aboutsummaryrefslogtreecommitdiff
path: root/modules/profile/manifests
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-07-08 15:35:43 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-07-09 20:16:21 +0200
commit6962463657db999c33f1aabe60e0567be218918d (patch)
tree8d1d7c924fe68c56a4478165e50e5dc1bbc758aa /modules/profile/manifests
parentd8f933bd00a5cc416da00cd26c9d13f7a1c02486 (diff)
downloadPuppet-6962463657db999c33f1aabe60e0567be218918d.tar.gz
Puppet-6962463657db999c33f1aabe60e0567be218918d.tar.zst
Puppet-6962463657db999c33f1aabe60e0567be218918d.zip
Prepare master monitoring
Diffstat (limited to 'modules/profile/manifests')
-rw-r--r--modules/profile/manifests/monitoring/commands.pp1
-rw-r--r--modules/profile/manifests/monitoring/contacts.pp13
-rw-r--r--modules/profile/manifests/monitoring/hosts.pp26
-rw-r--r--modules/profile/manifests/monitoring/local_service.pp65
-rw-r--r--modules/profile/manifests/monitoring/services.pp102
-rw-r--r--modules/profile/manifests/monitoring/times.pp13
6 files changed, 127 insertions, 93 deletions
diff --git a/modules/profile/manifests/monitoring/commands.pp b/modules/profile/manifests/monitoring/commands.pp
index 7e9683f..a25f7b3 100644
--- a/modules/profile/manifests/monitoring/commands.pp
+++ b/modules/profile/manifests/monitoring/commands.pp
@@ -31,6 +31,7 @@ class profile::monitoring::commands inherits profile::monitoring {
31 target => "/etc/naemon/objects.cfg", 31 target => "/etc/naemon/objects.cfg",
32 notify => Service["naemon"], 32 notify => Service["naemon"],
33 before => Service["naemon"], 33 before => Service["naemon"],
34 require => File["/etc/naemon"],
34 } 35 }
35 36
36 nagios_command { 37 nagios_command {
diff --git a/modules/profile/manifests/monitoring/contacts.pp b/modules/profile/manifests/monitoring/contacts.pp
index 284d51c..107af18 100644
--- a/modules/profile/manifests/monitoring/contacts.pp
+++ b/modules/profile/manifests/monitoring/contacts.pp
@@ -1,11 +1,12 @@
1class profile::monitoring::contacts { 1class profile::monitoring::contacts {
2 Nagios_contactgroup { 2 Nagios_contactgroup {
3 ensure => "present", 3 ensure => "present",
4 owner => "naemon", 4 owner => "naemon",
5 group => "naemon", 5 group => "naemon",
6 target => "/etc/naemon/objects.cfg", 6 target => "/etc/naemon/objects.cfg",
7 notify => Service["naemon"], 7 notify => Service["naemon"],
8 before => Service["naemon"], 8 before => Service["naemon"],
9 require => File["/etc/naemon"],
9 } 10 }
10 11
11 nagios_contactgroup { "admins": 12 nagios_contactgroup { "admins":
diff --git a/modules/profile/manifests/monitoring/hosts.pp b/modules/profile/manifests/monitoring/hosts.pp
index 306fe3e..3c8bc73 100644
--- a/modules/profile/manifests/monitoring/hosts.pp
+++ b/modules/profile/manifests/monitoring/hosts.pp
@@ -2,21 +2,23 @@ class profile::monitoring::hosts {
2 $real_hostname = lookup("base_installation::real_hostname") 2 $real_hostname = lookup("base_installation::real_hostname")
3 3
4 Nagios_hostgroup { 4 Nagios_hostgroup {
5 ensure => "present", 5 ensure => "present",
6 owner => "naemon", 6 owner => "naemon",
7 group => "naemon", 7 group => "naemon",
8 target => "/etc/naemon/objects.cfg", 8 target => "/etc/naemon/objects.cfg",
9 notify => Service["naemon"], 9 notify => Service["naemon"],
10 before => Service["naemon"], 10 before => Service["naemon"],
11 require => File["/etc/naemon"],
11 } 12 }
12 13
13 Nagios_host { 14 Nagios_host {
14 ensure => "present", 15 ensure => "present",
15 owner => "naemon", 16 owner => "naemon",
16 group => "naemon", 17 group => "naemon",
17 target => "/etc/naemon/objects.cfg", 18 target => "/etc/naemon/objects.cfg",
18 notify => Service["naemon"], 19 notify => Service["naemon"],
19 before => Service["naemon"], 20 before => Service["naemon"],
21 require => File["/etc/naemon"],
20 } 22 }
21 23
22 nagios_hostgroup { "linux-servers": 24 nagios_hostgroup { "linux-servers":
diff --git a/modules/profile/manifests/monitoring/local_service.pp b/modules/profile/manifests/monitoring/local_service.pp
new file mode 100644
index 0000000..3b39d1f
--- /dev/null
+++ b/modules/profile/manifests/monitoring/local_service.pp
@@ -0,0 +1,65 @@
1define profile::monitoring::local_service (
2 Optional[Hash] $common = {},
3 Optional[Hash] $master = {},
4 Optional[Hash] $local = {},
5) {
6 $service_description = $title
7 $real_hostname = lookup("base_installation::real_hostname")
8
9 $service_generic = {
10 active_checks_enabled => "1",
11 check_freshness => "0",
12 check_interval => "10",
13 check_period => "24x7",
14 contact_groups => "admins",
15 event_handler_enabled => "1",
16 flap_detection_enabled => "1",
17 is_volatile => "0",
18 max_check_attempts => "3",
19 notification_interval => "60",
20 notification_options => "w,u,c,r",
21 notification_period => "24x7",
22 notifications_enabled => "0",
23 obsess_over_service => "1",
24 passive_checks_enabled => "1",
25 process_perf_data => "1",
26 retain_nonstatus_information => "1",
27 retain_status_information => "1",
28 retry_interval => "2",
29 }
30
31 $service_local = merge($service_generic, {
32 host_name => $real_hostname,
33 check_interval => "5",
34 max_check_attempts => "4",
35 retry_interval => "1",
36 })
37
38
39 [true, false].each |$services_for_master| {
40 if $services_for_master {
41 $default_local = {
42 mode => "0644",
43 target => "/etc/naemon/services_for_master.cfg",
44 check_interval => $service_local["check_interval"],
45 retry_interval => $service_local["retry_interval"],
46 host_name => $service_local["host_name"],
47 use => "external-service",
48 notify => [],
49 }
50 $t = "master - "
51 $services_key = $master
52 } else {
53 $default_local = merge($service_local, { target => "/etc/naemon/objects.cfg" })
54 $t = ""
55 $services_key = $local
56 }
57
58 $hash = merge($default_local, $common, $services_key)
59
60 nagios_service { "$t$service_description":
61 service_description => $service_description,
62 * => $hash
63 }
64 }
65}
diff --git a/modules/profile/manifests/monitoring/services.pp b/modules/profile/manifests/monitoring/services.pp
index 39c2def..6e59ab1 100644
--- a/modules/profile/manifests/monitoring/services.pp
+++ b/modules/profile/manifests/monitoring/services.pp
@@ -1,45 +1,14 @@
1class profile::monitoring::services { 1class profile::monitoring::services {
2 $real_hostname = lookup("base_installation::real_hostname")
3 2
4 Nagios_service { 3 Nagios_service {
5 ensure => "present", 4 ensure => "present",
6 owner => "naemon", 5 owner => "naemon",
7 group => "naemon", 6 group => "naemon",
8 target => "/etc/naemon/objects.cfg", 7 notify => Service["naemon"],
9 notify => Service["naemon"], 8 before => Service["naemon"],
10 before => Service["naemon"], 9 require => File["/etc/naemon"],
11 } 10 }
12 11
13 $service_generic = {
14 active_checks_enabled => "1",
15 check_freshness => "0",
16 check_interval => "10",
17 check_period => "24x7",
18 contact_groups => "admins",
19 event_handler_enabled => "1",
20 flap_detection_enabled => "1",
21 is_volatile => "0",
22 max_check_attempts => "3",
23 notification_interval => "60",
24 notification_options => "w,u,c,r",
25 notification_period => "24x7",
26 notifications_enabled => "1",
27 obsess_over_service => "1",
28 passive_checks_enabled => "1",
29 process_perf_data => "1",
30 retain_nonstatus_information => "1",
31 retain_status_information => "1",
32 retry_interval => "2",
33 }
34
35
36 $service_local = merge($service_generic, {
37 host_name => $real_hostname,
38 check_interval => "5",
39 max_check_attempts => "4",
40 retry_interval => "1",
41 })
42
43 sudo::conf { 12 sudo::conf {
44 default: 13 default:
45 sudo_file_name => "naemon"; 14 sudo_file_name => "naemon";
@@ -47,43 +16,38 @@ class profile::monitoring::services {
47 content => "naemon ALL=(root) NOPASSWD: /usr/bin/fail2ban-client ping"; 16 content => "naemon ALL=(root) NOPASSWD: /usr/bin/fail2ban-client ping";
48 } 17 }
49 18
50 nagios_service { 19 profile::monitoring::local_service {
51 default: * => $service_local;
52 "Size on root partition": 20 "Size on root partition":
53 service_description => "Size on root partition", 21 local => {
54 check_command => "check_local_disk!20%!10%!/"; 22 check_command => "check_local_disk!20%!10%!/",
23 };
55 "Total number of process": 24 "Total number of process":
56 service_description => "Total number of process", 25 local => {
57 check_command => "check_local_procs!250!400!RSZDT"; 26 check_command => "check_local_procs!50!100!RSZDT",
27 };
58 "Average load": 28 "Average load":
59 service_description => "Average load", 29 local => {
60 check_command => "check_local_load!8.0,8.0,8.0!10.0,10.0,10.0"; 30 check_command => "check_local_load!8.0,8.0,8.0!10.0,10.0,10.0",
31 };
61 "Swap usage": 32 "Swap usage":
62 service_description => "Swap usage", 33 local => {
63 check_command => "check_local_swap!20!10"; 34 check_command => "check_local_swap!20!10",
35 };
64 "fail2ban is active": 36 "fail2ban is active":
65 service_description => "fail2ban is active", 37 local => {
66 check_command => "check_command_output!fail2ban-client ping!pong!-r root", 38 check_command => "check_command_output!fail2ban-client ping!pong!-r root",
67 require => Sudo::Conf["naemon-fail2ban"]; 39 require => Sudo::Conf["naemon-fail2ban"],
40 };
68 "NTP is activated and working": 41 "NTP is activated and working":
69 service_description => "NTP is activated and working", 42 local => {
70 check_command => "check_ntp"; 43 check_command => "check_ntp",
71 } 44 };
72 45 "No mdadm array is degraded":
73 if empty(find_file("/proc/mdstat")) { 46 common => {
74 nagios_service { 47 ensure => (find_file("/proc/mdstat") == undef) ? { true => "absent", default =>"present" },
75 default: * => $service_local; 48 },
76 "No mdadm array is degraded": 49 local => {
77 ensure => "absent", 50 check_command => "check_md_raid",
78 service_description => "No mdadm array is degraded", 51 };
79 check_command => "check_md_raid";
80 }
81 } else {
82 nagios_service {
83 default: * => $service_local;
84 "No mdadm array is degraded":
85 service_description => "No mdadm array is degraded",
86 check_command => "check_md_raid";
87 }
88 } 52 }
89} 53}
diff --git a/modules/profile/manifests/monitoring/times.pp b/modules/profile/manifests/monitoring/times.pp
index fb61acc..25bf86b 100644
--- a/modules/profile/manifests/monitoring/times.pp
+++ b/modules/profile/manifests/monitoring/times.pp
@@ -1,11 +1,12 @@
1class profile::monitoring::times { 1class profile::monitoring::times {
2 Nagios_timeperiod { 2 Nagios_timeperiod {
3 ensure => "present", 3 ensure => "present",
4 owner => "naemon", 4 owner => "naemon",
5 group => "naemon", 5 group => "naemon",
6 target => "/etc/naemon/objects.cfg", 6 target => "/etc/naemon/objects.cfg",
7 notify => Service["naemon"], 7 notify => Service["naemon"],
8 before => Service["naemon"], 8 before => Service["naemon"],
9 require => File["/etc/naemon"],
9 } 10 }
10 11
11 nagios_timeperiod { "24x7": 12 nagios_timeperiod { "24x7":