| Server IP : 118.27.122.120 / Your IP : 216.73.216.136 Web Server : Apache System : Linux web0216.sh.tyo1 4.18.0-553.141.2.lve.el7h.x86_64 #1 SMP Wed Jul 8 17:20:31 UTC 2026 x86_64 User : r4834334 ( 11094) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/thread-self/root/lib64/nagios/plugins/ |
Upload File : |
#!/usr/bin/bash
## monitor CPU iowait.
## Get avarage of recent 5 seconds. If iowait% avarage in several seconds too high,
## then report warning or critical.
## example "sar" command output is as follows.
## 15:19:58 CPU %user %nice %system %iowait %steal %idle
## 15:19:59 all 0.00 0.00 0.00 0.00 0.00 100.00
## 15:19:59 0 0.00 0.00 0.00 0.00 0.00 100.00
usage_exit(){
echo "usage: $0 -w <Warning_percentage> -c <Critical_percentage>"
echo "ex: $0 -w 70 -c 99"
exit 1
}
while getopts c:w:h OPT
do
case $OPT in
c) CRIT=$OPTARG
;;
w) WARN=$OPTARG
;;
h) usage_exit
;;
*) usage_exit
;;
esac
done
if [[ -z $CRIT ]];then
usage_exit
fi
IOWAIT=$( sar -P ALL 5 1 | awk '{print $6}' | sort -nr | head -1 )
if [[ -z $IOWAIT ]]; then
echo "UNKOWN - Error to get iowait info from sar command"
exit 3
fi
MSG=" maximum iowait is ${IOWAIT}% | iowait=${IOWAIT};;;;"
if [[ $(echo "$IOWAIT > $CRIT" | bc) == 1 ]]; then
echo "CRITICAL - $MSG"
exit 2
elif [[ $(echo "$IOWAIT > $WARN" | bc) == 1 ]]; then
echo "WARNING - $MSG"
exit 1
fi
echo "OK - $MSG"
exit 0