Page 1 of 2

REST service and host status + downtime and acknowledgements

Posted: Wed Feb 22, 2017 8:19 am
by stefanmadsen
Hi,

I'm writing a Little feature request for my organisation now, which is basically utilizing the Nagios XI BPI idea, but spiced up with our specific requirements.

what I'm working on:
I have a central java application which will run on the nagios Xi server - as a service/daemon (using apache common daemon)
the application pulls the BPI configuration, and then aligns BPI's in a matrix. This matrix splits environments in the same way BPI grouping would Work, but in a slightly different way.

since this is intended for our OPS, i need to include scheduled downtime and alert acks into the BPI logical Groups. (as in it shouldnt go "red" if its acknowledged)

(another reason as to why i wanted to backend proces this, is the REST calls the BPI dashboard is actually straining the nagios server quite alot when multiple dashboards are up and running, hence centralizing it with a single proces that polls the REST interface and exposes a result table, for a nagios dashboard to pull, (alot less data processed) - Means less strain on the nagios server)

I have the service and host REST calls working as i want it to - but i need some clarification on a few Things just to get it right - I've been unable to find meaningful information anywhere.

the REST call to /downtime:
As the service and host REST calls doesnt contain information whether or not the service/host is in a downtime state - i understand that i need to pull the /downtime information.
These registrations contain links (object_id) to the respective service_id/host_id - check.
but is the actual downtime status of a check done by nagios through the start_time and end_time?, or is there a flag ? "=1" somewhere i could pull?, i could simply check if time is between start and end.. but would be rather silly if Theres an attribute somewhere I've missed.
or are you checking up against the service/host calls last_check time ?

also please confirm for the /downtime json:
downtime_type ---> what are these values representing?
objecttype_id is 1 for host checks, 2 for service checks ?
object_id is either service_id (for service checks) or host_id (for host checks) depending on objecttype_ids value for host/service ?

