check_nt!USEDDISKSPACE
returns the both of size and percentage of disk usage. But thresholds are percentage.
If you want to receive alert based on size, you can write a wrapper shell script for check_nt
command, e.g check_disk_by_size
:
#!/bin/bash
FREESPACE=`/usr/local/nagios/libexec/check_nt -H $2 -p 12489 -s pa$$word \
-v USEDDISKSPACE -l $4 | awk -F"- " '{ print $4 }' | awk -F "|" '{ print $1 }'`
SIZE=`echo $FREESPACE | awk '{ print $2 }'`
UNIT=`echo $FREESPACE | awk '{ print $3 }'`
if [ $UNIT == "Gb" ]; then
SIZE=`echo $SIZE \* 1024 | bc`
fi
if [ `echo "$SIZE >= $6" | bc` -eq 1 ]; then
echo "$4:\_Drive_Space OK - $FREESPACE"
exit 0
elif [ `echo "$SIZE < $6" | bc` -eq 1 -a `echo "$SIZE > $8" | bc` -eq 1 ]; then
echo "$4:\_Drive_Space WARNING - $FREESPACE"
exit 1
elif [ `echo "$SIZE <= $8" | bc` -eq 1 ]; then
echo "$4:\_Drive_Space CRITICAL - $FREESPACE"
exit 2
fi
Testing:
$ check_disk_by_size.sh -H 192.168.6.31 -l c -w 10240 -c 5120
c:\_Drive_Space OK - free 13.01 Gb (36%)
$ check_disk_by_size.sh -H 192.168.6.31 -l c -w 14240 -c 5120
c:\_Drive_Space WARNING - free 13.01 Gb (36%)
$ check_disk_by_size.sh -H 192.168.6.31 -l c -w 16240 -c 15120
c:\_Drive_Space CRITICAL - free 13.01 Gb (36%)
You can add it to Nagios like this:
"check_disk_by_size.sh".
# 'check_disk_by_size' command definition
define command{
command_name check_disk_by_size
command_line $USER1$/check_disk_by_size.sh -H $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$
}
define service{
use generic-service
host_name fileserver1
service_description Drive Space fileserver1: L:
check_command check_disk_by_size!-l L -w 4096 -c 2048
notifications_enabled 1
}