Nagios plugin

Started by lweidig, October 03, 2012, 10:15:24 PM

Previous topic - Next topic

lweidig

I am trying to simply use the Nagios check_dhcp plugin to test some DHCP services in our network.  On the agent running on the same machine as the server I created the following entry:

ExternalParameterShellExec = Dhcp.Check(*):/usr/lib/nagios/plugins/check_dhcp -u -s $1 -m $2 > /dev/null ; echo $?


I then created a DCI for one of my machines using the NetXMS server as the proxy:

Dhcp.Check(1.2.3.4,"11:22:33:44:55:66")

The server shows the value in ERROR.  When I debug with agent I get:

[03-Oct-2012 13:57:13] [session:0] Requesting parameter "Dhcp.Check(1.2.3.4,"11:22:33:44:55:66")"
[03-Oct-2012 13:57:13] H_ExternalParameter called for "Dhcp.Check(1.2.3.4,"11:22:33:44:55:66")" "S/usr/lib/nagios/plugins/check_dhcp -u -s $1 -m $2 > /dev/null ; echo $?"
[03-Oct-2012 13:57:13] H_ExternalParameter: command line is "/usr/lib/nagios/plugins/check_dhcp -u -s 1.2.3.4 -m 11:22:33:44:55:66 > /dev/null ; echo ?"
[03-Oct-2012 13:57:13] H_ExternalParameter (shell exec): worker thread created
[03-Oct-2012 13:57:15] H_ExternalParameter (shell exec): execution timeout
[03-Oct-2012 13:57:15] H_ExternalParameter (shell exec): execution status 2
[03-Oct-2012 13:57:15] [session:0] GetParameterValue(): result is 500 (INTERNAL_ERROR)
[03-Oct-2012 13:57:15] [session:0] Sending message CMD_REQUEST_COMPLETED (size 32)
[03-Oct-2012 13:57:15] [session:0] Received message CMD_GET_PARAMETER
[03-Oct-2012 13:57:15] [session:0] Requesting parameter "Dhcp.Check(1.2.3.4,"11:22:33:44:55:66")"
[03-Oct-2012 13:57:15] H_ExternalParameter called for "Dhcp.Check(1.2.3.4,"11:22:33:44:55:66")" "S/usr/lib/nagios/plugins/check_dhcp -u -s $1 -m $2 > /dev/null ; echo $?"
[03-Oct-2012 13:57:15] H_ExternalParameter: command line is "/usr/lib/nagios/plugins/check_dhcp -u -s 1.2.3.4 -m 11:22:33:44:55:66 > /dev/null ; echo ?"
[03-Oct-2012 13:57:15] H_ExternalParameter (shell exec): worker thread created
[03-Oct-2012 13:57:15] H_ExternalParameter/POpenWorker: worker thread pipe read result: 0x7f84e0001070
[03-Oct-2012 13:57:17] H_ExternalParameter (shell exec): execution timeout
[03-Oct-2012 13:57:17] H_ExternalParameter (shell exec): execution status 2
[03-Oct-2012 13:57:17] [session:0] GetParameterValue(): result is 500 (INTERNAL_ERROR)
[03-Oct-2012 13:57:17] [session:0] Sending message CMD_REQUEST_COMPLETED (size 32)
[03-Oct-2012 13:57:17] [session:0] Received message CMD_GET_PARAMETER
[03-Oct-2012 13:57:17] [session:0] Requesting parameter "Dhcp.Check(1.2.3.4,"11:22:33:44:55:66")"
[03-Oct-2012 13:57:17] H_ExternalParameter called for "Dhcp.Check(1.2.3.4,"11:22:33:44:55:66")" "S/usr/lib/nagios/plugins/check_dhcp -u -s $1 -m $2 > /dev/null ; echo $?"
[03-Oct-2012 13:57:17] H_ExternalParameter: command line is "/usr/lib/nagios/plugins/check_dhcp -u -s 1.2.3.4 -m 11:22:33:44:55:66 > /dev/null ; echo ?"
[03-Oct-2012 13:57:17] H_ExternalParameter (shell exec): worker thread created
[03-Oct-2012 13:57:17] H_ExternalParameter/POpenWorker: worker thread pipe read result: 0x7f84e0001340
[03-Oct-2012 13:57:17] H_ExternalParameter/POpenWorker: worker thread pipe read result: 0x7f84e0001070


Have also tried this with the agent configuration as just ExternalParameter.  Still not 100% sure on the difference of the two. 

Running the parsed command from the server produces the desired results, 0 if everything works and 2 if there is no offer.

lweidig

Ok, followup and solution on my own post.  Two changes were necessary:

1.  In the nxagentd.conf needed to add a line:
ExecTimeout = 5000

2. The external parameter line ended up removing the "ShellExec" portion AND had an additional $ added to the echo resulting in:

ExternalParameter = Dhcp.Check(*):/usr/lib/nagios/plugins/check_dhcp -u -s $1 -m $2 > /dev/null ; echo $$?

Still confused as to when you would use the ShellExec version versus not, but will keep moving along.  Value is properly collecting at this point and can be added to the system controls.

Victor Kirhenshtein

Hi!

Few clarifications:

1. There are no difference between ExternalParameter and ExternalParameterShellExec on UNIX/Linux. They only behave differently on Windows.

2. There are two timeouts that must be taken into consideration:
a) ExecTimeout on agent - timeout for executing external program
b) AgentCommandTimeout on server - timeout for any command sent from server to client

In general AgentCommandTimeout must be greater or equal to ExecTimeout.

Also, if you have couple of external parameters with possible long collection time, you may create wrapper script to get them all at once and use it as external parameters provider - see wiki for details: http://wiki.netxms.org/wiki/ExternalParametersProvider.

Best regards,
Victor