Auto Register host.cfg ore service cfg to Nagios XI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sholdings
Posts: 21
Joined: Mon Jun 14, 2010 10:44 am

Auto Register host.cfg ore service cfg to Nagios XI

Post by sholdings »

HI,

We want to implement a mechanism to register host.cfg to Nagios XI automatically without human interference as soon as server been built. This mechanism will be triggered after new server has been built, all the necessary plugins and nrpe are installed and config properly. Basically, the procedure we want to do is something like followings,

1) Receiving server info from server team
2) Verify if ip, host name,... valid
3) Verify if NRPE is up and running
4) parsing info from server team and create hostname.cfg
5) update Nagios XI database

However, we encounter difficulty in step 5). We found there are many tables have been updated after I manually add 1 new hosts thru Core Config Manager.

After introduce my situation, here are the questions.
a) How can accomplish 5) by using the existing php script from Nagios XI?
or b) How can mimic the "Import Config File" function from "Core Config Manager" in command mode?
or c) How many tables in database NagiosQL and NDOUtils need to be updated? and who are they?
Nagiosql: tbl_host tbl_lnkHostToContact tbl_lnkHostToHosttemplate tbl_lnkHostToVariabledefinition
tbl_logbook
NDOUtils: 14+ tables has been updated

Thanks
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Auto Register host.cfg ore service cfg to Nagios XI

Post by mmestnik »

The file name MUST reflect the host name, using the same file name would have unforeseen results. If you have experience in this area it would be good of you to share.

The file name is used in place of the host name in the services table in the CCM. This is because services belonging to multiple hosts only exist once and such. Thus the file name used is presented along with the service name for means of identification. In cases where there are many services, say "PING", defined multiple times(I.E once for each host) but all in the same file it becomes difficult to tell them apart.

There is an import script that corrects this, splitting the services into multiple files.
User avatar
admin
Site Admin
Posts: 256
Joined: Mon Oct 12, 2009 8:21 am

Re: Auto Register host.cfg ore service cfg to Nagios XI

Post by admin »

To simulate the "Apply Configuration" button with an automated script, follow these steps:

1. Create a file named hostname.cfg in /usr/local/nagios/etc/import, where hostname is the name of the host. The file should contain the Nagios Core definitions for both the host and the host's services

2. Run the following script:

Code: Select all

/usr/local/nagiosxi/scripts/reconfigure_nagios.sh
That will update the CCM, Nagios Core, and NDOUtils. Good luck!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Ethan Galstad
President
sholdings
Posts: 21
Joined: Mon Jun 14, 2010 10:44 am

Re: Auto Register host.cfg ore service cfg to Nagios XI

Post by sholdings »

Hi,

We have followed the instruction to simulate the "Apply Configuration" button. However, we experienced some Permission denied issue when running reconfigure_nagios.sh under shell.

Here is the error message output from reconfigure_nagios.sh. Authentication failed seems not just from nagiosql. Does this script have to run under certain account?
  • nagiosql.login: Permission denied
    nagiosql.import.monitoring: Permission denied
    nagiosql.export.monitoring: Permission denied
    Stopping nagios: /etc/init.d/nagios: line 67: kill: (21335) - No such process
    done.
    rm: cannot remove `/usr/local/nagiosxi/var/subsys/nagios': Permission denied
    rm: cannot remove `/usr/local/nagios/var/rw/nagios.cmd': Permission denied
    Starting nagios:touch: cannot touch `/usr/local/nagios/var/nagios.log': Permission denied
    touch: cannot touch `/usr/local/nagios/var/retention.dat': Permission denied
    chown: changing ownership of `/usr/local/nagios/var/nagios.log': Operation not permitted
    chown: changing ownership of `/usr/local/nagios/var/retention.dat': Operation not permitted
    rm: cannot remove `/usr/local/nagios/var/rw/nagios.cmd': Permission denied
    chown: changing ownership of `/usr/local/nagios/var/nagios.lock': Operation not permitted
    touch: cannot touch `/usr/local/nagiosxi/var/subsys/nagios': Permission denied
    chown: changing ownership of `/usr/local/nagiosxi/var/subsys/nagios': Operation not permitted
    done.
    /usr/local/nagiosxi/scripts> /usr/local/nagiosxi/nom/checkpoints/nagioscore /usr/local/nagiosxi/scripts
    ./nom_create_nagioscore_checkpoint.sh: line 17: 1281451711.txt: Permission denied
    tar: 1281451711.tar.gz: Cannot open: Permission denied
    tar: Error is not recoverable: exiting now
    tar: Removing leading `/' from member names
    chown: cannot access `1281451711.txt': No such file or directory
    chown: cannot access `1281451711.tar.gz': No such file or directory
Thanks
Locked