From f114fe0897f9799629d1980a80d6ea3637f41c51 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 14 Jun 2025 10:09:54 -0500 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index 0eb9c17..8366806 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -111,18 +111,17 @@ CHECK(){ c=0; cw=${C_CW}; spc=''; spc1=$(expr ${cw} - ${#MSG}); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[LightCyan]}${MSG}${spc}: " fi - MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0" | - while read hostid hostname 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_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" | while read hostid hostname 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_limits[${hostid}]=$hostlimits + host_ids[$hostname]=$hostid + hostnames_sort+=("$hostname") + fi + done # done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0") IFS=$'\n' hostnames_sort=($(sort <<<"${hostnames_sort[*]}")); unset IFS [ "${1}" != "report" ] && echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}"