Installation and REST API Issues

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
comfone
Posts: 127
Joined: Fri May 01, 2015 3:28 am

Installation and REST API Issues

Post by comfone »

Installation Method Offline installer on Centos 7
Installation log shows following error.

-----
Running pre-flight check on configuration data...

Checking objects...
Error: There are no services defined!
Checked 0 services.
Error: There are no hosts defined!
Checked 0 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 0 contact groups.
Checked 124 commands.
Checked 3 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 0 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 3 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 2

***> One or more problems was encountered while running the pre-flight check...

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
RET: 1
/usr/local/nagiosxi/nom/checkpoints/nagioscore/errors /tmp/nagiosxi/nagiosxi/basedir/scripts
tar: Removing leading `/' from member names
/tmp/nagiosxi/nagiosxi/basedir/scripts
ls: cannot access /usr/local/nagiosxi/nom/checkpoints/nagioscore/*.gz: No such file or directory
NO NOM SNAPSHOT FOUND!
------

Default Services Hosts and many templates are not configured. I'm able to fix this with script restore_defaults.sh.

There seems to be another Issue with REST API However. Following test request:

curl -XPOST "https://cnaxi1097/nagiosxi/api/v1/confi ... 0&pretty=1" -d "host_name=testapihost&address=127.0.0.1&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1" -k

returns

{
"success": "Successfully added testapihost to the system. Config applied, Nagios Core was restarted."
}

Unfortunately the Host testapihost newer appears in NagiosXI even after applying config. I'm able to manually add and remove hosts however over the Web Frontend.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Installation and REST API Issues

Post by cdienger »

It's complaining that there are no hosts and services for some reason. Do you have anything in /usr/local/nagios/etc/hosts or /usr/local/nagios/etc/services ? /usr/local/nagios/etc/nagios.cfg should also contain:

cfg_dir=/usr/local/nagios/etc/hosts
cfg_dir=/usr/local/nagios/etc/services
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
comfone
Posts: 127
Joined: Fri May 01, 2015 3:28 am

Re: Installation and REST API Issues

Post by comfone »

No, as stated above, there were no hosts and services available. I was however able to fix this with the script restore_defaults.sh. Doesn't fix my REST API Issues though.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Installation and REST API Issues

Post by cdienger »

There may be permissions issues with the directory. Run:

/usr/local/nagiosxi/scripts/reset_config_perms.sh

Is selinux enabled:

sestatus

/etc/sudoers should also have a section like:

User_Alias NAGIOSXI=nagios
User_Alias NAGIOSXIWEB=apache
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios status
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios checkconfig
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db status
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd status
NAGIOSXI ALL = NOPASSWD:/usr/bin/php /usr/local/nagiosxi/html/includes/components/autodiscovery/scripts/autodiscover_new.php *
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/html/includes/components/profile/getprofile.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/upgrade_to_latest.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/change_timezone.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/reset_config_perms.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/backup_xi.sh *
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/messages
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/httpd/error_log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/mysqld.log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/php /usr/local/nagiosxi/html/includes/components/autodiscovery/scripts/autodiscover_new.php *
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/html/includes/components/profile/getprofile.sh
NAGIOSXIWEB ALL = NOPASSWD:/etc/init.d/snmptt restart
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/repair_databases.sh
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
comfone
Posts: 127
Joined: Fri May 01, 2015 3:28 am

Re: Installation and REST API Issues

Post by comfone »

Tried your suggestions. Unfortunately following REST API request still doesn't work. Everything looks OK but Host testatpihost is not created.

Input:

curl -XPOST "https://cnaxi1097/nagiosxi/api/v1/confi ... 0&pretty=1" -d "host_name=testapihost&address=127.0.0.1&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1" -k

Output:

returns

{
"success": "Successfully added testapihost to the system. Config applied, Nagios Core was restarted."
}
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: Installation and REST API Issues

Post by tacolover101 »

comfone wrote:Tried your suggestions. Unfortunately following REST API request still doesn't work. Everything looks OK but Host testatpihost is not created.

Input:

curl -XPOST "https://cnaxi1097/nagiosxi/api/v1/confi ... 0&pretty=1" -d "host_name=testapihost&address=127.0.0.1&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1" -k

Output:

returns

{
"success": "Successfully added testapihost to the system. Config applied, Nagios Core was restarted."
}
the API will mention success, but it will not apply if there are config errors with Core. can you successfully apply configuration?

can you try doing a delete -> write -> verify from the CCM? this will allow you to re-write out configs from a DB which may be locked out.

Another interesting file to look at is /usr/local/nagios/var/cmdsubsys* (path may be incorrect) as this may point to more of a direction on where the problem is.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Installation and REST API Issues

Post by cdienger »

The Delete/Write/Verify that @tacolover101 mentions can be found under Configure > Tools > Config File Management.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
comfone
Posts: 127
Joined: Fri May 01, 2015 3:28 am

Re: Installation and REST API Issues

Post by comfone »

Found the reason for the Problems. Someway MariaDB-10 sneaked into our default repositorv. If we use the default MariaDB-Version of CentOS 7 everything works fine.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Installation and REST API Issues

Post by cdienger »

Thanks for the update!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked