114 lines
4.2 KiB
Plaintext
114 lines
4.2 KiB
Plaintext
object CheckCommand "dummy-host" {
|
|
import "plugin-check-command"
|
|
command = [ PluginDir + "/test_hostcheck.pl" ]
|
|
arguments = {
|
|
"--type" = "$check_type$"
|
|
"--failchance" = "$check_failchance$"
|
|
"--previous-state" = "$check_previous_state$"
|
|
"--state-duration" = "$check_state_duration$"
|
|
"--hostname" = "$check_hostname$"
|
|
}
|
|
|
|
vars.check_type = "UP"
|
|
vars.check_failchance = "2%"
|
|
vars.check_previous_state = "$state$"
|
|
vars.check_state_duration = "$duration_sec$"
|
|
vars.check_hostname = "$name$"
|
|
}
|
|
|
|
object CheckCommand "dummy-service" {
|
|
import "plugin-check-command"
|
|
command = [ PluginDir + "/test_servicecheck.pl" ]
|
|
arguments = {
|
|
"--total-critical-on-host" = "$check_critical_on_host$"
|
|
"--total-warning-on-host" = "$check_warning_on_host$"
|
|
"--type" = "$check_type$"
|
|
"--failchance" = "$check_failchance$"
|
|
"--previous-state" = "$check_previous_state$"
|
|
"--state-duration" = "$check_state_duration$"
|
|
"--hostname" = "$check_hostname$"
|
|
"--servicedesc" = "$check_servicedesc$"
|
|
}
|
|
vars.check_critical_on_host = "$host.total_services_critical$"
|
|
vars.check_warning_on_host = "$host.total_services_warning$"
|
|
vars.check_type = "random"
|
|
vars.check_failchange = "5%"
|
|
vars.check_previous_state = "$service.state$"
|
|
vars.check_duration = "$service.duration_sec$"
|
|
vars.check_hostname = "$host.name$"
|
|
vars.check_servicedesc = "$service.name$"
|
|
}
|
|
|
|
// Hostgroups
|
|
object HostGroup "all-hosts" {
|
|
display_name = "All hosts on the system"
|
|
assign where true
|
|
}
|
|
|
|
var host_types = ["ok", "random", "down", "up", "unreachable", "pending"]
|
|
|
|
for (host_type in host_types) {
|
|
object HostGroup "all-" + host_type use (host_type) {
|
|
display_name = "All " + host_type + " hosts"
|
|
assign where host.vars.check_type == host_type
|
|
}
|
|
}
|
|
|
|
var service_types = ["ok", "warning", "critical", "unknown", "flapping", "pending"]
|
|
|
|
// Servicegroups
|
|
for (service_type in service_types) {
|
|
object ServiceGroup "service-" + service_type use (service_type) {
|
|
display_name = "All " + service_type + " services"
|
|
assign where service.vars.check_type == service_type
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
// Services
|
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
|
|
function createService(service_type, num) {
|
|
apply Service "service-" + service_type + "-" + string(num + 1) use (service_type) {
|
|
import "generic-service"
|
|
|
|
check_command = "dummy-service"
|
|
enable_active_checks = (service_type != "pending")
|
|
vars.check_type = service_type
|
|
|
|
assign where service_type in host.vars.check_config
|
|
}
|
|
}
|
|
|
|
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 + 1) use (checkEnabled, checkType, checkConfig) {
|
|
import "generic-host"
|
|
address = "127.0.0.1"
|
|
check_command = "dummy-host"
|
|
enable_active_checks = checkEnabled
|
|
vars.check_type = checkType
|
|
vars.check_config = checkConfig
|
|
}
|
|
}
|
|
|
|
for (num in range(10)) {
|
|
createHost("ok", [ "ok" ], 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", [ "flapping" ], num, true)
|
|
}
|
|
|
|
// EOF
|