Update dsmon.sh
This commit is contained in:
22
dsmon.sh
22
dsmon.sh
@@ -97,6 +97,7 @@ CHECK(){
|
||||
|
||||
declare -A host_ip
|
||||
declare -A host_name
|
||||
declare -A host_name_full
|
||||
declare -A host_limits
|
||||
declare -A host_ids
|
||||
declare -a hostnames_sort
|
||||
@@ -120,11 +121,12 @@ CHECK(){
|
||||
# echo "$hostid - $hostip - $hostname - $hostlimits"
|
||||
host_ip[${hostid}]=$hostip
|
||||
host_name[${hostid}]=$hostname
|
||||
host_name_full[${hostid}]=$hostname_full
|
||||
host_limits[${hostid}]=$hostlimits
|
||||
host_ids[$hostname]=$hostid
|
||||
hostnames_sort+=("$hostname")
|
||||
fi
|
||||
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 AND (host LIKE '%${1}%' OR ip LIKE '%${1}%')")
|
||||
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,hostname_full,ip,limits FROM servermonitor.hosts WHERE disabled=0 AND (host LIKE '%${1}%' OR ip LIKE '%${1}%')")
|
||||
else
|
||||
while read hostid hostname hostip hostlimits; do
|
||||
if [ "$hostid" != "id" ]; then
|
||||
@@ -132,11 +134,12 @@ CHECK(){
|
||||
# echo "$hostid - $hostip - $hostname - $hostlimits"
|
||||
host_ip[${hostid}]=$hostip
|
||||
host_name[${hostid}]=$hostname
|
||||
host_name_full[${hostid}]=$hostname_full
|
||||
host_limits[${hostid}]=$hostlimits
|
||||
host_ids[$hostname]=$hostid
|
||||
hostnames_sort+=("$hostname")
|
||||
fi
|
||||
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0")
|
||||
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,hostname_full,ip,limits FROM servermonitor.hosts WHERE disabled=0")
|
||||
fi
|
||||
|
||||
IFS=$'\n' hostnames_sort=($(sort <<<"${hostnames_sort[*]}")); unset IFS
|
||||
@@ -198,20 +201,22 @@ CHECK(){
|
||||
RUNCHECK(){
|
||||
declare -A host_ip
|
||||
declare -A host_name
|
||||
declare -A host_name_full
|
||||
declare -A host_limits
|
||||
declare -A host_ids
|
||||
declare -a hostnames_sort
|
||||
while read hostid hostname hostip hostlimits; do
|
||||
while read hostid hostname hostname_full hostip hostlimits; do
|
||||
if [ "$hostid" != "id" ]; then
|
||||
hostip=$(echo $hostip | cut -d ";" -f1)
|
||||
# echo "$hostid - $hostip - $hostname - $hostlimits"
|
||||
host_ip[${hostid}]=$hostip
|
||||
host_name[${hostid}]=$hostname
|
||||
host_name_full[${hostid}]=$hostname_full
|
||||
host_limits[${hostid}]=$hostlimits
|
||||
host_ids[$hostname]=$hostid
|
||||
hostnames_sort+=("$hostname")
|
||||
fi
|
||||
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 AND host='${1}'")
|
||||
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,hostname_full,ip,limits FROM servermonitor.hosts WHERE disabled=0 AND host='${1}'")
|
||||
RUN_CHECK ${1}
|
||||
}
|
||||
|
||||
@@ -222,11 +227,12 @@ RUN_CHECK(){
|
||||
|
||||
|
||||
MSG=" ${host_name[$hostid]}"
|
||||
MSG2="- [ ${host_ip[$hostid]} ] - "
|
||||
c=0; cw=85; spc=''; spc1=`expr ${cw} - ${#MSG} - ${#MSG2}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||
# c=0; cw2=20; spcB=''; spc1=`expr ${cw2} - ${#MSG2}`; until [ $c = ${spc1} ]; do spcB="${spcB} "; c=`expr $c + 1`; done
|
||||
MSG2="( ${host_name_full[$hostid]} )"
|
||||
MSG3="[ ${host_ip[$hostid]} ] "
|
||||
c=0; cw=85; spcA=''; spcB=''; spc1=`expr ${cw} - ${#MSG} - ${#MSG2} - ${#MSG3}`; spc1=$((spc1/2)); spc2=$((85-spc1))
|
||||
until [ $c = ${spc1} ]; do spcA="${spcA} "; c=`expr $c + 1`; done; until [ $c = ${spc2} ]; do spcB="${spcB} "; c=`expr $c + 1`; done
|
||||
DIVIDER 1 . 85
|
||||
echo -e "${idsST[Bold]}${idsBG[Blue]}${idsCL[White]}${MSG}${spc}${MSG2}${idsST[Reset]}"
|
||||
echo -e "${idsST[Bold]}${idsBG[Blue]}${idsCL[White]}${MSG}${spcA}${MSG2}${spcB}${MSG3}${idsST[Reset]}"
|
||||
DIVIDER . . 85
|
||||
|
||||
checkhost=$(CHECK_HOST ${host_ip[$hostid]})
|
||||
|
||||
Reference in New Issue
Block a user