APIs not returning Data

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
amarosimpi
Posts: 6
Joined: Wed Jan 22, 2020 6:19 pm

APIs not returning Data

Post by amarosimpi »

Trying to get NagiosTV to work with latest XI; seems like 5.7.3 broke something with the APIs and they aren't returning data via these URLs:
http://1.1.1.1/nagios/cgi-bin/statusjso ... tails=true
http://1.1.1.1/nagios/cgi-bin/statusjso ... tails=true

Replace 1.1.1.1 with Nagios XI server IP/Name

Any insight support can provide?
Thanks!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: APIs not returning Data

Post by ssax »

I just labbed this up and it's working fine with XI 5.7.3.

Please PM me a copy of your profile, you can download it from Admin > System Profile by clicking the Download Profile button.

What version of PHP are you running?

Code: Select all

php -v
Additionally, please send the output of these commands:
- NOTE: You may need to adjust the -h 127.0.0.1, the -uroot, and -pnagiosxi in the first command if your DB is offloaded to another server and/or you've changed the root mysql password

Code: Select all

echo "SELECT table_name AS 'Table', round(((data_length + index_length) / 1024 / 1024), 2) 'Size in MB' FROM information_schema.TABLES WHERE table_schema IN ('nagios', 'nagiosql', 'nagiosxi');" | mysql -h 127.0.0.1 -uroot -pnagiosxi --table
This next command may fail, that's okay, not all systems run postgresql, send the output anyways:

Code: Select all

echo "SELECT relname as Table, pg_size_pretty(pg_total_relation_size(relid)) As Size, pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as ExternalSize FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;" | psql nagiosxi nagiosxi
amarosimpi
Posts: 6
Joined: Wed Jan 22, 2020 6:19 pm

Re: APIs not returning Data

Post by amarosimpi »

Working on the profile download; need to sanitize it.

Code: Select all

