nagiosql api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
anil406
Posts: 43
Joined: Tue Apr 01, 2014 3:53 pm

nagiosql api

Post by anil406 »

Hello, Do we have any api that interacts with nagiosql. I am planning to write a bootstrap script that talks to nagios via api and adds the host during bootstrap process for the new machines. Any Ideas?
technick
Posts: 49
Joined: Tue Feb 04, 2014 10:30 am
Location: Denver, CO

Re: nagiosql api

Post by technick »

I know of three solutions to this and none of them involve a fancy API and I can only recommend one of them.

Have your bootstrap process create and manage static files in the /usr/local/nagios/etc/static directory. My organization is currently doing this with Ansible on provisioning / de-provisioning of AWS resources and its working out great.

The alternative to this is writing your config files into the /usr/local/nagios/etc/import file and there is a script that will import anything found there into the database. I have not tested this but have seen it recommended on these boards before.

The other more sketchy unrecommended method is writing something that will do the SQL inserts into the MySQL database and manage the row linking but that might cause more headache than its worth.
----------------------
Nagios Jedi in training.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: nagiosql api

Post by tmcdonald »

We have an API, but at the moment it only deals with querying and not editing:

http://assets.nagios.com/downloads/nagi ... nd_API.pdf
Former Nagios employee
anil406
Posts: 43
Joined: Tue Apr 01, 2014 3:53 pm

Re: nagiosql api

Post by anil406 »

Hello technik, Can you please elaborate on first solution?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: nagiosql api

Post by tmcdonald »

The static directory is used to store config files that Nagios should use but you do not want to appear in the CCM in XI. This makes it easy to script out changes to those files that will not be overwritten on an Apply Config. You still need to restart Nagios in order for the changes to be picked up, however (Apply Config does this as part of its routine).
Former Nagios employee
anil406
Posts: 43
Joined: Tue Apr 01, 2014 3:53 pm

Re: nagiosql api

Post by anil406 »

thanks donald, so what I understood from you post is that we need to restart the nagios to get static changes updated, however changes does not appear in XI, correct? if so any alternative method to get it updated in XI?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: nagiosql api

Post by Box293 »

anil406 wrote:however changes does not appear in XI, correct?
They won't appear in Core Configuration Manager but they will appear in the normal user interface.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
anil406
Posts: 43
Joined: Tue Apr 01, 2014 3:53 pm

Re: nagiosql api

Post by anil406 »

I built custom host and services file for test host and copied to hosts and services directories respectively and restarted the nagios, it works fine. however whenever we make changes to any other things using CCM, this is removing manually copied hosts/services cfgs. Is there a way to import these to CCM aswell?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: nagiosql api

Post by Box293 »

It is normal behaviour for Nagios XI to remove manually added config files when CCM applies it's settings.

If you want to import into Nagios XI, copy the custom host and service files you've created into:

Code: Select all

/usr/local/nagios/etc/import
Then in CCM:
  • Tools > Import Config Files
    Select your custom files in the list
    Click Import
    It should then tell you if it succeeded
    Now Apply Configuration
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
anil406
Posts: 43
Joined: Tue Apr 01, 2014 3:53 pm

Re: nagiosql api

Post by anil406 »

I tried to import, but when I click on import link it says cannot connect to database. But nagios is running fine.
Locked