Update dsmon.sh
This commit is contained in:
17
dsmon.sh
17
dsmon.sh
@@ -259,11 +259,28 @@ SETUPSSH(){
|
||||
done
|
||||
}
|
||||
|
||||
RUNCMD(){
|
||||
declare -A host_ip
|
||||
declare -A host_name
|
||||
|
||||
while read hostid hostname hostip hostlimits; do
|
||||
if [ "$hostid" != "id" ]; then
|
||||
host_ip[${hostid}]=$(echo $hostip | cut -d ";" -f1)
|
||||
host_name[${hostid}]=$hostname
|
||||
fi
|
||||
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h mysqldb.scity.us -P 3306 -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts")
|
||||
|
||||
for hostid in "${!host_ip[@]}"; do
|
||||
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Running command: ${1}${idsCL[Default]}${idsST[Reset]}"
|
||||
ssh root@${host_ip[$hostid]} ${1}
|
||||
done
|
||||
}
|
||||
|
||||
case $action in
|
||||
check) CHECK ${2};;
|
||||
setupssh) SETUPSSH;;
|
||||
run) RUN ${2};;
|
||||
runcmd) RUNCMD ${2};;
|
||||
update);;
|
||||
*) RUN ${action};;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user