From 024e93684d5b00a6932e44f7bfadabae3713f530 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 3 Jun 2025 21:02:17 -0500 Subject: [PATCH] Update dsmon.sh --- dsmon.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dsmon.sh b/dsmon.sh index acd3fe0..09a0dc2 100755 --- a/dsmon.sh +++ b/dsmon.sh @@ -187,7 +187,7 @@ RUN_CHECK(){ host_limits_tmp[$hlname]=$hllim done - DRIVEINFO=$(ssh -o BatchMode=yes -o ConnectTimeout=3 root@${host_ip[$hostid]} df -BM | grep -vE '^Filesystem|tmpfs|cdrom|@|ram|loop|udev|veeamimage|localhost|shm|overlay|-volume|Music|Software|//|AFS|PlexData_VG' | awk '{ print $1 " " $2 " " $4 }') + DRIVEINFO=$(${SSHCMD} root@${host_ip[$hostid]} df -BM | grep -vE '^Filesystem|tmpfs|cdrom|@|ram|loop|udev|veeamimage|localhost|shm|overlay|-volume|Music|Software|//|AFS|PlexData_VG' | awk '{ print $1 " " $2 " " $4 }') DRIVEINFO=(${DRIVEINFO}) # for x in "${!DRIVEINFO[@]}"; do printf "[%s]=%s\n" "$x" "${DRIVEINFO[$x]}" ; done @@ -301,7 +301,7 @@ RUN_CHECK(){ unset DRIVEINFO_TOT DRIVEINFO_FREE DRIVEINFO_FREEPER DRIVEINFO_SHORTNAME DRIVES DRIVEINFO host_limits_tmp - maillogsize=$(ssh -o BatchMode=yes -o ConnectTimeout=3 root@${host_ip[$hostid]} du -hs /var/log/mail.log | cut -d'/' -f 1) + maillogsize=$(${SSHCMD} root@${host_ip[$hostid]} du -hs /var/log/mail.log | cut -d'/' -f 1) if [[ "${maillogsize//[[:blank:]]/}" = *'G'* ]]; then if [ ! -f /tmp/dsmon.mail-log.${host_ip[$hostid]}.errorsent ] || ([ -f /tmp/dsmon.mail-log.${host_ip[$hostid]}.errorsent ] && [ $(expr $(date +%s) - $(stat -c %Y /tmp/dsmon.mail-log.${host_ip[$hostid]}.errorsent)) -gt 3600 ]); then SENDNOTICE "Mail Log Getting Big" "Mail log getting big (${maillogsize//[[:blank:]]/}) on ${hostname} [${host_ip[$hostid]}]" 1 @@ -353,7 +353,7 @@ RUNCMD(){ # while read hostid hostname hostip hostlimits; do # if [ "${hostname}" != "host" ]; then - # ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${hostip} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} + # ${SSHCMD} root@${hostip} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} # fi # done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT id,host,ip,limits FROM servermonitor.hosts WHERE disabled=0 ORDER BY host ASC") @@ -406,7 +406,7 @@ RUNCMD_SUB(){ tmpfile=/tmp/.dsmon.runcmd.${host// /-} touch ${tmpfile}.running > /dev/null 2>&1 echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host}${idsCL[Default]}${idsST[Reset]}" >> ${tmpfile}.running - if ssh_output=$(ssh -tq -o ConnectTimeout=5 -o ConnectionAttempts=1 root@${ip} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} 2>&1) ; then + if ssh_output=$(${SSHCMD} root@${ip} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} 2>&1) ; then echo -e "${idsCL[LightGreen]}SUCCESS: ${ssh_output}${idsCL[Default]}" >> ${tmpfile}.running else if [ "${ssh_output}" == "" ]; then @@ -425,7 +425,7 @@ RUNCMDSLOW(){ while read hostid hostname hostip hostlimits; do if [ "${hostname}" != "host" ]; then echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${hostname} - $(echo ${hostip} | cut -d ";" -f1)${idsCL[Default]}${idsST[Reset]}" - ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$(echo ${hostip} | cut -d ";" -f1) ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20} ${21} ${22} ${DS_CRONTAB_FOLDER}/${host}.crontab" + crontab -l | sshpass -p${1} ${SSHCMD} -o 'StrictHostKeyChecking no' nm_crontab_user@${nmip} "cat > ${DS_CRONTAB_FOLDER}/${host}.crontab" fi done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT host,hostname FROM servermonitor.hosts WHERE id=${SERVERMON_ID}") fi