diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-11 07:45:22 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-11 08:02:15 +0200 |
commit | 0363f38e186b8c942a6db2de4974befbc373f618 (patch) | |
tree | 4c3b08bface133b92748f33bfdb0c58065433a91 /modules | |
parent | bff7d1b743bc2239d7ce7ced37dd03e4e846c03d (diff) | |
download | Puppet-0363f38e186b8c942a6db2de4974befbc373f618.tar.gz Puppet-0363f38e186b8c942a6db2de4974befbc373f618.tar.zst Puppet-0363f38e186b8c942a6db2de4974befbc373f618.zip |
Refactor a bit monitoring profile
Diffstat (limited to 'modules')
-rw-r--r-- | modules/profile/manifests/monitoring.pp | 4 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/commands.pp | 14 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/contacts.pp | 4 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/hosts.pp | 6 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/local_service.pp | 47 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/params.pp | 37 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/times.pp | 4 | ||||
-rw-r--r-- | modules/profile/templates/monitoring/naemon.cfg.erb | 2 | ||||
-rw-r--r-- | modules/profile/templates/monitoring/resource.cfg.erb | 2 |
9 files changed, 66 insertions, 54 deletions
diff --git a/modules/profile/manifests/monitoring.pp b/modules/profile/manifests/monitoring.pp index 7df4ce9..8633626 100644 --- a/modules/profile/manifests/monitoring.pp +++ b/modules/profile/manifests/monitoring.pp | |||
@@ -1,7 +1,7 @@ | |||
1 | class profile::monitoring ( | 1 | class profile::monitoring ( |
2 | Optional[String] $naemon_url = undef, | 2 | Optional[String] $naemon_url = undef, |
3 | Optional[String] $naemon_token = undef, | 3 | Optional[String] $naemon_token = undef, |
4 | ) { | 4 | ) inherits profile::monitoring::params { |
5 | ensure_packages(["naemon", "cnagios"]) | 5 | ensure_packages(["naemon", "cnagios"]) |
6 | 6 | ||
7 | file { "/etc/naemon": | 7 | file { "/etc/naemon": |
@@ -28,7 +28,7 @@ class profile::monitoring ( | |||
28 | content => template("profile/monitoring/naemon.cfg.erb"), | 28 | content => template("profile/monitoring/naemon.cfg.erb"), |
29 | } | 29 | } |
30 | -> | 30 | -> |
31 | file { "/etc/naemon/objects.cfg": | 31 | file { $objects: |
32 | ensure => "file", | 32 | ensure => "file", |
33 | owner => "naemon", | 33 | owner => "naemon", |
34 | group => "naemon", | 34 | group => "naemon", |
diff --git a/modules/profile/manifests/monitoring/commands.pp b/modules/profile/manifests/monitoring/commands.pp index 4ccc816..1c8d0b4 100644 --- a/modules/profile/manifests/monitoring/commands.pp +++ b/modules/profile/manifests/monitoring/commands.pp | |||
@@ -1,7 +1,7 @@ | |||
1 | class profile::monitoring::commands inherits profile::monitoring { | 1 | class profile::monitoring::commands inherits profile::monitoring { |
2 | ensure_packages(["monitoring-plugins"]) | 2 | ensure_packages(["monitoring-plugins"]) |
3 | 3 | ||
4 | file { "/etc/naemon/monitoring-plugins": | 4 | file { $plugins: |
5 | ensure => "directory", | 5 | ensure => "directory", |
6 | owner => "root", | 6 | owner => "root", |
7 | group => "naemon", | 7 | group => "naemon", |
@@ -14,7 +14,7 @@ class profile::monitoring::commands inherits profile::monitoring { | |||
14 | "check_postgres_replication", | 14 | "check_postgres_replication", |
15 | "check_last_file_date", | 15 | "check_last_file_date", |
16 | ].each |$file| { | 16 | ].each |$file| { |
17 | file { "/etc/naemon/monitoring-plugins/$file": | 17 | file { "$plugins/$file": |
18 | ensure => "present", | 18 | ensure => "present", |
19 | owner => "root", | 19 | owner => "root", |
20 | group => "naemon", | 20 | group => "naemon", |
@@ -27,7 +27,7 @@ class profile::monitoring::commands inherits profile::monitoring { | |||
27 | ensure => "present", | 27 | ensure => "present", |
28 | owner => "naemon", | 28 | owner => "naemon", |
29 | group => "naemon", | 29 | group => "naemon", |
30 | target => "/etc/naemon/objects.cfg", | 30 | target => $objects, |
31 | notify => Service["naemon"], | 31 | notify => Service["naemon"], |
32 | before => Service["naemon"], | 32 | before => Service["naemon"], |
33 | require => File["/etc/naemon"], | 33 | require => File["/etc/naemon"], |
@@ -48,16 +48,16 @@ class profile::monitoring::commands inherits profile::monitoring { | |||
48 | command_line => '$USER1$/check_ntp_time -H 0.arch.pool.ntp.org'; | 48 | command_line => '$USER1$/check_ntp_time -H 0.arch.pool.ntp.org'; |
49 | "check_md_raid": | 49 | "check_md_raid": |
50 | command_line => '$USER2$/check_md_raid', | 50 | command_line => '$USER2$/check_md_raid', |
51 | require => File["/etc/naemon/monitoring-plugins/check_md_raid"]; | 51 | require => File["$plugins/check_md_raid"]; |
52 | "check_command_output": | 52 | "check_command_output": |
53 | command_line => '$USER2$/check_command -c "$ARG1$" -o "$ARG2$" $ARG3$', | 53 | command_line => '$USER2$/check_command -c "$ARG1$" -o "$ARG2$" $ARG3$', |
54 | require => File["/etc/naemon/monitoring-plugins/check_command"]; | 54 | require => File["$plugins/check_command"]; |
55 | "check_postgresql_replication": | 55 | "check_postgresql_replication": |
56 | command_line => '/usr/bin/sudo -u postgres $USER2$/check_postgres_replication "$ARG1$" "$ARG2$" "$ARG3$"', | 56 | command_line => '/usr/bin/sudo -u postgres $USER2$/check_postgres_replication "$ARG1$" "$ARG2$" "$ARG3$"', |
57 | require => File["/etc/naemon/monitoring-plugins/check_postgres_replication"]; | 57 | require => File["$plugins/check_postgres_replication"]; |
58 | "check_last_file_date": | 58 | "check_last_file_date": |
59 | command_line => '$USER2$/check_last_file_date "$ARG1$" "$ARG2$" "$ARG3$"', | 59 | command_line => '$USER2$/check_last_file_date "$ARG1$" "$ARG2$" "$ARG3$"', |
60 | require => File["/etc/naemon/monitoring-plugins/check_last_file_date"], | 60 | require => File["$plugins/check_last_file_date"], |
61 | } | 61 | } |
62 | 62 | ||
63 | unless empty($naemon_url) { | 63 | unless empty($naemon_url) { |
diff --git a/modules/profile/manifests/monitoring/contacts.pp b/modules/profile/manifests/monitoring/contacts.pp index 107af18..a751153 100644 --- a/modules/profile/manifests/monitoring/contacts.pp +++ b/modules/profile/manifests/monitoring/contacts.pp | |||
@@ -1,9 +1,9 @@ | |||
1 | class profile::monitoring::contacts { | 1 | class profile::monitoring::contacts inherits profile::monitoring::params { |
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 => $objects, |
7 | notify => Service["naemon"], | 7 | notify => Service["naemon"], |
8 | before => Service["naemon"], | 8 | before => Service["naemon"], |
9 | require => File["/etc/naemon"], | 9 | require => File["/etc/naemon"], |
diff --git a/modules/profile/manifests/monitoring/hosts.pp b/modules/profile/manifests/monitoring/hosts.pp index 3c8bc73..f7802be 100644 --- a/modules/profile/manifests/monitoring/hosts.pp +++ b/modules/profile/manifests/monitoring/hosts.pp | |||
@@ -1,11 +1,11 @@ | |||
1 | class profile::monitoring::hosts { | 1 | class profile::monitoring::hosts inherits profile::monitoring::params { |
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 => $objects, |
9 | notify => Service["naemon"], | 9 | notify => Service["naemon"], |
10 | before => Service["naemon"], | 10 | before => Service["naemon"], |
11 | require => File["/etc/naemon"], | 11 | require => File["/etc/naemon"], |
@@ -15,7 +15,7 @@ class profile::monitoring::hosts { | |||
15 | ensure => "present", | 15 | ensure => "present", |
16 | owner => "naemon", | 16 | owner => "naemon", |
17 | group => "naemon", | 17 | group => "naemon", |
18 | target => "/etc/naemon/objects.cfg", | 18 | target => $objects, |
19 | notify => Service["naemon"], | 19 | notify => Service["naemon"], |
20 | before => Service["naemon"], | 20 | before => Service["naemon"], |
21 | require => File["/etc/naemon"], | 21 | require => File["/etc/naemon"], |
diff --git a/modules/profile/manifests/monitoring/local_service.pp b/modules/profile/manifests/monitoring/local_service.pp index 9af7c7a..9544fdf 100644 --- a/modules/profile/manifests/monitoring/local_service.pp +++ b/modules/profile/manifests/monitoring/local_service.pp | |||
@@ -4,8 +4,9 @@ define profile::monitoring::local_service ( | |||
4 | Optional[Hash] $master = {}, | 4 | Optional[Hash] $master = {}, |
5 | Optional[Hash] $local = {}, | 5 | Optional[Hash] $local = {}, |
6 | ) { | 6 | ) { |
7 | include profile::monitoring::params | ||
8 | |||
7 | $service_description = $title | 9 | $service_description = $title |
8 | $real_hostname = lookup("base_installation::real_hostname") | ||
9 | 10 | ||
10 | Nagios_service { | 11 | Nagios_service { |
11 | ensure => "present", | 12 | ensure => "present", |
@@ -16,35 +17,6 @@ define profile::monitoring::local_service ( | |||
16 | require => File["/etc/naemon"], | 17 | require => File["/etc/naemon"], |
17 | } | 18 | } |
18 | 19 | ||
19 | $service_generic = { | ||
20 | active_checks_enabled => "1", | ||
21 | check_freshness => "0", | ||
22 | check_interval => "10", | ||
23 | check_period => "24x7", | ||
24 | contact_groups => "admins", | ||
25 | event_handler_enabled => "1", | ||
26 | flap_detection_enabled => "1", | ||
27 | is_volatile => "0", | ||
28 | max_check_attempts => "3", | ||
29 | notification_interval => "60", | ||
30 | notification_options => "w,u,c,r", | ||
31 | notification_period => "24x7", | ||
32 | notifications_enabled => "0", | ||
33 | obsess_over_service => "1", | ||
34 | passive_checks_enabled => "1", | ||
35 | process_perf_data => "1", | ||
36 | retain_nonstatus_information => "1", | ||
37 | retain_status_information => "1", | ||
38 | retry_interval => "2", | ||
39 | } | ||
40 | |||
41 | $service_local = merge($service_generic, { | ||
42 | host_name => $real_hostname, | ||
43 | check_interval => "5", | ||
44 | max_check_attempts => "4", | ||
45 | retry_interval => "1", | ||
46 | }) | ||
47 | |||
48 | $sudos.each |$sudo_name, $content| { | 20 | $sudos.each |$sudo_name, $content| { |
49 | ensure_resource("sudo::conf", $sudo_name, { | 21 | ensure_resource("sudo::conf", $sudo_name, { |
50 | content => $content, | 22 | content => $content, |
@@ -56,17 +28,20 @@ define profile::monitoring::local_service ( | |||
56 | if $services_for_master { | 28 | if $services_for_master { |
57 | $default_local = { | 29 | $default_local = { |
58 | mode => "0644", | 30 | mode => "0644", |
59 | target => "/etc/naemon/services_for_master.cfg", | 31 | target => $::profile::monitoring::params::services_for_master, |
60 | check_interval => $service_local["check_interval"], | 32 | check_interval => $::profile::monitoring::params::service_local["check_interval"], |
61 | retry_interval => $service_local["retry_interval"], | 33 | retry_interval => $::profile::monitoring::params::service_local["retry_interval"], |
62 | host_name => $service_local["host_name"], | 34 | host_name => $::profile::monitoring::params::service_local["host_name"], |
63 | use => "external-service", | 35 | use => "external-passive-service", |
64 | notify => [], | 36 | notify => [], |
65 | } | 37 | } |
66 | $t = "master - " | 38 | $t = "master - " |
67 | $services_key = $master | 39 | $services_key = $master |
68 | } else { | 40 | } else { |
69 | $default_local = merge($service_local, { target => "/etc/naemon/objects.cfg" }) | 41 | $default_local = merge( |
42 | $::profile::monitoring::params::service_local, | ||
43 | { target => $::profile::monitoring::params::objects } | ||
44 | ) | ||
70 | $t = "" | 45 | $t = "" |
71 | $services_key = $local | 46 | $services_key = $local |
72 | } | 47 | } |
diff --git a/modules/profile/manifests/monitoring/params.pp b/modules/profile/manifests/monitoring/params.pp new file mode 100644 index 0000000..a647130 --- /dev/null +++ b/modules/profile/manifests/monitoring/params.pp | |||
@@ -0,0 +1,37 @@ | |||
1 | class profile::monitoring::params { | ||
2 | $real_hostname = lookup("base_installation::real_hostname") | ||
3 | |||
4 | $services_for_master = "/etc/naemon/services_for_master.cfg" | ||
5 | $objects = "/etc/naemon/objects.cfg" | ||
6 | $plugins = "/etc/naemon/monitoring-plugins" | ||
7 | |||
8 | $service_generic = { | ||
9 | active_checks_enabled => "1", | ||
10 | check_freshness => "0", | ||
11 | check_interval => "10", | ||
12 | check_period => "24x7", | ||
13 | contact_groups => "admins", | ||
14 | event_handler_enabled => "1", | ||
15 | flap_detection_enabled => "1", | ||
16 | is_volatile => "0", | ||
17 | max_check_attempts => "3", | ||
18 | notification_interval => "60", | ||
19 | notification_options => "w,u,c,r", | ||
20 | notification_period => "24x7", | ||
21 | notifications_enabled => "0", | ||
22 | obsess_over_service => "1", | ||
23 | passive_checks_enabled => "1", | ||
24 | process_perf_data => "1", | ||
25 | retain_nonstatus_information => "1", | ||
26 | retain_status_information => "1", | ||
27 | retry_interval => "2", | ||
28 | } | ||
29 | |||
30 | $service_local = merge($service_generic, { | ||
31 | host_name => $real_hostname, | ||
32 | check_interval => "5", | ||
33 | max_check_attempts => "4", | ||
34 | retry_interval => "1", | ||
35 | }) | ||
36 | |||
37 | } | ||
diff --git a/modules/profile/manifests/monitoring/times.pp b/modules/profile/manifests/monitoring/times.pp index 25bf86b..42f5d9c 100644 --- a/modules/profile/manifests/monitoring/times.pp +++ b/modules/profile/manifests/monitoring/times.pp | |||
@@ -1,9 +1,9 @@ | |||
1 | class profile::monitoring::times { | 1 | class profile::monitoring::times inherits profile::monitoring::params { |
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 => $objects, |
7 | notify => Service["naemon"], | 7 | notify => Service["naemon"], |
8 | before => Service["naemon"], | 8 | before => Service["naemon"], |
9 | require => File["/etc/naemon"], | 9 | require => File["/etc/naemon"], |
diff --git a/modules/profile/templates/monitoring/naemon.cfg.erb b/modules/profile/templates/monitoring/naemon.cfg.erb index 78bada3..bacbe04 100644 --- a/modules/profile/templates/monitoring/naemon.cfg.erb +++ b/modules/profile/templates/monitoring/naemon.cfg.erb | |||
@@ -26,7 +26,7 @@ log_file=/var/log/naemon/naemon.log | |||
26 | # if you wish (as shown below), or keep them all in a single config file. | 26 | # if you wish (as shown below), or keep them all in a single config file. |
27 | 27 | ||
28 | # You can specify individual object config files as shown below: | 28 | # You can specify individual object config files as shown below: |
29 | cfg_file=/etc/naemon/objects.cfg | 29 | cfg_file=<%= @objects %> |
30 | #cfg_file=/etc/naemon/objects/commands.cfg | 30 | #cfg_file=/etc/naemon/objects/commands.cfg |
31 | #cfg_file=/etc/naemon/objects/contacts.cfg | 31 | #cfg_file=/etc/naemon/objects/contacts.cfg |
32 | #cfg_file=/etc/naemon/objects/timeperiods.cfg | 32 | #cfg_file=/etc/naemon/objects/timeperiods.cfg |
diff --git a/modules/profile/templates/monitoring/resource.cfg.erb b/modules/profile/templates/monitoring/resource.cfg.erb index 7da5e66..5a5c3ee 100644 --- a/modules/profile/templates/monitoring/resource.cfg.erb +++ b/modules/profile/templates/monitoring/resource.cfg.erb | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | # Sets $USER1$ to be the path to the plugins | 21 | # Sets $USER1$ to be the path to the plugins |
22 | $USER1$=/usr/lib/monitoring-plugins | 22 | $USER1$=/usr/lib/monitoring-plugins |
23 | $USER2$=/etc/naemon/monitoring-plugins | 23 | $USER2$=<%= @plugins %> |
24 | 24 | ||
25 | # Sets $USER2$ to be the path to event handlers | 25 | # Sets $USER2$ to be the path to event handlers |
26 | #$USER2$=/usr/lib/monitoring-plugins/eventhandlers | 26 | #$USER2$=/usr/lib/monitoring-plugins/eventhandlers |