@ -0,0 +1,118 @@ | |||
/* | |||
* Service apply rules. | |||
* | |||
* The CheckCommand objects `ping4`, `ping6`, etc | |||
* are provided by the plugin check command templates. | |||
* Check the documentation for details. | |||
* | |||
* Tip: Use `icinga2 object list --type Service` to | |||
* list all service objects after running | |||
* configuration validation (`icinga2 daemon -C`). | |||
*/ | |||
/* | |||
* This is an example host based on your | |||
* local host's FQDN. Specify the NodeName | |||
* constant in `constants.conf` or use your | |||
* own description, e.g. "db-host-1". | |||
*/ | |||
/* | |||
* These are generic `ping4` and `ping6` | |||
* checks applied to all hosts having the | |||
* `address` resp. `address6` attribute | |||
* defined. | |||
*/ | |||
apply Service "ping4" { | |||
import "generic-service" | |||
check_command = "ping4" | |||
assign where host.address | |||
} | |||
apply Service "ping6" { | |||
import "generic-service" | |||
check_command = "ping6" | |||
assign where host.address6 | |||
} | |||
/* | |||
* Apply the `ssh` service to all hosts | |||
* with the `address` attribute defined and | |||
* the custom attribute `os` set to `Linux`. | |||
*/ | |||
apply Service "ssh" { | |||
import "generic-service" | |||
check_command = "ssh" | |||
assign where (host.address || host.address6) && host.vars.os == "Linux" | |||
} | |||
apply Service for (http_vhost => config in host.vars.http_vhosts) { | |||
import "generic-service" | |||
check_command = "http" | |||
vars += config | |||
} | |||
apply Service for (disk => config in host.vars.disks) { | |||
import "generic-service" | |||
check_command = "disk" | |||
vars += config | |||
assign where host.name == NodeName | |||
} | |||
apply Service "icinga" { | |||
import "generic-service" | |||
check_command = "icinga" | |||
assign where host.name == NodeName | |||
} | |||
apply Service "load" { | |||
import "generic-service" | |||
check_command = "load" | |||
/* Used by the ScheduledDowntime apply rule in `downtimes.conf`. */ | |||
vars.backup_downtime = "02:00-03:00" | |||
assign where host.name == NodeName | |||
} | |||
apply Service "procs" { | |||
import "generic-service" | |||
check_command = "procs" | |||
assign where host.name == NodeName | |||
} | |||
apply Service "swap" { | |||
import "generic-service" | |||
check_command = "swap" | |||
assign where host.name == NodeName | |||
} | |||
apply Service "users" { | |||
import "generic-service" | |||
check_command = "users" | |||
assign where host.name == NodeName | |||
} | |||
@ -0,0 +1,52 @@ | |||
/* | |||
* Service apply rules for ssh remote agents. | |||
* | |||
* For the moment the following service are supported: | |||
* - disk | |||
* - procs | |||
* - apt | |||
* | |||
*/ | |||
apply Service for (disk => config in host.vars.disks) { | |||
import "generic-service" | |||
check_command = "by_ssh" | |||
vars.by_ssh_options = "HostKeyAlias="+host.name | |||
vars.by_ssh_logname = "icinga" | |||
vars.by_ssh_command = [ "/usr/lib/nagios/plugins/check_disk" ] | |||
vars.by_ssh_arguments = { | |||
"-w" = { | |||
value = "20%" | |||
} | |||
"-c" = { | |||
value = "10%" | |||
} | |||
} | |||
vars += config | |||
assign where host.vars.agent_type == "ssh" | |||
} | |||
apply Service "procs" { | |||
import "generic-service" | |||
check_command = "by_ssh" | |||
vars.by_ssh_options = "HostKeyAlias="+host.name | |||
vars.by_ssh_logname = "icinga" | |||
vars.by_ssh_command = [ "/usr/lib/nagios/plugins/check_procs" ] | |||
assign where host.vars.agent_type == "ssh" | |||
} | |||
apply Service "apt" { | |||
import "generic-service" | |||
check_command = "by_ssh" | |||
vars.by_ssh_options = "HostKeyAlias="+host.name | |||
vars.by_ssh_logname = "icinga" | |||
vars.by_ssh_command = [ "/usr/lib/nagios/plugins/check_apt" ] | |||
assign where host.vars.agent_type == "ssh" | |||
} |
@ -0,0 +1,91 @@ | |||
template Host "generic-host" { | |||
max_check_attempts = 3 | |||
check_interval = 1m | |||
retry_interval = 30s | |||
check_command = "hostalive" | |||
/* Disk monitoring enabled by default in Agent hosts */ | |||
vars.disks["disk"] = { | |||
/* No parameters. */ | |||
} | |||
} | |||
/* | |||
* Generic template examples. | |||
*/ | |||
/** | |||
* Provides default settings for hosts. By convention | |||
* all hosts should import this template. | |||
* | |||
* The CheckCommand object `hostalive` is provided by | |||
* the plugin check command templates. | |||
* Check the documentation for details. | |||
*/ | |||
/** | |||
* Provides default settings for services. By convention | |||
* all services should import this template. | |||
*/ | |||
template Service "generic-service" { | |||
max_check_attempts = 5 | |||
check_interval = 1m | |||
retry_interval = 30s | |||
} | |||
/** | |||
* Provides default settings for users. By convention | |||
* all users should inherit from this template. | |||
*/ | |||
template User "generic-user" { | |||
} | |||
/** | |||
* Provides default settings for host notifications. | |||
* By convention all host notifications should import | |||
* this template. | |||
*/ | |||
template Notification "mail-host-notification" { | |||
command = "mail-host-notification" | |||
states = [ Up, Down ] | |||
types = [ Problem, Acknowledgement, Recovery, Custom, | |||
FlappingStart, FlappingEnd, | |||
DowntimeStart, DowntimeEnd, DowntimeRemoved ] | |||
vars += { | |||
// notification_icingaweb2url = "https://www.example.com/icingaweb2" | |||
// notification_from = "Icinga 2 Host Monitoring <icinga@example.com>" | |||
notification_logtosyslog = false | |||
} | |||
period = "24x7" | |||
} | |||
/** | |||
* Provides default settings for service notifications. | |||
* By convention all service notifications should import | |||
* this template. | |||
*/ | |||
template Notification "mail-service-notification" { | |||
command = "mail-service-notification" | |||
states = [ OK, Warning, Critical, Unknown ] | |||
types = [ Problem, Acknowledgement, Recovery, Custom, | |||
FlappingStart, FlappingEnd, | |||
DowntimeStart, DowntimeEnd, DowntimeRemoved ] | |||
vars += { | |||
// notification_icingaweb2url = "https://www.example.com/icingaweb2" | |||
// notification_from = "Icinga 2 Service Monitoring <icinga@example.com>" | |||
notification_logtosyslog = false | |||
} | |||
period = "24x7" | |||
} |