Update dsmon.sh
This commit is contained in:
26
dsmon.sh
26
dsmon.sh
@@ -340,31 +340,16 @@ SETUPSSH(){
|
|||||||
RUNCMD(){
|
RUNCMD(){
|
||||||
start=`date +%s`
|
start=`date +%s`
|
||||||
|
|
||||||
declare -A host_ip
|
|
||||||
declare -A host_name
|
|
||||||
|
|
||||||
rm -f /tmp/.dsmon.runcmd.*
|
rm -f /tmp/.dsmon.runcmd.*
|
||||||
|
|
||||||
|
ncount=0
|
||||||
while read hostid hostname hostip hostlimits; do
|
while read hostid hostname hostip hostlimits; do
|
||||||
if [ "${hostname}" != "host" ]; then
|
if [ "${hostname}" != "host" ]; then
|
||||||
host_ip[${hostid}]=$(echo ${hostip} | cut -d ";" -f1)
|
RUNCMD_SUB $(echo ${hostip} | cut -d ";" -f1) ${hostname} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} &
|
||||||
host_name[${hostid}]="${hostname}"
|
((ncount++))
|
||||||
fi
|
fi
|
||||||
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC")
|
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC")
|
||||||
|
|
||||||
ncount=0
|
|
||||||
for hostid in "${!host_ip[@]}"; do
|
|
||||||
# checkhost=$(CHECK_HOST ${host_ip[$hostid]})
|
|
||||||
# if [ "${checkhost}" != "false" ]; then
|
|
||||||
# echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Running command: ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20}${idsCL[Default]}${idsST[Reset]}"
|
|
||||||
# ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${host_ip[$hostid]} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20}
|
|
||||||
# else
|
|
||||||
# echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
|
|
||||||
# fi
|
|
||||||
RUNCMD_SUB ${host_ip[$hostid]} ${host_name[$hostid]} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} &
|
|
||||||
((ncount++))
|
|
||||||
done
|
|
||||||
|
|
||||||
nc_count=0; completed=false
|
nc_count=0; completed=false
|
||||||
until [ "${completed}" == "true" ]; do
|
until [ "${completed}" == "true" ]; do
|
||||||
for nodecmd in /tmp/.dsmon.runcmd.*.done; do
|
for nodecmd in /tmp/.dsmon.runcmd.*.done; do
|
||||||
@@ -375,14 +360,15 @@ RUNCMD(){
|
|||||||
# [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n"
|
# [ "${nodecmd_output}" != "" ] && echo -e "${nodecmd_output}\n"
|
||||||
# fi
|
# fi
|
||||||
# rm -f ${nodecmd}
|
# rm -f ${nodecmd}
|
||||||
|
echo ${nodecmd}
|
||||||
((nc_count++))
|
((nc_count++))
|
||||||
done
|
done
|
||||||
echo "${ncount} - ${nc_count}"
|
echo "${ncount} - ${nc_count}\n"
|
||||||
if [ ${nc_count} -eq ${ncount} ]; then
|
if [ ${nc_count} -eq ${ncount} ]; then
|
||||||
completed=true
|
completed=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 1s
|
sleep 2s
|
||||||
done
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user