check_nt!USEDDISKSPACE
retorna o tamanho e a porcentagem do uso do disco. Mas os limites são percentuais.
Se você deseja receber alertas com base no tamanho, pode escrever um script de shell de wrapper para o comando check_nt
, por exemplo, 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
Teste:
$ 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%)
Você pode adicioná-lo ao Nagios assim:
"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
}