nagiosql api
nagiosql api
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?
Re: nagiosql api
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.
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.
Nagios Jedi in training.
Re: nagiosql api
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
http://assets.nagios.com/downloads/nagi ... nd_API.pdf
Former Nagios employee
Re: nagiosql api
Hello technik, Can you please elaborate on first solution?
Re: nagiosql api
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
Re: nagiosql api
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?
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: nagiosql api
They won't appear in Core Configuration Manager but they will appear in the normal user interface.anil406 wrote:however changes does not appear in XI, correct?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: nagiosql api
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?
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: nagiosql api
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:
Then in CCM:
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- 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.
Re: nagiosql api
I tried to import, but when I click on import link it says cannot connect to database. But nagios is running fine.