From 45e9373ce9b298988399e635ef9a994f321c01ab Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 15 Jul 2023 18:40:29 -0500 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/dsmon.sh b/dsmon.sh index 33d60e9..7a576fc 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -298,6 +298,36 @@ RUNCMD(){ } GETTSIP(){ + start=`date +%s` + + declare -A host_ip + declare -A host_name + + while read hostid hostname hostip hostlimits; do + if [ "$hostid" != "id" ]; then + host_ip[${hostid}]=$(echo $hostip | cut -d ";" -f1) + host_name[${hostid}]=$hostname + fi + done <<< $(MYSQL_PWD="sysmoninsert" mysql -h ${mysqlip} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 AND ip LIKE '%100.100.%' ORDER BY host ASC") + + for hostid in "${!host_ip[@]}"; do + checkhost=$(CHECK_HOST ${host_ip[$hostid]}) + if [ "${checkhost}" != "false" ]; then + ssh -tq root@${host_ip[$hostid]} dsmon gettsip-node + else + echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}" + fi + done + + echo + end=`date +%s` + runtime=$((end-start)) + echo "Script Runtime: ${runtime}" + echo + +} + +GETTSIP_NODE(){ TSI=$(/sbin/ip link | grep tailscale0) if [ ${#TSI} != 0 ]; then TSIP=$(/sbin/ip -o -4 addr list tailscale0 | awk '{print $4}' | cut -d/ -f1) @@ -388,6 +418,7 @@ case $action in get-crontab) GETCRONTAB ${2};; fix-crontab) FIXCRONTAB;; gettsip) GETTSIP;; + gettsip-node) GETTSIP_NODE;; run) RUN ${2};; runcmd) RUNCMD ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11};; update);;