El problema es que el comando que se usa para monitorizar discos locales no vale para monitorizar discos compartidos en una SAN/NAS (los que aparecen enlazados bajo /vmfs en los host ESX).
Para poder monitorizar esos volúmenes, hace falta algún paso adicional que paso a describir.
- Creamos un fichero con el contenido que hay al final del post: vi /usr/lib/nagios/plugins/check_vdisk_porcent.sh
- Le damos permisos de ejecución: chmod a+x /usr/lib/nagios/plugins/check_vdisk_porcent.sh
- Ejecutamos "visudo" para cambiar un par de líneas:
- Comentar la de "Defaults requiretty"
- Agregar la línea "nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_vdisk_porcent.sh"
Luego ya solo queda que desde el nagios le hagas una consulta de este estilo: check_nrpe -H 192.168.X.X -p 5666 -t 60 -c check_vdisk -a 10 5 'ST3-disco01'
El primer parámetro indica el porcentaje para "WARNING" (10 en este caso) y el segundo el de "CRITICAL"
CONTENIDO DEL FICHERO /usr/lib/nagios/plugins/check_vdisk_porcent.sh (no es el original, le he hecho algunos apaños/mejoras)
# Author: James Chase
# Contact: james@chasecomputers.net
# Description: A script to check Virtual Disk Information on ESX 3.5.
# It only checks space in terms of Gigabytes. If you have a
# Terabyte or more, this isn't a problem. If you are checking
# a drive that is being reported in Megabytes, then it is just
# going to tell you that the drive has no space left (which
# if we are talking about ESX DataStores might as well be true).
# This is due to bash only doing integer math. Maybe I will
# re-write this script with awk or something at some point,
# but if you know enough to view this file, then you probably
# are a better scripter than me =o)
# Also it would be nice if it accepted command line options, and
# probably the logic could be written to execute faster. Oh well.
# Hope it can be some help to you.
if test "$#" -ne 3
then
echo "Usage: check_vdisk.sh [Warning%] [Critical%] [Mount Point of volume]"
exit 3
fi
warning=$1
critical=$2
search=$3
#echo $1 $2 $3 >> /tmp/logcualquiera
#echo $search
freeSpace=`/usr/sbin/vdf -h | grep "$search"`
#echo $freeSpace >> /tmp/logcdisk.txt
freeSpace=`echo $freeSpace | awk '{print $(NF-1)}'`
#echo $freeSpace >> /tmp/logcdisk.txt
if [ "$freeSpace" != "" ]
then
freeSpace=`echo $freeSpace | sed s/[%]//`
#echo $freeSpace >> /tmp/logcdisk.txt
freeSpace=$((100 - $freeSpace))
#echo $freeSpace >> /tmp/logcdisk.txt
if test $freeSpace -le $critical
then
echo "DISK CRITICAL $freeSpace% libre | $search=$freeSpace%;$warning;$critical"
exit 2
fi
if test $freeSpace -le $warning
then
echo "DISK WARNING $freeSpace% libre | $search=$freeSpace%;$warning;$critical"
exit 1
fi
if test $freeSpace -gt $warning
then
echo "DISK OK $freeSpace% libre | $search=$freeSpace%;$warning;$critical"
exit 0
fi
else
echo 'DISK CRITICAL - The filesystem doesnt exist or there is a script error'
exit 3
fi
