Page 1 of 1

NagiosXI and Python script

Posted: Tue Oct 28, 2014 2:07 pm
by wally
Hello!

I’m very new to Nagios and I spent the day studying how to best implement my Python plugin. I was able to run a NagioxIX virtual machine using VirtualBox, and now I am trying to understand how to build my plugin.

REQUIREMENTS:

I need to integrate into Nagios some alerts coming from my own monitoring tool. I have a Python library that queries my own monitoring tool (REST based via HTTPS), so I need to have this information displayed into Nagios.

I understood that Nagios is basically a monitoring server, so in order to have info pushed into its dashboard, I need to set up a Linux client where to run the Python script. I found this NRPE add ons that looks like what I need, since the NRPE is also able to to http_check (so would be ok with my REST based query to my monitoring tool):
Pasted_Image_10_28_14__19_56.png
So using the example in the following link, I managed to have the data from my own tool, queried via Python script, displayed into Nagios dashboard:

https://www.digitalocean.com/community/ ... untu-12-10

Alternatively, I can run the Python script directly on the Nagios server as explained here:

http://skipperkongen.dk/2011/12/06/hell ... in-python/

-----------------------------
QUESTION: What are the pros/cons of each of the two solutions?
-----------------------------

Thanks!

Wally

Re: NagiosXI and Python script

Posted: Tue Oct 28, 2014 4:49 pm
by abrist
Nagios XI can also run checks locally (I think you mentioned this). So you could make a check_http service that runs on the XI box against your remote hosts. The "NRPE proxy" method that you are suggesting is usually only used when you to get around endpoint issues like a firewall or restricted subnet. Unless you need to proxy the check, I suggest running it locally as it is much simpler and does not require editing configs on a remote box when you want to change the check.

Re: NagiosXI and Python script

Posted: Tue Oct 28, 2014 4:59 pm
by wally
Hi Abrist,

thanks for your reply! So if I want to run my Python script locally on the Nagios Server, is this the correct and only procedure (see link)?

http://skipperkongen.dk/2011/12/06/hell ... in-python/

What is worrying me is the fact that critical NagiosXI config files:

define command{..} >>>> /usr/local/nagios/etc/commands.cfg
define service {..} >>> /usr/local/nagios/etc/services/localhost.cfg

need to be modified to run the Python script automatically in Nagios. So I need either have to modify these two config files manually (prone to errors) or automatically using my script (danger of bugs). Is there a way to avoid touching those two files?

Thanks!

Re: NagiosXI and Python script

Posted: Tue Oct 28, 2014 5:08 pm
by abrist
wally wrote: need to be modified to run the Python script automatically in Nagios. So I need either have to modify these two config files manually (prone to errors) or automatically using my script (danger of bugs). Is there a way to avoid touching those two files?
Yes, through the CCM in nagios XI. Go to --> Configure --> CCM --> Commands. Create a new command for your check here.
Then go to --> CCM --> Services. Add a new service check for your command here and add the remote host to the check.

Re: NagiosXI and Python script

Posted: Tue Nov 11, 2014 7:57 am
by wally
Thanks Abrist, much appreciated!

Re: NagiosXI and Python script

Posted: Tue Nov 11, 2014 10:35 am
by tmcdonald
Did that resolve the issue? If so I would like to close the thread.

Re: NagiosXI and Python script

Posted: Tue Nov 11, 2014 10:40 am
by wally
yes it did, please close. Thanks again.