Update dsmon.sh
This commit is contained in:
31
dsmon.sh
31
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);;
|
||||
|
||||
Reference in New Issue
Block a user