From ee33f93db7912fba215558ccbf6000a63d725cce Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 14 Jun 2025 12:15:21 -0500 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index 134448e..8c5c91d 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -148,8 +148,13 @@ CHECK(){ for hostname in "${hostnames_sort[@]}"; do until [ $(ls /tmp/dscheck.*.running 2>/dev/null | wc -l) -lt 12 ]; do tmp=tmp; done # RUN_CHECK ${hostname} > /tmp/dscheck.${hostname}.results & - ( RUN_CHECK "${hostname}"; echo ) | tee "/tmp/dscheck.${hostname}.results" > /dev/null & + echo "#!/bin/bash +/usr/local/bin/dsmon runcheck \"${hostname}\"" > /tmp/run_check_${hostname}.sh +chmod +x /tmp/run_check_${hostname}.sh +/tmp/run_check_${hostname}.sh > "/tmp/dscheck.${hostname}.results" & + + done [ "${1}" != "report" ] && echo -e "${idsCL[LightGreen]}Done${idsCL[Default]}\n" @@ -186,6 +191,26 @@ CHECK(){ echo } +RUNCHECK(){ + declare -A host_ip + declare -A host_name + declare -A host_limits + declare -A host_ids + declare -a hostnames_sort + 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 AND host='${1}'") + RUN_CHECK ${1} +} + RUN_CHECK(){ hostname=${1} touch /tmp/dscheck.${hostname}.running @@ -570,7 +595,7 @@ if [[ "${noheader}" != *" ${1} "* ]] && [[ "${noheader}" != *" ${2} "* ]]; then fi case ${ACTION} in check) CHECK ${2};; - runcheck) RUN_CHECK ${2};; + runcheck) RUNCHECK ${2};; setupssh) SETUPSSH;; get-crontabs) GETCRONTABS ${2};; get-crontab) GETCRONTAB ${2};;