Icinga DLS - monitoring services

hello Team,

Unfortunately, I am not an expert on Icinga DSL and because of this, I have a friendly request for you.

I need to create a monitoring service that will be monitoring if ALL services under an exact host will be in status OK. I don’t want to use businessprocess module for this task.

Something similar was done here >>
checking-service-clusters-in-icinga-2

With this Icinga command, you are able to check an exact service on various hosts and give the status OK if all are UP.

I need something the same but in opposite, ALL services under one exact host.
If even one service from the list is in UNKNOWN or CRITICAL then the command will have Critical in the output.

Maybe it’s an easy thing if modify the command from this example …
In the attachment Icinga DSL from the example.

argument_1.txt (457 Bytes)
argument_2.txt (1.3 KB)

old topic is here:

xy

Quick and dirty coded (with ignoring soft/hard state):

apply Service "all-services" {
    check_command = "dummy"

    vars.dummy_state = {{
        var state = 0
        for (svc in get_services(host.name)) {
            if (svc.name != "all-services") {
                if (state < 2 && svc.state > 1) {
                    state = 2
                }
            }
        }
        return state
    }}

    vars.dummy_text = {{
        var states = ["Ok", "Warning", "Critical", "Unknown"]
        var output = "Check all services\n"
        for (svc in get_services(host.name)) {
            if (svc.name != "all-services") {
                output += svc.display_name + ": " + states[svc.state] + "\n"
            }
        }
        return output
   }}

   assign where true
}
1 Like

Roland thx for the response. But could you check for creating rather an Icinga “command” that could be integrated thru Icinga Director.

here is a ready-for-use Icinga command >>

but it has a limitation. you are monitoring services from the different hosts.

I need something in opposition to this command from provided URL. I need to create a service under the exact host. This service must monitor a number of services from the host. And give OK only when every service is in status OK.

xy

Hey you can check my command below
You can modify it as you wish, it if all services are up on a single host.
Just follow the guide provided