[root@nagios ~]# php -v
PHP 5.4.16 (cli) (built: Nov  1 2019 16:04:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Code: Select all

+--------------------------------------------+------------+
| Table                                      | Size in MB |
+--------------------------------------------+------------+
| nagios_acknowledgements                    |       0.02 |
| nagios_commands                            |       0.02 |
| nagios_commenthistory                      |       3.00 |
| nagios_comments                            |       0.00 |
| nagios_configfiles                         |       0.01 |
| nagios_configfilevariables                 |       0.01 |
| nagios_conninfo                            |       0.14 |
| nagios_contact_addresses                   |       0.00 |
| nagios_contact_notificationcommands        |       0.01 |
| nagios_contactgroup_members                |       0.00 |
| nagios_contactgroups                       |       0.00 |
| nagios_contactnotificationmethods          |       0.89 |
| nagios_contactnotifications                |       0.94 |
| nagios_contacts                            |       0.00 |
| nagios_contactstatus                       |       0.00 |
| nagios_customvariables                     |       0.17 |
| nagios_customvariablestatus                |       0.18 |
| nagios_dbversion                           |       0.00 |
| nagios_downtimehistory                     |       0.00 |
| nagios_eventhandlers                       |       0.01 |
| nagios_externalcommands                    |       0.00 |
| nagios_flappinghistory                     |       1.23 |
| nagios_host_contactgroups                  |       0.01 |
| nagios_host_contacts                       |       0.00 |
| nagios_host_parenthosts                    |       0.00 |
| nagios_hostchecks                          |       0.09 |
| nagios_hostdependencies                    |       0.00 |
| nagios_hostescalation_contactgroups        |       0.00 |
| nagios_hostescalation_contacts             |       0.00 |
| nagios_hostescalations                     |       0.00 |
| nagios_hostgroup_members                   |       0.01 |
| nagios_hostgroups                          |       0.00 |
| nagios_hosts                               |       0.04 |
| nagios_hoststatus                          |       0.11 |
| nagios_instances                           |       0.00 |
| nagios_logentries                          |     147.39 |
| nagios_notifications                       |      98.15 |
| nagios_objects                             |       0.71 |
| nagios_processevents                       |       0.41 |
| nagios_programstatus                       |       0.00 |
| nagios_runtimevariables                    |       0.00 |
| nagios_scheduleddowntime                   |       0.00 |
| nagios_service_contactgroups               |       0.09 |
| nagios_service_contacts                    |       0.01 |
| nagios_service_parentservices              |       0.00 |
| nagios_servicechecks                       |       1.22 |
| nagios_servicedependencies                 |       0.00 |
| nagios_serviceescalation_contactgroups     |       0.00 |
| nagios_serviceescalation_contacts          |       0.00 |
| nagios_serviceescalations                  |       0.00 |
| nagios_servicegroup_members                |       0.05 |
| nagios_servicegroups                       |       0.00 |
| nagios_services                            |       0.46 |
| nagios_servicestatus                       |       1.13 |
| nagios_statehistory                        |     103.86 |
| nagios_systemcommands                      |       0.04 |
| nagios_timedeventqueue                     |       0.00 |
| nagios_timedevents                         |       0.00 |
| nagios_timeperiod_timeranges               |       0.01 |
| nagios_timeperiods                         |       0.00 |
| tbl_command                                |       0.08 |
| tbl_contact                                |       0.03 |
| tbl_contactgroup                           |       0.03 |
| tbl_contacttemplate                        |       0.03 |
| tbl_domain                                 |       0.03 |
| tbl_host                                   |       0.08 |
| tbl_hostdependency                         |       0.03 |
| tbl_hostescalation                         |       0.03 |
| tbl_hostextinfo                            |       0.03 |
| tbl_hostgroup                              |       0.03 |
| tbl_hosttemplate                           |       0.03 |
| tbl_info                                   |       0.17 |
| tbl_lnkContactToCommandHost                |       0.02 |
| tbl_lnkContactToCommandService             |       0.02 |
| tbl_lnkContactToContactgroup               |       0.02 |
| tbl_lnkContactToContacttemplate            |       0.02 |
| tbl_lnkContactToVariabledefinition         |       0.02 |
| tbl_lnkContactgroupToContact               |       0.02 |
| tbl_lnkContactgroupToContactgroup          |       0.02 |
| tbl_lnkContacttemplateToCommandHost        |       0.02 |
| tbl_lnkContacttemplateToCommandService     |       0.02 |
| tbl_lnkContacttemplateToContactgroup       |       0.02 |
| tbl_lnkContacttemplateToContacttemplate    |       0.02 |
| tbl_lnkContacttemplateToVariabledefinition |       0.02 |
| tbl_lnkHostToContact                       |       0.02 |
| tbl_lnkHostToContactgroup                  |       0.02 |
| tbl_lnkHostToHost                          |       0.02 |
| tbl_lnkHostToHostgroup                     |       0.02 |
| tbl_lnkHostToHosttemplate                  |       0.02 |
| tbl_lnkHostToVariabledefinition            |       0.02 |
| tbl_lnkHostdependencyToHost_DH             |       0.02 |
| tbl_lnkHostdependencyToHost_H              |       0.02 |
| tbl_lnkHostdependencyToHostgroup_DH        |       0.02 |
| tbl_lnkHostdependencyToHostgroup_H         |       0.02 |
| tbl_lnkHostescalationToContact             |       0.02 |
| tbl_lnkHostescalationToContactgroup        |       0.02 |
| tbl_lnkHostescalationToHost                |       0.02 |
| tbl_lnkHostescalationToHostgroup           |       0.02 |
| tbl_lnkHostgroupToHost                     |       0.02 |
| tbl_lnkHostgroupToHostgroup                |       0.02 |
| tbl_lnkHosttemplateToContact               |       0.02 |
| tbl_lnkHosttemplateToContactgroup          |       0.02 |
| tbl_lnkHosttemplateToHost                  |       0.02 |
| tbl_lnkHosttemplateToHostgroup             |       0.02 |
| tbl_lnkHosttemplateToHosttemplate          |       0.02 |
| tbl_lnkHosttemplateToVariabledefinition    |       0.02 |
| tbl_lnkServiceToContact                    |       0.02 |
| tbl_lnkServiceToContactgroup               |       0.08 |
| tbl_lnkServiceToHost                       |       0.09 |
| tbl_lnkServiceToHostgroup                  |       0.02 |
| tbl_lnkServiceToServicegroup               |       0.05 |
| tbl_lnkServiceToServicetemplate            |       0.09 |
| tbl_lnkServiceToVariabledefinition         |       0.09 |
| tbl_lnkServicedependencyToHost_DH          |       0.02 |
| tbl_lnkServicedependencyToHost_H           |       0.02 |
| tbl_lnkServicedependencyToHostgroup_DH     |       0.02 |
| tbl_lnkServicedependencyToHostgroup_H      |       0.02 |
| tbl_lnkServicedependencyToService_DS       |       0.02 |
| tbl_lnkServicedependencyToService_S        |       0.02 |
| tbl_lnkServicedependencyToServicegroup_DS  |       0.02 |
| tbl_lnkServicedependencyToServicegroup_S   |       0.02 |
| tbl_lnkServiceescalationToContact          |       0.02 |
| tbl_lnkServiceescalationToContactgroup     |       0.02 |
| tbl_lnkServiceescalationToHost             |       0.02 |
| tbl_lnkServiceescalationToHostgroup        |       0.02 |
| tbl_lnkServiceescalationToService          |       0.02 |
| tbl_lnkServiceescalationToServicegroup     |       0.02 |
| tbl_lnkServicegroupToService               |       0.05 |
| tbl_lnkServicegroupToServicegroup          |       0.02 |
| tbl_lnkServicetemplateToContact            |       0.02 |
| tbl_lnkServicetemplateToContactgroup       |       0.02 |
| tbl_lnkServicetemplateToHost               |       0.02 |
| tbl_lnkServicetemplateToHostgroup          |       0.02 |
| tbl_lnkServicetemplateToServicegroup       |       0.02 |
| tbl_lnkServicetemplateToServicetemplate    |       0.02 |
| tbl_lnkServicetemplateToVariabledefinition |       0.02 |
| tbl_lnkTimeperiodToTimeperiod              |       0.02 |
| tbl_logbook                                |       0.02 |
| tbl_mainmenu                               |       0.02 |
| tbl_permission                             |       0.02 |
| tbl_permission_inactive                    |       0.02 |
| tbl_service                                |       0.47 |
| tbl_servicedependency                      |       0.03 |
| tbl_serviceescalation                      |       0.03 |
| tbl_serviceextinfo                         |       0.03 |
| tbl_servicegroup                           |       0.03 |
| tbl_servicetemplate                        |       0.03 |
| tbl_session                                |       0.02 |
| tbl_session_locks                          |       0.02 |
| tbl_settings                               |       0.03 |
| tbl_submenu                                |       0.02 |
| tbl_timedefinition                         |       0.02 |
| tbl_timeperiod                             |       0.03 |
| tbl_user                                   |       0.03 |
| tbl_variabledefinition                     |       0.14 |
| xi_auditlog                                |       2.34 |
| xi_auth_tokens                             |       0.03 |
| xi_cmp_ccm_backups                         |       0.02 |
| xi_cmp_favorites                           |       0.03 |
| xi_cmp_nagiosbpi_backups                   |       0.09 |
| xi_cmp_trapdata                            |       1.58 |
| xi_cmp_trapdata_log                        |       0.17 |
| xi_commands                                |       0.02 |
| xi_deploy_agents                           |       0.02 |
| xi_deploy_jobs                             |       0.02 |
| xi_eventqueue                              |       0.03 |
| xi_events                                  |       0.14 |
| xi_meta                                    |       2.52 |
| xi_mibs                                    |       0.05 |
| xi_options                                 |       0.06 |
| xi_sessions                                |       0.03 |
| xi_sysstat                                 |       0.03 |
| xi_usermeta                                |       1.59 |
| xi_users                                   |       0.03 |
+--------------------------------------------+------------+

Code: Select all

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
amarosimpi
Posts: 6
Joined: Wed Jan 22, 2020 6:19 pm

Re: APIs not returning Data

Post by amarosimpi »

Tried to PM you - looks like i need to be authorized:
We are sorry, but you are not authorised to use this feature. You may have just registered here and may need to participate more to be able to use this feature.
amarosimpi
Posts: 6
Joined: Wed Jan 22, 2020 6:19 pm

Re: APIs not returning Data

Post by amarosimpi »

Profile sent in PM
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: APIs not returning Data

Post by ssax »

I see this:

Code: Select all

[Fri Oct 23 15:21:19.472914 2020] [auth_basic:error] [pid 48411] [client X.X.X.X:57928] AH01617: user nagiosadmin: authentication failure for "/nagios/nagiostv": Password Mismatch
Try going to Admin > Manage Users, edit the nagiosadmin user and just click Save. Then try again.

Did you also try restarting apache?

Code: Select all

service httpd restart
Are you going to this?

Code: Select all

http://YOURXISERVER/nagios/nagiostv/
Or this?

Code: Select all

https://YOURXISERVER/nagios/nagiostv/
Try with and without https and see if either work.

What is the output of this command on the XI server?

Code: Select all

curl -k -L -v 'https://YOURXISERVER/nagios/nagiostv/'
amarosimpi
Posts: 6
Joined: Wed Jan 22, 2020 6:19 pm

Re: APIs not returning Data

Post by amarosimpi »

Just logged in with nagiosadmin and it works...wtf....

Odd thing is that it won't work with LDAP connected credentials. It's always used to work with LDAP creds...
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: APIs not returning Data

Post by ssax »

Technically, the backend nagios core web interface (what you are hitting when your URL has /nagios/ instead of /nagiosxi/) has no idea about AD/LDAP, by default it only references the /usr/local/nagiosxi/etc/htpasswd.users file which will ONLY be updated with your AD/LDAP password if you check the box when editing the user for Allow local login if auth server login fails and then login to XI.

Do your LDAP users have that setting checked on their account in Admin > Manage Users? If yes, did they login to XI first? If so, then it should've updated the /usr/local/nagiosxi/etc/htpasswd.users file on XI login so the next time they try to go to the backend core interface they should be able login with their LDAP credentials but it doesn't technically use LDAP for it, it will just validate the cached LDAP credentials from the htpasswd file.
Locked