20111003

Nagios DISK UNKNOWN - free space:|

Tengo a medio montar un servidor de Nagios para chequear el funcionamiento de los servidores y servicios de mi organización. Los chequeos que por ahora tengo configurado son los básicos, disco, CPU, memoria, etc.
La cosa es que los chequeos de algunas particiones de mis servidores GNU/Linux me arrojan el siguiente resultado:
     Status: UNKNOWN
     Status information: DISK UNKNOWN - free space: |

Lo primero es conectarme al servidor de Nagios y realizar el chequeo desde la línea de comandos:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK UNKNOWN - free space:|

Y obtengo el mismo resultado. Lo siguiente es conectarme al cliente de Nagios, y comprobar la ejecución del plugin check_disk desde este. Copio el chequeo tal cual lo tengo en el fichero nrpe.cfg y lo ejecuto en el terminal:
bdispatcher@fileserver:~$ /opt/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

Pues aquí sí que funciona. Después de mucho probar y poco pensar, me doy cuenta de que el problema es que el chequeo lo ejecuta el proceso nrpe, que se ejecuta con el usuario nagios, el cual no tiene permisos sobre la ruta /opt/files, así que no puede comprobar el espacio del disco montado sobre esa ruta:
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
df: «/opt/files/datos»: Permiso denegado
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

Para resolverlo, basta con dar permisos a este usuario (más bien se los doy al resto de usuario y restrinjo el acceso más abajo en el árbol, y probamos de nuevo:
bdispatcher@fileserver:~$ sudo chmod 755 /opt/files
bdispatcher@fileserver:~$ su - nagios
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
/dev/sdd1              30G   25G  3,7G  88% /opt/files/datos
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

Al ejecutar ahora el chequeo obtengo el resultado esperado:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

Y con esto una piojera menos, y un warning más :-(

I am deploying a Nagios server to schedule some checks over the servers and the services on my organization. First of all, some of the basic checks like disk, CPU, memory, etc.
But some of the disk checks return an unknown status like this::
     Status: UNKNOWN
     Status information: DISK UNKNOWN - free space: |

The first that springs to my mind is to execute this check manually on the Nagios server:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK UNKNOWN - free space:|

With the same result, so the next step is to try it again but on the server which has the Nagios client installed. After a fast review of the nrpe.cfg configuration file to copy and paste the check and: 
bdispatcher@fileserver:~$ /opt/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

Wow!! It works here!! Some days and some tests after, I bump into the big clue. The checking process is executed by the nrpe, running with the user nagios, which has no permissions on the path /opt/files, so it can't check the free space available on the disk mounted on this path:
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
df: «/opt/files/datos»: Permiso denegado
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

All I need to solve it is to give read and execution (access) permissions to this user. I'll cut the access on a lower level on the tree:
bdispatcher@fileserver:~$ sudo chmod 755 /opt/files
bdispatcher@fileserver:~$ su - nagios
nagios@fileserver:~$ df -h
S.ficheros          Tamaño Usado  Disp Uso% Montado en
/dev/sda1             4,9G  1,3G  3,4G  28% /
/dev/sdc1             9,7G  5,2G  4,1G  57% /opt/files
/dev/sdd1              30G   25G  3,7G  88% /opt/files/datos
tmpfs                 506M     0  506M   0% /dev/shm
nagios@fileserver:~$

The next check gives me the expected output:
bdispatcher@nagserver:~$ /opt/nagios/libexec/check_nrpe -H fileserver -p 5666 -c check_sdd1
DISK WARNING - free space: /opt/files/datos 3696 MB (12% inode=99%);| /opt/files/datos=25003MB;24188;27212;0;30236

And that's all folks!

PS. I know, I know. My English is not good enought but, the more you help me, the more I learn.

No hay comentarios: