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