Blog

NSClient++

NSClient++

Desde hacía unos día Nagios me daba error al comprobar el uso de CPU de un host:
Current Status: UNKNOWN  (for Xd Xh Xm XXs)
Status Information: NSClient - ERROR: Could not get data for 1440 please check log for details
Al probar el comando correspondiente el resultado era el mismo:
[root@nagios libexec]# ./check_nt -H tempesta2 -v CPULOAD -l "1440,95,100"
NSClient - ERROR: Could not get data for 1440 please check log for details
El log mostraba lo siguiente:
2014-04-30 13:23:34: e:..\..\..\..\trunk\modules\CheckSystem\PDHCollector.cpp:223: Failed to get CPU value: \238(_total)\6: Length given larger then interval: 864000 >= 36010
Buscando en Internet, encontré este enlace donde se explicaba que era un problema del buffer. Por defecto está establecido a 1h, pero yo le estaba pidiendo 24h (1440 minutos). Antes de cambiar nada, probé si realmente funcionaba con 1h:
[root@nagios libexec]# ./check_nt -H tempesta2 -v CPULOAD -l "60,95,100"
CPU Load 0% (60 min average) |   '60 min avg Load'=0%;95;100;0;100
[root@nagios libexec]# ./check_nt -H tempesta2 -v CPULOAD -l "61,95,100"
NSClient - ERROR: Could not get data for 61 please check log for details
Efectivamente, funciona con 60 minutos y falla con 61. Para cambiar a 24h, basta modificar la configuración del cliente instalado en el host. En mi caso era NSClient++, y el fichero de configuración NSC.ini. Le añadí la siguiente entrada:
# DEFAULT LENGTH
# Used to define the default intervall for range buffer checks (ie. CPU).
[/settings/system/windows]
default buffer length=24h
A cotinuación reiniciamos el servicio de NSClient++:
C:\Documents and Settings\Administrador>net stop nscp
The NSClient++ (Win32) service is stopping..
The NSClient++ (Win32) service was stopped successfully.

C:\Documents and Settings\Administrador>net start nscp
The NSClient++ (Win32) service is starting.
The NSClient++ (Win32) service was started successfully.

Finalmente, comprobamos que funcione para 1440 minutos:
[root@nagios libexec]# ./check_nt -H tempesta2 -v CPULOAD -l "1440,95,100"
CPU Load 0% (1440 min average) |   '1440 min avg Load'=0%;95;100;0;100