Page 1 of 1
API exec error
Posted: Thu Apr 23, 2020 9:10 pm
by rajasegar
Can you please advice how to troubleshoot this issue?
The following is not working on the new server we setup 5.6.12 running on RHEL7.6.
API key is correct for the user in this server and it works fine on all the other servers.
Code: Select all
curl "http://10.10.1.10/nagiosxi/backend/?cmd=getstatehistory&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=both&mode=csv&username=test&ticket=oqhpGMNfQbG7FU77lLTKiDOEBk7jXX9Gnp5kr8ChieoepOENPtN7mR2dc8P95YOM"
<?xml version="1.0" encoding="utf-8"?>
<error>
<errormessage>Authentication Failure</errormessage>
</error>
Thanks
Re: API exec error
Posted: Thu Apr 23, 2020 9:27 pm
by rajasegar
FYI, this works
curl -XGET "
http://10.10.1.10/nagiosxi/api/v1/objec ... putype=xml"
{"recordcount":"18","stateentry":[{"instance_id":"1","state_time":"2020-04-24 08:09:52","object_id":"967","objecttype_id":"2","host_name":"MYWCBPIFRSDBS01","service_description":"MSSQL: Connection Time IFRS9-MY","state_change":"1","state":"0","state_type":"1","current_check_attempt":"2","max_check_attempts":"2","last_state":"1","last_hard_state":"0","output":"OK - 0.03 seconds to connect as nagios"},{"instance_id":"1","state_time":"2020-04-24 08:05:03","object_id":"967","objecttype_id":"2","host_name":"MYWCBPIFRSDBS01","service_description":"MSSQL: Connection Time IFRS9-MY","state_change":"1","state":"1","state_type":"0","current_check_attempt":"1","max_check_attempts":"2","last_state":"0","last_hard_state":"0","output":"WARNING - 3.04 seconds to connect as nagios"},{"instance_id":"1","state_time":"2020-04-24 05:44:08","object_id":"968","objecttype_id":"2","host_name":"MYWCBPIFRSDBS01","service
....
It is not coming out as XML though. We still need the backend version output as all the import routines is based on that.
Re: API exec error
Posted: Fri Apr 24, 2020 9:07 am
by ssax
In order to use the depracated backend API, you need to go to Admin > System Settings > Backwards Compatibility tab and turn on "Allow Insecure Logins" and click the Update Settings button.
Then you will need to login (or masquerade as the user you want to allow it from) and click their username in the top right corner, then select "Enable Insecure Login" and click the Update Settings button.
That should do it.
Re: API exec error
Posted: Sun Apr 26, 2020 9:53 pm
by rajasegar
ssax wrote:In order to use the depracated backend API, you need to go to Admin > System Settings > Backwards Compatibility tab and turn on "Allow Insecure Logins" and click the Update Settings button.
Then you will need to login (or masquerade as the user you want to allow it from) and click their username in the top right corner, then select "Enable Insecure Login" and click the Update Settings button.
That should do it.
Capture1.JPG
Now Backend API works from browser but not from command line. Both API key and Insecure ticket works using the backend api from web browser. However when using curl I still getting the same error. Running on the same server ssh session also same issue.
The new API command below works fine from command line though.
Code: Select all
curl "http://10.104.18.193/nagiosxi/api/v1/objects/hoststatus?apikey=oqhpGMNfQbG7FU77lLTKiDOEBk7jXX9Gnp5kr8ChieoepOENPtN7mR2dc8P95YOM&pretty=1"
Please advice where else to check on this.
Code: Select all
[nagios@nagiosprodxi1 scripts]$ curl -v "http://10.104.18.193/nagiosxi/backend/?cmd=getstatehistory&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=both&mode=csv&username=rajasegar&ticket=oqhpGMNfQbG7FU77lLTKiDOEBk7jXX9Gnp5kr8ChieoepOENPtN7mR2dc8P95YOM"
* About to connect() to 10.104.18.193 port 80 (#0)
* Trying 10.104.18.193... connected
* Connected to 10.104.18.193 (10.104.18.193) port 80 (#0)
> GET /nagiosxi/backend/?cmd=getstatehistory&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=both&mode=csv&username=rajasegar&ticket=oqhpGMNfQbG7FU77lLTKiDOEBk7jXX9Gnp5kr8ChieoepOENPtN7mR2dc8P95YOM HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.3.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 10.104.18.193
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 27 Apr 2020 02:33:51 GMT
< Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips PHP/5.4.16
< X-Powered-By: PHP/5.4.16
< Set-Cookie: nagiosxi=7c8lqnio9bjvh5engh2t2c6tf3; expires=Mon, 27-Apr-2020 03:03:51 GMT; path=/; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< X-Frame-Options: SAMEORIGIN
< Content-Security-Policy: frame-ancestors 'self'
< Access-Control-Allow-Origin: *
< Content-Length: 108
< Content-Type: text/xml
<
<?xml version="1.0" encoding="utf-8"?>
<error>
<errormessage>Authentication Failure</errormessage>
</error>
* Connection #0 to host 10.104.18.193 left intact
* Closing connection #0
Code: Select all
[nagios@nagiosprodxi1 scripts]$ curl -v "http://10.104.18.193/nagiosxi/backend/?cmd=getstatehistory&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=both&mode=csv&username=rajasegar&ticket=Z50PJXaeufi0HockAVtkKnptYG65sX7ri7A0kJv9YQpVuEf4PLnAoPjGrILXF8IX"
* About to connect() to 10.104.18.193 port 80 (#0)
* Trying 10.104.18.193... connected
* Connected to 10.104.18.193 (10.104.18.193) port 80 (#0)
> GET /nagiosxi/backend/?cmd=getstatehistory&search=&reportperiod=last24hours&startdate=&enddate=&hostgroup=&servicegroup=&statetype=both&mode=csv&username=rajasegar&ticket=Z50PJXaeufi0HockAVtkKnptYG65sX7ri7A0kJv9YQpVuEf4PLnAoPjGrILXF8IX HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.3.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 10.104.18.193
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 27 Apr 2020 02:36:05 GMT
< Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips PHP/5.4.16
< X-Powered-By: PHP/5.4.16
< Set-Cookie: nagiosxi=s3okqa0rjv90516nep55fkq1g7; expires=Mon, 27-Apr-2020 03:06:06 GMT; path=/; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< X-Frame-Options: SAMEORIGIN
< Content-Security-Policy: frame-ancestors 'self'
< Access-Control-Allow-Origin: *
< Content-Length: 108
< Content-Type: text/xml
<
<?xml version="1.0" encoding="utf-8"?>
<error>
<errormessage>Authentication Failure</errormessage>
</error>
* Connection #0 to host 10.104.18.193 left intact
* Closing connection #0
Re: API exec error
Posted: Mon Apr 27, 2020 2:46 pm
by ssax
This is a bug, I'm able to replicate it on my system. Reporting this to development now.
Code: Select all
NEW TASK created - Nagios XI Bug Report: XI - Insecure Login Ticket functionality broken
Re: API exec error
Posted: Mon Apr 27, 2020 3:28 pm
by ssax
You should be able to get XML from the API like this: (you missed a
t in
outputtype)
Code: Select all
curl -XGET "http://10.10.1.10/nagiosxi/api/v1/objects/statehistory?apikey=oqhpGMNfQbG7FU77lLTKiDOEBk7jXX9Gnp5kr8ChieoepOENPtN7mR2dc8P95YOM&outputtype=xml"
Re: API exec error
Posted: Mon Apr 27, 2020 8:56 pm
by rajasegar
ssax wrote:You should be able to get XML from the API like this: (you missed a
t in
outputtype)
Code: Select all
curl -XGET "http://10.10.1.10/nagiosxi/api/v1/objects/statehistory?apikey=oqhpGMNfQbG7FU77lLTKiDOEBk7jXX9Gnp5kr8ChieoepOENPtN7mR2dc8P95YOM&outputtype=xml"
Thanks. This works fine. You can close the thread.