Page 1 of 1

API for certain name should not work

Posted: Wed Aug 11, 2021 7:20 am
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."
}

Re: API for certain name should not work

Posted: Wed Aug 11, 2021 3:18 pm
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"
                ]

Re: API for certain name should not work

Posted: Fri Aug 13, 2021 3:21 am
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 ~]#

Re: API for certain name should not work

Posted: Fri Aug 13, 2021 3:30 pm
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

Re: API for certain name should not work

Posted: Wed Aug 18, 2021 1:24 am
by mejokj
Hi Benjamin,

Please close the thread. API works well now.

Thanks for your support