Home Directory Plugins Operating Systems Linux Check IO stats of one or all disks

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check IO stats of one or all disks

Rating
6 votes
Favoured:
4
Current Version
1.0
Last Release Date
2011-09-07
Compatible With
  • Nagios 3.x
License
GPL
Hits
120780
Files:
FileDescription
check_diskstat.shFixed read and written bytes per seconds in output
check_all_diskstat.shPlease, review path to check_diskstat.sh before using it
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
This plug-in checks IO stats of one (or all) disk. It can be used to send alerts when maximum hard drive IO/s or sectors read|write/s is reached.
This plug-in checks IO stats of one (or all) disk. It can be used to send alerts when maximum hard drive IO/s or sectors read|write/s is reached

Usage:
./check_diskstat.sh -d DEVICE -w tps,read,write -c tps,read,write | -h

-d DEVICE DEVICE must be without /dev (ex: -d sda)
-w/c TPS,READ,WRITE TPS means transfer per seconds (aka IO/s)
READ and WRITE are in sectors per seconds

Example: ./check_diskstat.sh -d sda -w 200,100000,100000 -c 300,200000,200000

This plugin use /sys filesystem for retrieving data. Average values are then calculated by keeping an history file.

In order to check all disks on your system, you can use check_all_diskstat.sh. (Please, review it to correctly set path to check_diskstat.sh)
Reviews (3)
bymonty, September 6, 2018
There is a better way to get the modify timestamp of a file - check the -c option of stat:
OLDDISKSTAT_EPOCH=$(stat $HISTFILE -c %Y)

Furthermore the perfdata documentation states, that you should add the warning and crit levels:
echo "${OUTPUT}summary: $TPS io/s, read $SECTORS_READ sectors (${KBYTES_READ_PER_SEC}kB/s), write $SECTORS_WRITE sectors (${KBYTES_WRITTEN_PER_SEC}kB/s) in $TIME seconds | tps=${TPS};${WARN_TPS};${CRIT_TPS};; read=${BYTES_READ_PER_SEC};${WARN_READ};${CRIT_READ};; write=${BYTES_WRITTEN_PER_SEC};${WARN_WRITE};${CRIT_WRITE};;"
bykalavan, January 4, 2017
Plugin is reading /sys/block/DEVICE/stat file, so does not depend on output of other programs (like iostat). Also keeps continuous measurement of system by keeping previous read in temporary file.

One thing to point out though: Plugin checks read/write tresholds against bytes read/written per second, not against sectors per second as help states.
It's very useful check which must be turned on for every server!

PS: but small changes for check_all_diskstat.sh can be applied as soon it not returning a correct exit status for nagios notification.

I make some changes which can help somebody else:
###################
#!/bin/bash
EXITCODE=0
CHK=/usr/lib/nagios/plugins/check_diskstat.sh
WARN=${1:-"300,10000,10000"}
CRIT=${2:-"400,20000,20000"}

for DEVICE in `ls /sys/block`; do
if [ -L /sys/block/$DEVICE/device ]; then
DEVNAME=$(echo /dev/$DEVICE | sed 's#!#/#g')
echo -n "$DEVNAME: "
OUTPUT="`$CHK -d $DEVICE -w $WARN -c $CRIT`"
STATUS=$?
if [ "$EXITCODE" -le "$STATUS" ]; then
EXITCODE=$STATUS;
fi
echo $OUTPUT | sed "s#=#_$DEVNAME=#g"
fi
done
exit $EXITCODE
###################