From d8f933bd00a5cc416da00cd26c9d13f7a1c02486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 1 Jul 2018 15:35:43 +0200 Subject: Add monitoring --- modules/profile/manifests/monitoring/services.pp | 89 ++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 modules/profile/manifests/monitoring/services.pp (limited to 'modules/profile/manifests/monitoring/services.pp') diff --git a/modules/profile/manifests/monitoring/services.pp b/modules/profile/manifests/monitoring/services.pp new file mode 100644 index 0000000..39c2def --- /dev/null +++ b/modules/profile/manifests/monitoring/services.pp @@ -0,0 +1,89 @@ +class profile::monitoring::services { + $real_hostname = lookup("base_installation::real_hostname") + + Nagios_service { + ensure => "present", + owner => "naemon", + group => "naemon", + target => "/etc/naemon/objects.cfg", + notify => Service["naemon"], + before => Service["naemon"], + } + + $service_generic = { + active_checks_enabled => "1", + check_freshness => "0", + check_interval => "10", + check_period => "24x7", + contact_groups => "admins", + event_handler_enabled => "1", + flap_detection_enabled => "1", + is_volatile => "0", + max_check_attempts => "3", + notification_interval => "60", + notification_options => "w,u,c,r", + notification_period => "24x7", + notifications_enabled => "1", + obsess_over_service => "1", + passive_checks_enabled => "1", + process_perf_data => "1", + retain_nonstatus_information => "1", + retain_status_information => "1", + retry_interval => "2", + } + + + $service_local = merge($service_generic, { + host_name => $real_hostname, + check_interval => "5", + max_check_attempts => "4", + retry_interval => "1", + }) + + sudo::conf { + default: + sudo_file_name => "naemon"; + 'naemon-fail2ban': + content => "naemon ALL=(root) NOPASSWD: /usr/bin/fail2ban-client ping"; + } + + nagios_service { + default: * => $service_local; + "Size on root partition": + service_description => "Size on root partition", + check_command => "check_local_disk!20%!10%!/"; + "Total number of process": + service_description => "Total number of process", + check_command => "check_local_procs!250!400!RSZDT"; + "Average load": + service_description => "Average load", + check_command => "check_local_load!8.0,8.0,8.0!10.0,10.0,10.0"; + "Swap usage": + service_description => "Swap usage", + check_command => "check_local_swap!20!10"; + "fail2ban is active": + service_description => "fail2ban is active", + check_command => "check_command_output!fail2ban-client ping!pong!-r root", + require => Sudo::Conf["naemon-fail2ban"]; + "NTP is activated and working": + service_description => "NTP is activated and working", + check_command => "check_ntp"; + } + + if empty(find_file("/proc/mdstat")) { + nagios_service { + default: * => $service_local; + "No mdadm array is degraded": + ensure => "absent", + service_description => "No mdadm array is degraded", + check_command => "check_md_raid"; + } + } else { + nagios_service { + default: * => $service_local; + "No mdadm array is degraded": + service_description => "No mdadm array is degraded", + check_command => "check_md_raid"; + } + } +} -- cgit v1.2.3