parent
709146d49f
commit
f6d42944f7
|
@ -1,5 +1,4 @@
|
|||
|
||||
template CheckCommand "dummy-host-generic" {
|
||||
object CheckCommand "dummy-host" {
|
||||
import "plugin-check-command"
|
||||
command = [ PluginDir + "/libexec/test_hostcheck.pl" ]
|
||||
arguments = {
|
||||
|
@ -17,7 +16,7 @@ template CheckCommand "dummy-host-generic" {
|
|||
vars.check_hostname = "$name$"
|
||||
}
|
||||
|
||||
template CheckCommand "dummy-service-generic" {
|
||||
object CheckCommand "dummy-service" {
|
||||
import "plugin-check-command"
|
||||
command = [ PluginDir + "/libexec/test_servicecheck.pl" ]
|
||||
arguments = {
|
||||
|
@ -40,119 +39,59 @@ template CheckCommand "dummy-service-generic" {
|
|||
vars.check_servicedesc = "$service.name$"
|
||||
}
|
||||
|
||||
// Concrete check commands
|
||||
object CheckCommand "dummy-host" {
|
||||
import "dummy-host-generic"
|
||||
}
|
||||
|
||||
object CheckCommand "dummy-service" {
|
||||
import "dummy-service-generic"
|
||||
}
|
||||
|
||||
// Hostgroups
|
||||
object HostGroup "all-hosts" {
|
||||
display_name = "All hosts on the system"
|
||||
assign where true
|
||||
}
|
||||
|
||||
object HostGroup "all-ok" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-ok", host.name)
|
||||
host_types = ["ok", "random", "down", "up", "unreachable", "pending"]
|
||||
|
||||
__for (host_type in host_types) {
|
||||
object HostGroup "all-" + host_type {
|
||||
display_name = "All " + host_type + " hosts"
|
||||
assign where regex("^test-" + host_type, host.name)
|
||||
}
|
||||
}
|
||||
|
||||
object HostGroup "all-chaos" {
|
||||
display_name = "All chaos hosts"
|
||||
assign where regex("^test-random", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-down" {
|
||||
display_name = "All down hosts"
|
||||
assign where regex("^test-down", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-up" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-ok", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-unreachable" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-unreachable", host.name)
|
||||
}
|
||||
|
||||
object HostGroup "all-pending" {
|
||||
display_name = "All ok hosts"
|
||||
assign where regex("^test-pending", host.name)
|
||||
}
|
||||
service_types = ["ok", "warning", "critical", "unknown", "flapping", "pending"]
|
||||
|
||||
// Servicegroups
|
||||
object ServiceGroup "service-ok" {
|
||||
display_name = "All ok services"
|
||||
assign where regex("^service-ok", service.name)
|
||||
__for (service_type in service_types) {
|
||||
object ServiceGroup "service-" + service_type {
|
||||
display_name = "All " + service_type + " services"
|
||||
assign where regex("^service-" + service_type, service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-warning" {
|
||||
display_name = "All warning services"
|
||||
assign where regex("^service-warning", service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-critical" {
|
||||
display_name = "All critical services"
|
||||
assign where regex("^service-critical", service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-unknown" {
|
||||
display_name = "All unknown services"
|
||||
assign where regex("^service-unknown", service.name)
|
||||
}
|
||||
|
||||
object ServiceGroup "service-flapping" {
|
||||
display_name = "All flapping services"
|
||||
assign where regex("^service-flapping", service.name)
|
||||
}
|
||||
|
||||
|
||||
object ServiceGroup "service-pending" {
|
||||
display_name = "All pending services"
|
||||
assign where regex("^service-pending", service.name)
|
||||
}
|
||||
|
||||
// Config helper
|
||||
function loop(count, func) {
|
||||
count == 1 || loop(count - 1, func)
|
||||
func(count)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Services
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function createService(filter, num, checkEnabled) {
|
||||
apply Service "service-" + filter + "-" + string(num) {
|
||||
__function createService(service_type, num) {
|
||||
apply Service "service-" + service_type + "-" + string(num + 1) {
|
||||
import "generic-service"
|
||||
|
||||
check_command = "dummy-service"
|
||||
enable_active_checks = checkEnabled
|
||||
vars.check_type = filter
|
||||
assign where match("*" + filter + "*", host.vars.check_config)
|
||||
enable_active_checks = (service_type != "pending")
|
||||
vars.check_type = service_type
|
||||
|
||||
assign where match("*" + service_type + "*", host.vars.check_config)
|
||||
}
|
||||
}
|
||||
|
||||
loop(4, lambda num: {
|
||||
createService("ok", num, true)
|
||||
createService("warning", num, true)
|
||||
createService("critical", num, true)
|
||||
createService("flap", num, true)
|
||||
createService("random", num, true)
|
||||
createService("unknown", num, true)
|
||||
createService("pending", num, false)
|
||||
})
|
||||
__for (num in range(4)) {
|
||||
__for (service_type in service_types) {
|
||||
createService(service_type, num)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Hosts
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function createHost(checkType, checkConfig, num, checkEnabled) {
|
||||
object Host "test-" + checkType + "-" + string(num) {
|
||||
__function createHost(checkType, checkConfig, num, checkEnabled) {
|
||||
object Host "test-" + checkType + "-" + string(num + 1) {
|
||||
import "generic-host"
|
||||
address = "127.0.0.1"
|
||||
check_command = "dummy-host"
|
||||
|
@ -162,13 +101,13 @@ function createHost(checkType, checkConfig, num, checkEnabled) {
|
|||
}
|
||||
}
|
||||
|
||||
loop(10, lambda num: {
|
||||
__for (num in range(10)) {
|
||||
createHost("ok", "ok", num, true)
|
||||
createHost("random", "random,flap", num, true)
|
||||
createHost("random", "random,flapping", num, true)
|
||||
createHost("down", "warning,critical", num, true)
|
||||
createHost("unreachable", "unknown", num, true)
|
||||
createHost("pending", "pending", num, false)
|
||||
createHost("flap", "flap", num, true)
|
||||
})
|
||||
createHost("flap", "flapping", num, true)
|
||||
}
|
||||
|
||||
// EOF
|
Loading…
Reference in New Issue