Update dsmon.sh
This commit is contained in:
14
dsmon.sh
14
dsmon.sh
@@ -97,6 +97,8 @@ RUN(){
|
|||||||
CHECK(){
|
CHECK(){
|
||||||
start=`date +%s`
|
start=`date +%s`
|
||||||
|
|
||||||
|
C_CW=40
|
||||||
|
|
||||||
declare -A host_ip
|
declare -A host_ip
|
||||||
declare -A host_name
|
declare -A host_name
|
||||||
declare -A host_limits
|
declare -A host_limits
|
||||||
@@ -110,6 +112,9 @@ CHECK(){
|
|||||||
idsST=('')
|
idsST=('')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
MSG="Determining hosts and preparing"
|
||||||
|
c=0; cw=${C_CW}; spc=''; spc1=${cw}-${#MSG}; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
|
echo -en "${idsCL[LightCyan]}${MSG}${spc}: "
|
||||||
while read hostid hostname hostip hostlimits; do
|
while read hostid hostname hostip hostlimits; do
|
||||||
if [ "$hostid" != "id" ]; then
|
if [ "$hostid" != "id" ]; then
|
||||||
hostip=$(echo $hostip | cut -d ";" -f1)
|
hostip=$(echo $hostip | cut -d ";" -f1)
|
||||||
@@ -122,17 +127,22 @@ CHECK(){
|
|||||||
fi
|
fi
|
||||||
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0")
|
done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0")
|
||||||
# done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 AND host LIKE '%WAN%'")
|
# done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 AND host LIKE '%WAN%'")
|
||||||
|
|
||||||
IFS=$'\n' hostnames_sort=($(sort <<<"${hostnames_sort[*]}")); unset IFS
|
IFS=$'\n' hostnames_sort=($(sort <<<"${hostnames_sort[*]}")); unset IFS
|
||||||
|
echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}"
|
||||||
|
|
||||||
|
MSG="Starting jobs to collect host info"
|
||||||
|
c=0; cw=${C_CW}; spc=''; spc1=${cw}-${#MSG}; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
|
echo -en "${idsCL[LightCyan]}${MSG}${spc}: "
|
||||||
#for hostid in "${!host_ip[@]}"; do
|
#for hostid in "${!host_ip[@]}"; do
|
||||||
for hostname in "${hostnames_sort[@]}"; do
|
for hostname in "${hostnames_sort[@]}"; do
|
||||||
RUN_CHECK ${hostname} > /tmp/dscheck.${hostname}.results 2>/dev/null &
|
RUN_CHECK ${hostname} > /tmp/dscheck.${hostname}.results 2>/dev/null &
|
||||||
done
|
done
|
||||||
|
echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}"
|
||||||
|
echo
|
||||||
|
|
||||||
nc_count=0; completed=false; scanstart=$(date +%s)
|
nc_count=0; completed=false; scanstart=$(date +%s)
|
||||||
until [ "${completed}" == "true" ]; do
|
until [ "${completed}" == "true" ]; do
|
||||||
for host in /tmp/dscheck.*.done; do
|
for host in /tmp/dscheck.*.done >/dev/null 2>&1; do
|
||||||
NTS=$(grep -oP '(?<=dscheck.).*?(?=.done)' <<< "${nodestatus}")
|
NTS=$(grep -oP '(?<=dscheck.).*?(?=.done)' <<< "${nodestatus}")
|
||||||
if [ "${NTS}" != "*" ]; then
|
if [ "${NTS}" != "*" ]; then
|
||||||
hoststatus=$(cat /tmp/dscheck.${NTS}.results)
|
hoststatus=$(cat /tmp/dscheck.${NTS}.results)
|
||||||
|
|||||||
Reference in New Issue
Block a user