MariadDB Query for Total alert generated from last WEEK/MONT

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
prasadt
Posts: 25
Joined: Wed Sep 24, 2014 1:18 am

MariadDB Query for Total alert generated from last WEEK/MONT

Post by prasadt »

Hello Team,

As we are getting total alert information from the Nagios Core Dashboard, Can we get that total number of alerts from the Mariadb query.

We want that data in our application portal to show how many alerts generated every WEEK/MONTH/DAY.

For doing this we need mariadb Query to generate weekly monthly total alert like it is showing in the attachment.

Can you please check and let me know the Query.

Regards,
Manoj Namdev
Attachments
How to generate alert from nagios core dashboard
How to generate alert from nagios core dashboard
Total Alert generated monthly
Total Alert generated monthly
ABC123-reports.png (10.1 KiB) Viewed 2081 times
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: MariadDB Query for Total alert generated from last WEEK/

Post by mcapra »

I'm a bit confused. Nagios Core doesn't have a MariaDB back-end. Unless you're referring to NagiosQL? Or Nagios XI?
We want that data in our application portal to show how many alerts generated every WEEK/MONTH/DAY.
If you wanted to do this programatically, I think the JSON Query Generator is probably the best route.
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: MariadDB Query for Total alert generated from last WEEK/

Post by scottwilkerson »

@mcapra is correct, this data isn't in a DB in Core by default
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
prasadt
Posts: 25
Joined: Wed Sep 24, 2014 1:18 am

Re: MariadDB Query for Total alert generated from last WEEK/

Post by prasadt »

Thanks team,

Its great help you guys are genius.

Can you just tell me how i can run JSON Query means fields to get desired output.

I want to count weekly hard alerts from the nagios core server.. I am little bit confused in date format and some other fields.

Please help me.

Thanks for your prompt support also
prasadt
Posts: 25
Joined: Wed Sep 24, 2014 1:18 am

Re: MariadDB Query for Total alert generated from last WEEK/

Post by prasadt »

Specifically confused with Date Format and how i can keep "start time" and "end time"
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: MariadDB Query for Total alert generated from last WEEK/

Post by mcapra »

prasadt wrote: I want to count
2017_06_14_11_59_14_JSON_Query_Generator.png
prasadt wrote:weekly
2017_06_14_12_00_38_JSON_Query_Generator.png
2017_06_14_12_00_38_JSON_Query_Generator.png (9.97 KiB) Viewed 2063 times
Your "Start Time" and "End Time" will need to be evaluated as unix epochs at the time you make the JSON Query request.
prasadt wrote:hard alerts
2017_06_14_12_03_28_JSON_Query_Generator.png
2017_06_14_12_03_28_JSON_Query_Generator.png (3.61 KiB) Viewed 2063 times
Which creates this request:

Code: Select all

http://10.35.6.50/nagios/cgi-bin/archivejson.cgi?query=alertcount&statetypes=hard&starttime=1493657796&endtime=1497459396
Which returns this JSON structure:

Code: Select all

{
    "format_version": 0,
    "result": {
        "query_time": 1497459542000,
        "cgi": "archivejson.cgi",
        "user": "nagiosadmin",
        "query": "alertcount",
        "query_status": "released",
        "program_start": 1497368308000,
        "last_data_update": 1497459181000,
        "type_code": 0,
        "type_text": "Success",
        "message": ""
    },
    "data": {
        "selectors": {
            "starttime": 1493657796000,
            "endtime": 1497459396000,
            "statetypes": 1
        },
        "count": 155
    }
}
Former Nagios employee
https://www.mcapra.com/
prasadt
Posts: 25
Joined: Wed Sep 24, 2014 1:18 am

Re: MariadDB Query for Total alert generated from last WEEK/

Post by prasadt »

Thanks Mcapra,

Perfect Thanks a lot you saved my life.

I Got what i was looking and i tried from every wrong place but in only 1 days you guys have cracked this even i can say in just some minutes.

Thanks a lot for simplify this and given me in such a perfect query.

Have a nice DAY :-)

You can please close this ticket.


Regards,
Manoj Namdev
Locked