Page 1 of 1
See numeber of notifictions in the last 24 hours
Posted: Thu Oct 02, 2014 9:19 am
by rhassing
Is it possible in Nagios Core or in livestatus to check how many notifications have been sent in the last 24 hours?
The output I need should be just a number.

Re: See numeber of notifictions in the last 24 hours
Posted: Thu Oct 02, 2014 12:34 pm
by abrist
You can use the JSON api in core 4 to fetch this data:
Code: Select all
http://<ip>/nagios/cgi-bin/archivejson.cgi?query=notificationcount&starttime=-86400&endtime=-0
The most important part are the start and endtimes:
-0 is now
-86400 is a day ago
You are welcome to play with the api using the nifty jsonquery.html tool. In core 4 it is located at:
Re: See numeber of notifictions in the last 24 hours
Posted: Fri Oct 03, 2014 5:03 am
by rhassing
It does not seem to work in my installation
Code: Select all
{
"format_version": 0,
"result": {
"query_time": 1412329765000,
"cgi": "archivejson.cgi",
"user": "rhg",
"query": "notificationcount",
"query_status": "beta",
"program_start": 1412325631000,
"last_data_update": 1412329765000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"starttime": 1412143365000,
"endtime": 1412329765000
},
"count": 0
}
}

Re: See numeber of notifictions in the last 24 hours
Posted: Fri Oct 03, 2014 9:53 am
by abrist
Can you try running the query as nagiosadmin? Also, there was a number of JSON escaping fixes in 4.0.8 and a few more fixes will be coming in the next release of core. What version are you running?
URL:
http://dwpro.net/nagios/cgi-bin/archive ... endtime=-0
Code: Select all
{
"format_version": 0,
"result": {
"query_time": 1412347850000,
"cgi": "archivejson.cgi",
"user": "nagiosadmin",
"query": "notificationcount",
"query_status": "beta",
"program_start": 1411882453000,
"last_data_update": 1412347850000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"starttime": 1412261450000,
"endtime": 1412347850000
},
"count": 36
}
}
Re: See numeber of notifictions in the last 24 hours
Posted: Mon Oct 06, 2014 4:08 am
by rhassing
It's working now

There was a authorization problem as you already mentioned.
Thank you very much for your help.
Code: Select all
{
"format_version": 0,
"result": {
"query_time": 1412586302000,
"cgi": "archivejson.cgi",
"user": "rhg",
"query": "notificationcount",
"query_status": "beta",
"program_start": 1412586295000,
"last_data_update": 1412586300000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"starttime": 1412399902000,
"endtime": 1412586302000
},
"count": 73
}
}