Update dsmon.sh
This commit is contained in:
16
dsmon.sh
16
dsmon.sh
@@ -187,7 +187,7 @@ RUN_CHECK(){
|
|||||||
host_limits_tmp[$hlname]=$hllim
|
host_limits_tmp[$hlname]=$hllim
|
||||||
done
|
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})
|
DRIVEINFO=(${DRIVEINFO})
|
||||||
|
|
||||||
# for x in "${!DRIVEINFO[@]}"; do printf "[%s]=%s\n" "$x" "${DRIVEINFO[$x]}" ; done
|
# 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
|
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 [[ "${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
|
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
|
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
|
# while read hostid hostname hostip hostlimits; do
|
||||||
# if [ "${hostname}" != "host" ]; then
|
# 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
|
# 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")
|
# 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// /-}
|
tmpfile=/tmp/.dsmon.runcmd.${host// /-}
|
||||||
touch ${tmpfile}.running > /dev/null 2>&1
|
touch ${tmpfile}.running > /dev/null 2>&1
|
||||||
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host}${idsCL[Default]}${idsST[Reset]}" >> ${tmpfile}.running
|
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
|
echo -e "${idsCL[LightGreen]}SUCCESS: ${ssh_output}${idsCL[Default]}" >> ${tmpfile}.running
|
||||||
else
|
else
|
||||||
if [ "${ssh_output}" == "" ]; then
|
if [ "${ssh_output}" == "" ]; then
|
||||||
@@ -425,7 +425,7 @@ RUNCMDSLOW(){
|
|||||||
while read hostid hostname hostip hostlimits; do
|
while read hostid hostname hostip hostlimits; do
|
||||||
if [ "${hostname}" != "host" ]; then
|
if [ "${hostname}" != "host" ]; then
|
||||||
echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${hostname} - $(echo ${hostip} | cut -d ";" -f1)${idsCL[Default]}${idsST[Reset]}"
|
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} </dev/null
|
${SSHCMD} 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} </dev/null
|
||||||
echo
|
echo
|
||||||
fi
|
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")
|
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")
|
||||||
@@ -448,7 +448,7 @@ UPDATENODES(){
|
|||||||
while read hostid hostname hostip hostlimits; do
|
while read hostid hostname hostip hostlimits; do
|
||||||
if [ "${hostname}" != "host" ]; then
|
if [ "${hostname}" != "host" ]; then
|
||||||
echo -e "${idsCL[LightCyan]}Updating DSMON on '${hostname}'${idsCL[Default]}"
|
echo -e "${idsCL[LightCyan]}Updating DSMON on '${hostname}'${idsCL[Default]}"
|
||||||
ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@$(echo $hostip | cut -d ";" -f1) "dsmon update" </dev/null
|
${SSHCMD} root@$(echo $hostip | cut -d ";" -f1) "dsmon update" </dev/null
|
||||||
echo
|
echo
|
||||||
fi
|
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")
|
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")
|
||||||
@@ -503,7 +503,7 @@ GETCRONTABS(){
|
|||||||
# checkhost=$(CHECK_HOST ${host_ip[$hostid]})
|
# checkhost=$(CHECK_HOST ${host_ip[$hostid]})
|
||||||
# if [ "${checkhost}" != "false" ]; then
|
# if [ "${checkhost}" != "false" ]; then
|
||||||
# echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}"
|
# echo -e "${idsST[Bold]}${idsCL[LightCyan]} ${host_name[$hostid]} - Gathering Crontabs ... ${idsCL[Default]}${idsST[Reset]}"
|
||||||
ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd}
|
${SSHCMD} root@${host_ip[$hostid]} dsmon get-crontab ${rtpsswd}
|
||||||
# else
|
# else
|
||||||
# echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
|
# echo -e "${idsST[Bold]}${idsCL[Red]} ${host_name[$hostid]} - Timeout${idsCL[Default]}${idsST[Reset]}"
|
||||||
# fi
|
# fi
|
||||||
@@ -525,7 +525,7 @@ GETCRONTAB(){
|
|||||||
while read host hostname; do
|
while read host hostname; do
|
||||||
if [ "${host}" != "host" ] && [ "${host}" != "" ]; then
|
if [ "${host}" != "host" ] && [ "${host}" != "" ]; then
|
||||||
# echo -e "${SERVERMON_ID}) ${host} : ${hostname}\nmysqlip=${mysqlip}\n"
|
# echo -e "${SERVERMON_ID}) ${host} : ${hostname}\nmysqlip=${mysqlip}\n"
|
||||||
crontab -l | sshpass -p${1} ssh -tq -o ConnectTimeout=3 -o ConnectionAttempts=1 -o 'StrictHostKeyChecking no' nm_crontab_user@${nmip} "cat > ${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
|
fi
|
||||||
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT host,hostname FROM servermonitor.hosts WHERE id=${SERVERMON_ID}")
|
done <<< $(MYSQL_PWD="sysmoninsert" ${mysqlcmd} ${mysql_conn} -u sysmoninsert -e "SELECT host,hostname FROM servermonitor.hosts WHERE id=${SERVERMON_ID}")
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user