Page 1 of 1

objects/cpexport: historical data

Posted: Wed Mar 20, 2019 2:17 pm
by anilgupta
Team,

I am interested to find Historical data of my services with "objects/cpexport".

For the PING service, the API is returning the expected data.

Code: Select all

curl -XGET "https://10.115.xxx.xxx/nagiosxi/api/v1/objects/cpexport?apikey=**************************&pretty=1&host_name=localhost&service_description=PING&track=rta"
However, when I try the same command for other service (for example: CPUStats), it throws error as below.

Code: Select all

curl -XGET "https://10.115.xxx.xxx/nagiosxi/api/v1/objects/cpexport?apikey=**************************&pretty=1&host_name=localhost&service_description=CPUStats&track=rta"
{
    "dmax": null,
    "dmean": null,
    "emax": null,
    "emean": null,
    "error": "Error reading file '\/usr\/local\/nagios\/share\/perfdata\/localhost\/CPUStats.xml': failed to load external entity \"\/usr\/local\/nagios\/share\/perfdata\/localhost\/CPUStats.xml\"",
    "integrity": 0,
    "data": {
        "historical": [

        ],
        "predicted": [

        ]
    },
    "name": "localhost_CPUStats_rta"
}
Seems it is looking for CPUStats.xml which is missing. Do we need to configure the service for cpexport?
Please suggest.

Re: objects/cpexport: historical data

Posted: Wed Mar 20, 2019 4:36 pm
by npolovenko
Hello, @anilgupta. This API command looks at the performance data so there should be RRD and XML files for this service in the /usr/local/nagios/share/perfdata/ folder. Does this particular service have a performance graph? Can you check to see whether there's an RRD file in the perfdata folder?

Re: objects/cpexport: historical data

Posted: Thu Mar 21, 2019 8:38 am
by anilgupta
Hello @npolovenko,

Thanks for your response.

I do see some issues here.

1) I do not see RRD and XML file corresponding to cpu_stats.

2) when I try to execute nrpe command for cpu_stats, it throws error as below

Code: Select all

[guptaa@pstvmpkimon02 nagios]$ /usr/local/nagios/libexec/check_nrpe -H localhost -t 30 -c check_cpu_stats -a '-w 70,40,30 -c 90,60,40'
CHECK_NRPE: Error - Could not connect to ::f053:b2da:fc7f:0: Connection reset by peer
Additionally, dashboard shows message as
"NRPE: Command 'check_cpu_stats' not defined".
Is it missing some configuration somewhere? please note the same command is working for other instances.

Re: objects/cpexport: historical data

Posted: Thu Mar 21, 2019 2:41 pm
by npolovenko
@anilgupta, So this check is not working properly. I'm guessing its in a critical(red) state and not collecting any perfdata at this moment.
The command you ran checks the localhost = XI server. You don't need nrpe to execute checks on a local server. Instead, you can run and use the following command:
/usr/local/nagios/libexec/check_cpu_stats.sh -w 70,40,30 -c 90,60,40
if it says no such file or directory make sure you download the check_cpu_stats.sh plugin and put it in the /usr/local/nagios/libexec/ folder first.
https://exchange.nagios.org/directory/P ... sh/details

Re: objects/cpexport: historical data

Posted: Fri Mar 22, 2019 11:40 am
by anilgupta
Thanks,

This is better. But, still not getting the records.
curl --noproxy xxx.xxx.xxx.xxx --insecure -XGET "https://xxx.xxx.xxx.xxx/nagiosxi/api/v1 ... &track=rta"
{
"dmax": null,
"dmean": null,
"emax": null,
"emean": null,
"error": "'NoneType' object has no attribute 'set_period'",
"integrity": 0,
"data": {
"historical": [

],
"predicted": [

]
},
"name": "localhost_CPUStats_rta"
}

Re: objects/cpexport: historical data

Posted: Fri Mar 22, 2019 1:44 pm
by ssax
It takes time to build the RRDs to get an average, if you run the command now does it still fail?

Code: Select all

curl -k -L -XGET "https://10.115.xxx.xxx/nagiosxi/api/v1/objects/cpexport?apikey=**************************&pretty=1&host_name=localhost&service_description=CPUStats&track=rta"
Please attach these files:

Code: Select all

/usr/local/nagios/share/perfdata/localhost/CPUStats.xml
/usr/local/nagios/share/perfdata/localhost/CPUStats.rrd
And post the full output of these commands (run it on your XI server as root/sudo):

Code: Select all

su - nagios
/usr/local/nagios/libexec/check_cpu_stats.sh -w 70,40,30 -c 90,60,40

Re: objects/cpexport: historical data

Posted: Fri Mar 22, 2019 2:54 pm
by anilgupta
Yes, still it it not fetching the expected result.
$ curl --noproxy xx.xxx.xxx.xxx --insecure -XGET "https://xxx.xxx.xxx.xxx/nagiosxi/api/v1 ... &track=rta"
{
"dmax": null,
"dmean": null,
"emax": null,
"emean": null,
"error": "'NoneType' object has no attribute 'set_period'",
"integrity": 0,
"data": {
"historical": [

],
"predicted": [

]
},
"name": "localhost_CPUStats_rta"
}
Uploaded the rrd and xml files.

Below is output for cpustats command
$ sudo /usr/local/nagios/libexec/check_cpu_stats.sh -w 70,40,30 -c 90,60,40
(standard_in) 1: syntax error
/usr/local/nagios/libexec/check_cpu_stats.sh: line 140: [: -eq: unary operator expected
(standard_in) 1: syntax error
/usr/local/nagios/libexec/check_cpu_stats.sh: line 143: [: -eq: unary operator expected
CPU STATISTICS OK: user=8.63% system=4.41% iowait=0.30% idle=86.66% | user=8.63% system=4.41% iowait=0.0%;70,40,30;90,60,40 idle=86.66%

Re: objects/cpexport: historical data

Posted: Fri Mar 22, 2019 3:47 pm
by ssax
Thank you, I'm able to replicate it on my system with your files, you're specifying the wrong track, use these ones instead:

Code: Select all

https://YOURXISERVER/nagiosxi/api/v1/objects/cpexport?apikey=XXXXXXXXXXXXXXX&pretty=1&host_name=localhost&service_description=CPUStats&track=system

https://YOURXISERVER/nagiosxi/api/v1/objects/cpexport?apikey=XXXXXXXXXXXXXXX&pretty=1&host_name=localhost&service_description=CPUStats&track=iowait

https://YOURXISERVER/nagiosxi/api/v1/objects/cpexport?apikey=XXXXXXXXXXXXXXX&pretty=1&host_name=localhost&service_description=CPUStats&track=idle

Re: objects/cpexport: historical data

Posted: Mon Mar 25, 2019 8:47 am
by anilgupta
@ssax,

Thanks for your response.

Can you please guide me on how to find the related track for various services? For example what are track options for disk and memory utilization?

Re: objects/cpexport: historical data

Posted: Mon Mar 25, 2019 2:45 pm
by ssax
Go look at the performance graphs, at the bottom of the graphs in the legend it will show you the tracks.

Or look at the perfdata labels returned from your plugin by clicking the Advanced (+) tab when viewing the host/service.

Or look in your /usr/local/nagios/share/perfdata/HOSTNAME/SERVICENAME.xml file and see this section:
- You can see it has user, system, iowait, and idle listed, those are the tracks

Code: Select all

<NAGIOS_SERVICEPERFDATA>user=1.10% system=2.00% iowait=0.0%;70,40,30;90,60,40 idle=96.79%</NAGIOS_SERVICEPERFDATA>