Changeset View
Changeset View
Standalone View
Standalone View
site-modules/profile/manifests/icinga2/objects/common_checks.pp
# Icinga2 common check definitions | # Icinga2 common check definitions | ||||
class profile::icinga2::objects::common_checks { | class profile::icinga2::objects::common_checks { | ||||
$service_configuration = lookup('icinga2::service_configuration') | $service_configuration = lookup('icinga2::service_configuration') | ||||
$target_file = '/etc/icinga2/zones.d/global-templates/services.conf' | |||||
# Done locally on the master | # Done locally on the master | ||||
::icinga2::object::service {'ping4': | ::icinga2::object::service {'ping4': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => true, | apply => true, | ||||
check_command => 'ping4', | check_command => 'ping4', | ||||
assign => ['host.address'], | assign => ['host.address'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | } | ||||
::icinga2::object::service {'linux-ssh': | ::icinga2::object::service {'linux-ssh': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => true, | apply => true, | ||||
check_command => 'ssh', | check_command => 'ssh', | ||||
assign => ['host.vars.os == Linux'], | assign => ['host.vars.os == Linux'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | } | ||||
# Done remotely on the client: command_endpoint = host.name. | # Done remotely on the client: command_endpoint = host.name. | ||||
each($service_configuration['load']) |$name, $vars| { | each($service_configuration['load']) |$name, $vars| { | ||||
if $name == 'default' { | if $name == 'default' { | ||||
$assign = 'host.vars.os == Linux' | $assign = 'host.vars.os == Linux' | ||||
$ignore = 'host.vars.noagent || host.vars.load' | $ignore = 'host.vars.noagent || host.vars.load' | ||||
} else { | } else { | ||||
$assign = "host.vars.os == Linux && host.vars.load == ${name}" | $assign = "host.vars.os == Linux && host.vars.load == ${name}" | ||||
$ignore = 'host.vars.noagent' | $ignore = 'host.vars.noagent' | ||||
} | } | ||||
::icinga2::object::service {"linux_load_${name}": | ::icinga2::object::service {"linux_load_${name}": | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
service_name => 'load', | service_name => 'load', | ||||
apply => true, | apply => true, | ||||
check_command => 'load', | check_command => 'load', | ||||
command_endpoint => 'host.name', | command_endpoint => 'host.name', | ||||
assign => [$assign], | assign => [$assign], | ||||
ignore => [$ignore], | ignore => [$ignore], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
vars => $vars, | vars => $vars, | ||||
} | } | ||||
} | } | ||||
::icinga2::object::service {'linux_disks': | ::icinga2::object::service {'linux_disks': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => 'disk_name => config in host.vars.disks', | apply => 'disk_name => config in host.vars.disks', | ||||
check_command => 'disk', | check_command => 'disk', | ||||
command_endpoint => 'host.name', | command_endpoint => 'host.name', | ||||
vars => 'vars + config', | vars => 'vars + config', | ||||
assign => ['host.vars.os == Linux'], | assign => ['host.vars.os == Linux'], | ||||
ignore => ['host.vars.noagent'], | ignore => ['host.vars.noagent'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | } | ||||
::icinga2::object::service {'apt': | ::icinga2::object::service {'apt': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => true, | apply => true, | ||||
check_command => 'apt', | check_command => 'apt', | ||||
command_endpoint => 'host.name', | command_endpoint => 'host.name', | ||||
check_interval => '3h', | check_interval => '3h', | ||||
vars => { | vars => { | ||||
apt_timeout => '120', | apt_timeout => '120', | ||||
apt_only_critical => 'true', | apt_only_critical => 'true', | ||||
}, | }, | ||||
assign => ['host.vars.os == Linux'], | assign => ['host.vars.os == Linux'], | ||||
ignore => ['host.vars.noagent'], | ignore => ['host.vars.noagent'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | } | ||||
::icinga2::object::service {'ntp': | ::icinga2::object::service {'ntp': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => true, | apply => true, | ||||
check_command => 'ntp_peer', | check_command => 'ntp_peer', | ||||
command_endpoint => 'host.name', | command_endpoint => 'host.name', | ||||
vars => { | vars => { | ||||
ntp_address => 'localhost', | ntp_address => 'localhost', | ||||
}, | }, | ||||
assign => ['host.vars.os == Linux'], | assign => ['host.vars.os == Linux'], | ||||
ignore => ['host.vars.noagent'], | ignore => ['host.vars.noagent'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | } | ||||
::icinga2::object::service {'journalbeat': | ::icinga2::object::service {'journalbeat': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => true, | apply => true, | ||||
check_command => 'check_journal', | check_command => 'check_journal', | ||||
command_endpoint => 'host.name', | command_endpoint => 'host.name', | ||||
assign => ['host.vars.os == Linux'], | assign => ['host.vars.os == Linux'], | ||||
ignore => ['-:"check_journal" !in host.vars.plugins', 'host.vars.noagent'], | ignore => ['-:"check_journal" !in host.vars.plugins', 'host.vars.noagent'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | } | ||||
::icinga2::object::service {'puppet_agent': | ::icinga2::object::service {'puppet_agent': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => true, | apply => true, | ||||
check_command => 'file_age', | check_command => 'file_age', | ||||
command_endpoint => 'host.name', | command_endpoint => 'host.name', | ||||
vars => { | vars => { | ||||
file_age_file => '/var/lib/puppet/state/agent_disabled.lock', | file_age_file => '/var/lib/puppet/state/agent_disabled.lock', | ||||
file_age_warning_time => '14400', # in seconds, warning after 4h | file_age_warning_time => '14400', # in seconds, warning after 4h | ||||
file_age_critical_time => '86400', # in seconds, critical after 24h | file_age_critical_time => '86400', # in seconds, critical after 24h | ||||
file_age_ignoremissing => 'true', | file_age_ignoremissing => 'true', | ||||
}, | }, | ||||
assign => ['host.vars.os == Linux'], | assign => ['host.vars.os == Linux'], | ||||
ignore => ['host.vars.noagent'], | ignore => ['host.vars.noagent'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | |||||
::icinga2::object::service {'check_postfix': | |||||
import => ['generic-service'], | |||||
apply => true, | |||||
name => "Check postfix service", | |||||
check_command => "check_systemd", | |||||
command_endpoint => 'host.name', | |||||
assign => ['host.vars.os == Linux'], | |||||
vars => { | |||||
check_systemd_unit => 'postfix@-.service', | |||||
}, | |||||
ignore => ['host.vars.noagent'], | |||||
target => $target_file, | |||||
} | } | ||||
::icinga2::object::service {'logstash_errors': | ::icinga2::object::service {'logstash_errors': | ||||
import => ['generic-service'], | import => ['generic-service'], | ||||
apply => true, | apply => true, | ||||
check_command => 'check_logstash_errors.sh', | check_command => 'check_logstash_errors.sh', | ||||
command_endpoint => 'host.name', | command_endpoint => 'host.name', | ||||
assign => ['check_logstash_errors.sh in host.vars.plugins'], | assign => ['check_logstash_errors.sh in host.vars.plugins'], | ||||
ignore => ['host.vars.noagent'], | ignore => ['host.vars.noagent'], | ||||
target => '/etc/icinga2/zones.d/global-templates/services.conf', | target => $target_file, | ||||
} | } | ||||
} | } |