API for certain name should not work

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mejokj
Posts: 353
Joined: Mon Jul 22, 2013 10:31 pm

API for certain name should not work

Post by mejokj »

Hello,

I am trying the service with the below name, but it is not working.

ABSA BANK-DEVKI ATHI RIVER ATM- BV000191-2MB

When I search this name in the nagiosxi search bar also it is not showing. Kindly help to resolve these issue

[root@nagiosphy2 24hour]# curl -XGET "http://10.22.20.161/nagiosxi/api/v1/obj ... ption=Ping" > /tmp/device
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 43 0 43 0 0 125 0 --:--:-- --:--:-- --:--:-- 126
[root@nagiosphy2 24hour]#
[root@nagiosphy2 24hour]#
[root@nagiosphy2 24hour]# cat /tmp/device
{
"error": "No valid data returned."
}
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: API for certain name should not work

Post by lmiltchev »

What is the version of Nagios XI that you are currently using? Do you see any errors database errors in the logs? Do you see this host and its service in the CCM? It is possible that you never applied configuration after adding the host and/or the service. If configuration applied successfully, you should be able to see the host and the service in the GUI (and search for it).

I haven't been able to recreate the issue in Nagios XI 5.8.5.

The search worked fine for me.
example-01.jpg
The REST API command worked as well:

Code: Select all

[root@main-nagios-xi ~]# curl -XGET "http://192.168.x.x/nagiosxi/api/v1/objects/rrdexport?apikey=xxx&pretty=1&host_name=ABSA%20BANK-DEVKI%20ATHI%20RIVER%20ATM-%20BV000191-2MB&service_description=Ping" > /tmp/device
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 46052    0 46052    0     0   325k      0 --:--:-- --:--:-- --:--:--  328k

Code: Select all

[root@main-nagios-xi ~]# head -50 /tmp/device
{
    "meta": {
        "start": "1628626800",
        "step": "300",
        "end": "1628626800",
        "rows": "289",
        "columns": "2",
        "legend": {
            "entry": [
                "rta",
                "pl"
            ]
        }
    },
    "data": {
        "row": [
            {
                "t": "1628626800",
                "v": [
                    "NaN",
                    "NaN"
                ]
            },
            {
                "t": "1628627100",
                "v": [
                    "NaN",
                    "NaN"
                ]
            },
            {
                "t": "1628627400",
                "v": [
                    "NaN",
                    "NaN"
                ]
            },
            {
                "t": "1628627700",
                "v": [
                    "NaN",
                    "NaN"
                ]
            },
            {
                "t": "1628628000",
                "v": [
                    "NaN",
                    "NaN"
                ]
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
mejokj
Posts: 353
Joined: Mon Jul 22, 2013 10:31 pm

Re: API for certain name should not work

Post by mejokj »

Hi Team,

We are using nagios version 5.7.5. Not getting any output with curl command. see below the error.

But we can able to see the host in CCM and home dashboard

[root@nagiosphy2 ~]# curl -XGET "http://10.x.x.x/nagiosxi/api/v1/objects ... ption=Ping"
{
"error": "No valid data returned."
}
[root@nagiosphy2 ~]#
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: API for certain name should not work

Post by benjaminsmith »

Hi,

I tried this on both 5.7.5 and using the latest version and I'm able to get it to work so it's not a bug in the API. However the first time, I got the same error as I had an error in the hostname. Please double-check the syntax, and run it again or temporarily change the hostname to a short string for testing purposes.
api-rrd-download.png

Code: Select all

curl -XGET "http://192.168.164.133/nagiosxi/api/v1/objects/rrdexport?apikey=PAJkqQr2sTiBvq5hOGuOgqeQYeMdeOXjEWGk3omOhXl6HqmMmTAWEN3S2OlfSCBM&pretty=1&host_name=ABSA%20BANK-DEVKI%20ATHI%20RIVER%20ATM-%20BV000191-2MB&service_description=Ping"
Let us know if you get it working.

--Benjamin
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
mejokj
Posts: 353
Joined: Mon Jul 22, 2013 10:31 pm

Re: API for certain name should not work

Post by mejokj »

Hi Benjamin,

Please close the thread. API works well now.

Thanks for your support
Locked