The recent use of a partition on the line was too fast, and Nagios did not turn on the monitoring of partition usage, taking a few minutes to temporarily write a script to use first. The usage is relatively simple, directly on the code:
Note: The SendEmail script used in the code is an e-mail program developed by Perl that can be found online or using other email scripts
#!/bin/bash#--dir:monitoring of the mount point#--critical:critical value#--warning: warning value #--ip[ $# -eq 0 ] && { echo "$0 [--dir path --critical num --warning num  -H|--HELP] " exit 99}while [ $# -ne 0 ];d ocase $1 in -h|--help) echo "$0 [--dir  PATH --CRITICAL NUM --WARNING NUM -H|--HELP] " --dir) dir=$2 --critical) critical=$2 shift 2 ;; --warning) WARNING=$2 shift 2 ;;         --IP) IP=$2 shift 2 ;; *) echo "$0 [--dir path --critical num --warning num -h |--HELP] " exit 99 ;; Esacdoneuseage= ' df -h|awk -v mount= $DIR ' $NF ==mount{print $ (NF-1)} ' |cut -d% -f1 ' if [ $USEAGE -ge $CRITICAL ];then msg= "Problem service alert: $IP: $DIR is CRITICAL,Used $USEAGE%" /usr/local/bin/sendEmail -f FROMEMAIL -t TOEMAIL -s smtpserver -u "SUBJECT" -xu YOURUSERNAME -xp YOUPASS -m "$MSG" elif [ $Useage -ge $WARNING ];then msg= "PROBLEM Service alert: $IP: $DIR is WARNING,Used $USEAGE% " /usr/local/bin/sendemail -f fromemail -t toemail -s smtpserver -u "SUBJECT" -xu YOURUSERNAME -xp YOUPASS -m "$MSG" fi
Usage:./monitorback.sh--dir/back--ip 192.168.1.100--critical 70--warning
This article is from the "Diannaowa" blog, make sure to keep this source http://diannaowa.blog.51cto.com/3219919/1617262
Shell script monitors partition usage, concurrent mail alerts