Monday, July 27, 2009

Solved : Adding Perfromace Data to External Scripts in NSClient++ for Nagios

Insering Perfromance data to the External Script that you executes with NSClient++ to send data to Nagios Monitoring Server. For that simply you can create a .bat file as follows.

echo off
echo <string>^|<performance data>
exit <code>

Explanantion of the tags given in the sample can be given as follows.

<string> : Just a string with Nagios Status Information. No Specific way of this string

^| : the HAT (^) mark before the pipe(|) is used to avoid the pipe symbol making a dos command

<performance data> : Making this data in a specific way helps you to use many graphing techniqus (such as pnp4nagios) without any problem. It should come as "<key>=<value>;<warn>;<critical>;<min>;<max>"

<code> : the code can be a value from 0 to 3. 0-OK, 1-WARNING, 2-CRITICAL, 3-UNKNOWN, will be displayed on Magios Status.

So the final sample code of a .bat file can be shown as follows.

echo off
echo CPU works fine. ^| CPU_Load=34;70;95;0;100
exit 0

This will show that the current CPU_Load is 34, 70 is the level of WARNING and 95 is the level of CRITICAL. And the value varies from 0 to 100. And the exit code 0 shows that the Status is OK. The Status Information shows that "CPU works fine"

For more information you can check Nagios Performance Data, Nagios Plugin API and Thread By Michael Medin on this matter in NSClient++

No comments: