Page 1 of 1

Using python plugin in Nagios XI

Posted: Fri Sep 25, 2015 2:53 pm
by rawwrr
Hi,

I'm trying to use the check_esxi_hardware.py plugin to check my hosts' hardware. I installed the pywbem extension and it works just fine when I run the following command directly on the Nagios server in the plugin folder;

[user@server libexec]#python ./check_esxi_hardware.py -H host -U user -P password -v

plugin; https://exchange.nagios.org/directory/P ... py/details

If I try to run the command in Nagios XI, I get not output, no error message, nothing. I'm pretty sure the problem comes from an error I made in my command - although I tried many different commands but I couldn't get it to work.

My command in Nagios XI;

$USERS1$\python ./check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -v

Is it possible that I'm doing this the wrong way? (I'm fairly sure I am!)

Thanks!

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 8:28 am
by tgriep
The user section of your command isn't defined correctly. Try defining the command like below and see if it works for you.

Code: Select all

$USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$ -v

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 9:13 am
by rawwrr
Hi,

Thanks for the help - I tried with the suggested command but I still have the same issue, there's no output in Nagios;

COMMAND: /usr/local/nagios/libexec/check_esxi_hardware.py -H 0.0.0.0 -U user -P password
OUTPUT:

I'm still looking into the "python issue".
Thanks

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 9:17 am
by jdalrymple
Can you run it without calling the interpreter from the command line? If not it's probably as simple as doing `chmod +x /path/to/your/check_esxi_hardware.py`

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 1:39 pm
by rawwrr
Actually I can't --> /usr/bin/python: No such file or directory (yet it really exists!)

So I can run the command successfully in nagios this way;
/usr/bin/python $USER1$/check_esxi_hardware.py -H $HOSTADDRESS$ -U $ARG1$ -P $ARG2$

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 1:48 pm
by Box293
rawwrr wrote:Hi,

Thanks for the help - I tried with the suggested command but I still have the same issue, there's no output in Nagios;

COMMAND: /usr/local/nagios/libexec/check_esxi_hardware.py -H 0.0.0.0 -U user -P password
OUTPUT:

I'm still looking into the "python issue".
Thanks
When you use the "Test Command" button it runs as the user apache, which is different to the nagios user that the monitoring engine runs as. There are some problems with the "Test Command" button so instead, save, apply config, find the service in the XI GUI (not CCM) and Schedule an immediate check. Does this work?

When you test at the command line, are you doing this as the nagios user?

Code: Select all

su nagios
./check_esxi_hardware.py -H host -U user -P password -v

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 1:53 pm
by rawwrr
Box293 wrote:
rawwrr wrote:Hi,

Thanks for the help - I tried with the suggested command but I still have the same issue, there's no output in Nagios;

COMMAND: /usr/local/nagios/libexec/check_esxi_hardware.py -H 0.0.0.0 -U user -P password
OUTPUT:

I'm still looking into the "python issue".
Thanks
When you use the "Test Command" button it runs as the user apache, which is different to the nagios user that the monitoring engine runs as. There are some problems with the "Test Command" button so instead, save, apply config, find the service in the XI GUI (not CCM) and Schedule an immediate check. Does this work?

When you test at the command line, are you doing this as the nagios user?

Code: Select all

su nagios
./check_esxi_hardware.py -H host -U user -P password -v
1- It does not work
2- I was testing as root but it doesn't work either with the nagios user.

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 2:18 pm
by Box293
rawwrr wrote:2- I was testing as root but it doesn't work either with the nagios user.
This is the source of your problem. Something to do with the python environment or standard operating environment when the check executes is not present.

Do you have a heavily locked down system?

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 2:22 pm
by rawwrr
No particularly - I believe the base install was done using the Nagios VMware template but it precedes my arrival here. I don't think any specific restriction were enforced on the system.

Re: Using python plugin in Nagios XI

Posted: Mon Sep 28, 2015 2:30 pm
by Box293
But it works OK as root ?