See numeber of notifictions in the last 24 hours

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

See numeber of notifictions in the last 24 hours

Post 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. :-)
Rob Hassing
Image
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: See numeber of notifictions in the last 24 hours

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

Code: Select all

http://<ip>/nagios/jsonquery.html
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: See numeber of notifictions in the last 24 hours

Post 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
  }
}
Image
Rob Hassing
Image
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: See numeber of notifictions in the last 24 hours

Post 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
    }
}
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: See numeber of notifictions in the last 24 hours

Post 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
  }
}
Rob Hassing
Image
Locked