Statehistory command via api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
nms
Posts: 222
Joined: Wed Sep 28, 2016 9:35 am

Statehistory command via api

Post by nms »

Hi,

I am trying to build up some statistics for alarms via API.
What I am trying to achieve is this:

1. Number of HARD alarms PER host group (i.e irrespective of severity, unknown+critical_warning) but separate per host group
EX: Hostgrp1 - X alarms
Hostgrp2 - X alarms

2. The number of HARD alarms with NO host group (again irrespective of severity).

I know that you can call via api with:

Code: Select all

curl -XGET "http://<ipaddress>/nagiosxi/api/v1/objects/statehistory?apikey=<apikey>&last_hard_state=1"
but I can't understand how I can set the parameters for limiting to a host group and limit to state. I guess if you don't input a timeframe it defaults to 24hrs which is good for me.

Basically I am looking after the below parameters in the api:
2019-10-10_1810.png
Can you kindly help?

Rgds
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Statehistory command via api

Post by benjaminsmith »

Hello @nms,

That endpoint does not contain a hostgroup field to lmit on. You can however do this by the host or object ID.

Code: Select all

    "stateentry": [
        {
            "instance_id": "1",
            "state_time": "2015-09-24 03:39:52",
            "object_id": "175",
            "objecttype_id": "2",
            "host_name": "127.0.0.1",
            "service_description": "Load",
            "state_change": "1",
            "state": "2",
            "state_type": "0",
            "current_check_attempt": "1",
            "max_check_attempts": "5",
            "last_state": "0",
            "last_hard_state": "0",
            "output": "awfawfawf"
        },
One thing to note, is that you can download the State History report in CSV format for running analyzing the data.
state-history.png
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked