Page 1 of 1

Nagios CLI

Posted: Mon Dec 05, 2011 6:12 am
by oz123
Hi,

Is there a way to "Apply Configuration" from command ?
I'm using Linux.
I can verify but how do i Apply ?

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Thanks

Re: Nagios CLI

Posted: Mon Dec 05, 2011 10:29 am
by mguthrie
The /usr/local/nagiosxi/scripts/reconfigure_nagios.sh is the actual script that gets run under the hood when you Apply Configuration. : )

Re: Nagios CLI

Posted: Tue Dec 06, 2011 3:47 am
by oz123
Great !! Thanks
Another question, before the "Apply Configuration" I'm using the "Import Config Files" to import all services under /etc/services.
Can i do it from CLI also ?

Thanks

Re: Nagios CLI

Posted: Tue Dec 06, 2011 10:56 am
by mguthrie
If you're importing configs, I would strongly recommend reading the below docs and using the procedure outlined in them. There is a config prep process that should be run before importing.

http://assets.nagios.com/downloads/nagi ... ngfromcore

Re: Nagios CLI

Posted: Tue Dec 06, 2011 4:07 pm
by oz123
Hi,

I'm familiar with the import steps.
I need it in CLI as I need Nagios to be able to to change between two states automatically using a script.
I have 2 folders containing a defferent services.cfg files which I made in advance and i need to be able to control which is active, means 1 of the 2 folders content should be copied into /usr/local/nagios/etc/services

Steps in script:
1) deleting all current /usr/local/nagios/etc/services content
2) copy the desired content from 1 of the 2 folders I made in advance into /usr/local/nagios/etc/services
3) truncating from nagiosql database the tbl_service table.

then I need to do 2 more steps in that script:
4) import all /etc/services content to database - I don't know how it can be done from CLI so I'm doing it meanwhile from GUI
5) Apply configuration (which I know now how to do it as you helped me) -
/usr/local/nagiosxi/scripts/reconfigure_nagios.sh

so I need your help only with section number 4

Hope this is clear

Thanks

Re: Nagios CLI

Posted: Wed Dec 07, 2011 9:27 am
by oz123
Found it,

I just copied the new folder content to "/usr/local/nagios/etc/import" and ran the "/usr/local/nagiosxi/scripts/reconfigure_nagios.sh"

Thanks anyway

Re: Nagios CLI

Posted: Wed Dec 07, 2011 11:11 am
by mguthrie
Yeah, that was going to be my suggestion. Just a note though, the import directory is meant for *new* configs, I wouldn't recommend it for regular configuration changes.