Customize Dashing - Show Services where Hosts are not in downtime

Hello everybody,

this is basically a follow-up question to this post of mine.

My goal is to show ALL critical services in Dashing where the corresponding host is NOT currently in a downtime-state and the service is NOT acknowledged.

I verified that I am querying the right attributes of my host objects, and the code should work as well, thing is, it doesn’t.

I do not know my way around Ruby all too well, so a proofreading of the lines in question would be very nice!

services = icinga.getServiceObjects(["__name", "state", "acknowledgement", "host"], nil, ["host.downtime_depth"])
service_problems = 0
services.each do |service|
  if(service["attrs"]["state"] > 0 && service["attrs"]["acknowledgement"] == 0 && service["joins"]["host.downtime_depth"] == 0.0)
    service_problems += 1

‘service_problems’ gets pushed to a meter-widget within my dashboard, this is the simplest example using this filtering query, even though I intend to use it in many places throughout my code.

Shouldn’t this do the trick? Anything I’m missing?

Thanks in regards,
Best, Daniel


and what exactly is the error? :slight_smile: Where is this code snippet implemented and how does it reach the send_event function?


Ah yeah, the further context…

This code snippet is implemented within icinga2.rb inside the ./jobs folder.
The send_event function is called right after this snippet in the following way:

send_event('icinga-service-meter', {
  value: service_problems,
  max: service_count,
  moreInfo: "some info",
  color: "blue"

Where service_count is the preprocessed total amount of services queried.

The error is, that it does not filter properly. With this filter applied, I am seemingly not getting ANY critical services returned anymore, not even the ones where the respective hosts are not in a downtime at the moment.

If I delete
&& service[“joins”][“downtime_depth”]

from the code, the filter works fine again and displays the correct number of non-“green” services which matches the amount of non-green services shown in icingaweb.

Are you sure that this nested hash value 1) exists 2) has a value?

I tend to debug this with simple puts print statements for the console log.


Thank you very much, it turned out that the value I was looking for was on a lower level of the nested json-response than I thought: service[“joins”][“host”][“downtime_depth”] contains the value.