objects/cpexport: historical data

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
anilgupta
Posts: 102
Joined: Fri Mar 01, 2019 8:35 am

objects/cpexport: historical data

Post 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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: objects/cpexport: historical data

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
anilgupta
Posts: 102
Joined: Fri Mar 01, 2019 8:35 am

Re: objects/cpexport: historical data

Post 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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: objects/cpexport: historical data

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
anilgupta
Posts: 102
Joined: Fri Mar 01, 2019 8:35 am

Re: objects/cpexport: historical data

Post 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"
}
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: objects/cpexport: historical data

Post 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
anilgupta
Posts: 102
Joined: Fri Mar 01, 2019 8:35 am

Re: objects/cpexport: historical data

Post 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%
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: objects/cpexport: historical data

Post 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
anilgupta
Posts: 102
Joined: Fri Mar 01, 2019 8:35 am

Re: objects/cpexport: historical data

Post 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?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: objects/cpexport: historical data

Post 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>
Locked