the REST call to /*status (host/service):
acknowledgement_type is ---> what are these values representing ?
problem_acknowledged is ---> what are these values representing ? (im guessing 0 is "null" and 1 is "acknowledged" - any more states?)

Re: REST service and host status + downtime and acknowledgem

Posted: Wed Feb 22, 2017 4:43 pm
by dwhitfield
stefanmadsen wrote: but is the actual downtime status of a check done by nagios through the start_time and end_time?, or is there a flag ? "=1" somewhere i could pull?, i could simply check if time is between start and end.. but would be rather silly if Theres an attribute somewhere I've missed.
or are you checking up against the service/host calls last_check time ?

also please confirm for the /downtime json:
downtime_type ---> what are these values representing?
objecttype_id is 1 for host checks, 2 for service checks ?
object_id is either service_id (for service checks) or host_id (for host checks) depending on objecttype_ids value for host/service ?

the REST call to /*status (host/service):
acknowledgement_type is ---> what are these values representing ?
problem_acknowledged is ---> what are these values representing ? (im guessing 0 is "null" and 1 is "acknowledged" - any more states?)
It's 57 pages, but I think https://assets.nagios.com/downloads/nag ... _Model.pdf will answer a bunch of questions for you (not enough questions here just to point you to a 57-page document, but I have this feeling more questions are going to pop up!)

What version of XI are you running? I'm not seeing anything under /downtime about start_time, although maybe you just mean scheduled_start_time and actual_start_time.

I don't really understand your question about where it is pulling the status from. There is a /hoststatus.

Also, I would be remiss from saying that running other applications on the XI server is not supported. We of course are very familiar with certain third-party plugins, but you need to be very careful that your application doesn't run into dependency issues with current and future XI versions.

Re: REST service and host status + downtime and acknowledgem

Posted: Thu Feb 23, 2017 4:01 am
by stefanmadsen
Thanks i think at least the doc might explain the values

I'm asking regarding the REST calls only.
through the REST calls, how can i check whether or not a specific check (which i've found in /servicestatus) is currently in scheduled downtime?

As from what i can tell in the datamodel, (in your linked doc) - Theres no flag that indicates that a certain hoststatus/servicestatus is currently affected by "scheduled downtime".
But Theres a relacation between instance_id <-> instance_id between scheduleddowntime and host/service-status.

question Again is - how does nagios determine that a check is in a downtime status?

does nagios simply check whether or not a "scheduled downtime" is within a active timeperiod?
since you dont have a way to pull the fact that a check is in downtime, i would have to build this logic myself - but i need to know how its done, i would prefer not to dig through the source code for this.


regarding your second statement:
Yes i respect that, and I am writing my Little daemon to not affect nagios that much.
But having 10 or (this would be worstcase in our organisation) so BPI dashboards thats updating all the time tanks the nagios server.. as its pulling the service and host status REST calls quite often.
My way makes this more consistent regarding the load on the server.

Since it only relies on java (and builtin/packaged libraries) its selfcontained - only thing that could break it would be if the payload in the REST calls would change between versions.

Re: REST service and host status + downtime and acknowledgem

Posted: Thu Feb 23, 2017 4:15 am
by stefanmadsen
hmm, and apparently Theres a field in the /downtime call that is not present in your datamodel document. I reckon its not important?, I'm just wondering.

see "objecttype_id" - heres a fresh REST call to /downtime on a specific entry

Code: Select all

{"@attributes":{"id":"6080"},
"instance_id":"1",
"downtime_type":"1",
"object_id":"2450",
"objecttype_id":"2",
"host_name":"osb02",
"service_description":"AliveCheck-2_0-osb02-krweb",
"entry_time":"2017-02-23 02:01:02",
"author_name":"nagiosadmin",
"comment_data":"AUTO: Web genstart",
"internal_id":"431",
"triggered_by":"0",
"fixed":"1",
"duration":"1200",
"scheduled_start_time":"2017-02-24 02:00:00",
"scheduled_end_time":"2017-02-24 02:20:00",
"was_started":"0",
"actual_start_time":"0000-00-00 00:00:00",
"actual_start_time_usec":"0"}

Re: REST service and host status + downtime and acknowledgem

Posted: Thu Feb 23, 2017 4:26 am
by stefanmadsen
so far I've found that whenever downtime_type = 2, objecttype_id is 1
and whenever downtime type =1, objecttype_id is 2

sooooo....yeah..

Re: REST service and host status + downtime and acknowledgem

Posted: Thu Feb 23, 2017 9:15 am
by stefanmadsen
alright, i guess i could use the downtime.was_started

in the documentation its written in parenthesis in combo with a page break :S - so missed it :

Code: Select all

was_started |SMALLINT| Indicates whether or not the downtime was started (is currently active) | 0 = Not started (inactive) 1 = Started (active)

Re: REST service and host status + downtime and acknowledgem

Posted: Thu Feb 23, 2017 10:34 am
by dwhitfield
stefanmadsen wrote:alright, i guess i could use the downtime.was_started
It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!

Re: REST service and host status + downtime and acknowledgem

Posted: Fri Feb 24, 2017 2:22 am
by stefanmadsen
uhm no.. please elaborate on the objecttype_id

Re: REST service and host status + downtime and acknowledgem

Posted: Fri Feb 24, 2017 10:55 am
by mcapra
objecttype_id is used to indicate what type of Nagios configuration object is being represented. Here's a list of the internal defines we use:

Code: Select all

// OBJECT TYPES
define("OBJECTTYPE_HOST", 1);
define("OBJECTTYPE_SERVICE", 2);
define("OBJECTTYPE_HOSTGROUP", 3);
define("OBJECTTYPE_SERVICEGROUP", 4);
define("OBJECTTYPE_HOSTESCALATION", 5);
define("OBJECTTYPE_SERVICEESCALATION", 6);
define("OBJECTTYPE_HOSTDEPENDENCY", 7);
define("OBJECTTYPE_SERVICEDEPENDENCY", 8);
define("OBJECTTYPE_TIMEPERIOD", 9);
define("OBJECTTYPE_CONTACT", 10);
define("OBJECTTYPE_CONTACTGROUP", 11);
define("OBJECTTYPE_COMMAND", 12);
So in the case of your initial example, "objecttype_id":"2", this item that is scheduled for downtime appears to be a service.

Re: REST service and host status + downtime and acknowledgem

Posted: Mon Feb 27, 2017 2:37 am
by stefanmadsen
thank you very much - please update your documentation accordingly :)