Update dsmon.sh

This commit is contained in:
2023-01-02 22:01:45 -06:00
parent 814eb8f860
commit 993314e59f

View File

@@ -263,17 +263,19 @@ 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")
# 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
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
echo ${1}
}
case $action in