diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-08 21:51:30 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-07-10 10:26:39 +0200 |
commit | b5305b5cad5cbb0a2c072b29f2d4dc05126c39d4 (patch) | |
tree | 8fb1844be8b9e68d62ee2ede54c1bb39d27d4c30 /modules/profile/manifests/monitoring | |
parent | 6962463657db999c33f1aabe60e0567be218918d (diff) | |
download | Puppet-b5305b5cad5cbb0a2c072b29f2d4dc05126c39d4.tar.gz Puppet-b5305b5cad5cbb0a2c072b29f2d4dc05126c39d4.tar.zst Puppet-b5305b5cad5cbb0a2c072b29f2d4dc05126c39d4.zip |
Add postgresql monitoring
Diffstat (limited to 'modules/profile/manifests/monitoring')
-rw-r--r-- | modules/profile/manifests/monitoring/commands.pp | 40 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/local_service.pp | 16 | ||||
-rw-r--r-- | modules/profile/manifests/monitoring/services.pp | 24 |
3 files changed, 45 insertions, 35 deletions
diff --git a/modules/profile/manifests/monitoring/commands.pp b/modules/profile/manifests/monitoring/commands.pp index a25f7b3..4ccc816 100644 --- a/modules/profile/manifests/monitoring/commands.pp +++ b/modules/profile/manifests/monitoring/commands.pp | |||
@@ -3,25 +3,24 @@ class profile::monitoring::commands inherits profile::monitoring { | |||
3 | 3 | ||
4 | file { "/etc/naemon/monitoring-plugins": | 4 | file { "/etc/naemon/monitoring-plugins": |
5 | ensure => "directory", | 5 | ensure => "directory", |
6 | owner => "naemon", | 6 | owner => "root", |
7 | group => "naemon", | ||
8 | mode => "0700", | ||
9 | } | ||
10 | |||
11 | file { "/etc/naemon/monitoring-plugins/check_command": | ||
12 | ensure => "present", | ||
13 | owner => "naemon", | ||
14 | group => "naemon", | 7 | group => "naemon", |
15 | mode => "0700", | 8 | mode => "0755", |
16 | source => "puppet:///modules/profile/monitoring/check_command", | ||
17 | } | 9 | } |
18 | 10 | ||
19 | file { "/etc/naemon/monitoring-plugins/check_md_raid": | 11 | [ |
20 | ensure => "present", | 12 | "check_command", |
21 | owner => "naemon", | 13 | "check_md_raid", |
22 | group => "naemon", | 14 | "check_postgres_replication", |
23 | mode => "0700", | 15 | "check_last_file_date", |
24 | source => "puppet:///modules/profile/monitoring/check_md_raid", | 16 | ].each |$file| { |
17 | file { "/etc/naemon/monitoring-plugins/$file": | ||
18 | ensure => "present", | ||
19 | owner => "root", | ||
20 | group => "naemon", | ||
21 | mode => "0755", | ||
22 | source => "puppet:///modules/profile/monitoring/$file", | ||
23 | } | ||
25 | } | 24 | } |
26 | 25 | ||
27 | Nagios_command { | 26 | Nagios_command { |
@@ -48,10 +47,17 @@ class profile::monitoring::commands inherits profile::monitoring { | |||
48 | "check_ntp": | 47 | "check_ntp": |
49 | 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'; |
50 | "check_md_raid": | 49 | "check_md_raid": |
51 | command_line => '$USER2$/check_md_raid'; | 50 | command_line => '$USER2$/check_md_raid', |
51 | require => File["/etc/naemon/monitoring-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["/etc/naemon/monitoring-plugins/check_command"]; |
55 | "check_postgresql_replication": | ||
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"]; | ||
58 | "check_last_file_date": | ||
59 | command_line => '$USER2$/check_last_file_date "$ARG1$" "$ARG2$" "$ARG3$"', | ||
60 | require => File["/etc/naemon/monitoring-plugins/check_last_file_date"], | ||
55 | } | 61 | } |
56 | 62 | ||
57 | unless empty($naemon_url) { | 63 | unless empty($naemon_url) { |
diff --git a/modules/profile/manifests/monitoring/local_service.pp b/modules/profile/manifests/monitoring/local_service.pp index 3b39d1f..0caf72e 100644 --- a/modules/profile/manifests/monitoring/local_service.pp +++ b/modules/profile/manifests/monitoring/local_service.pp | |||
@@ -1,4 +1,5 @@ | |||
1 | define profile::monitoring::local_service ( | 1 | define profile::monitoring::local_service ( |
2 | Optional[Hash] $sudos = {}, | ||
2 | Optional[Hash] $common = {}, | 3 | Optional[Hash] $common = {}, |
3 | Optional[Hash] $master = {}, | 4 | Optional[Hash] $master = {}, |
4 | Optional[Hash] $local = {}, | 5 | Optional[Hash] $local = {}, |
@@ -6,6 +7,15 @@ define profile::monitoring::local_service ( | |||
6 | $service_description = $title | 7 | $service_description = $title |
7 | $real_hostname = lookup("base_installation::real_hostname") | 8 | $real_hostname = lookup("base_installation::real_hostname") |
8 | 9 | ||
10 | Nagios_service { | ||
11 | ensure => "present", | ||
12 | owner => "naemon", | ||
13 | group => "naemon", | ||
14 | notify => Service["naemon"], | ||
15 | before => Service["naemon"], | ||
16 | require => File["/etc/naemon"], | ||
17 | } | ||
18 | |||
9 | $service_generic = { | 19 | $service_generic = { |
10 | active_checks_enabled => "1", | 20 | active_checks_enabled => "1", |
11 | check_freshness => "0", | 21 | check_freshness => "0", |
@@ -35,6 +45,12 @@ define profile::monitoring::local_service ( | |||
35 | retry_interval => "1", | 45 | retry_interval => "1", |
36 | }) | 46 | }) |
37 | 47 | ||
48 | $sudos.each |$sudo_name, $content| { | ||
49 | sudo::conf { $sudo_name: | ||
50 | content => $content, | ||
51 | before => Nagios_service[$service_description], | ||
52 | } | ||
53 | } | ||
38 | 54 | ||
39 | [true, false].each |$services_for_master| { | 55 | [true, false].each |$services_for_master| { |
40 | if $services_for_master { | 56 | if $services_for_master { |
diff --git a/modules/profile/manifests/monitoring/services.pp b/modules/profile/manifests/monitoring/services.pp index 6e59ab1..b20a352 100644 --- a/modules/profile/manifests/monitoring/services.pp +++ b/modules/profile/manifests/monitoring/services.pp | |||
@@ -1,21 +1,5 @@ | |||
1 | class profile::monitoring::services { | 1 | class profile::monitoring::services { |
2 | 2 | ||
3 | Nagios_service { | ||
4 | ensure => "present", | ||
5 | owner => "naemon", | ||
6 | group => "naemon", | ||
7 | notify => Service["naemon"], | ||
8 | before => Service["naemon"], | ||
9 | require => File["/etc/naemon"], | ||
10 | } | ||
11 | |||
12 | sudo::conf { | ||
13 | default: | ||
14 | sudo_file_name => "naemon"; | ||
15 | 'naemon-fail2ban': | ||
16 | content => "naemon ALL=(root) NOPASSWD: /usr/bin/fail2ban-client ping"; | ||
17 | } | ||
18 | |||
19 | profile::monitoring::local_service { | 3 | profile::monitoring::local_service { |
20 | "Size on root partition": | 4 | "Size on root partition": |
21 | local => { | 5 | local => { |
@@ -34,9 +18,11 @@ class profile::monitoring::services { | |||
34 | check_command => "check_local_swap!20!10", | 18 | check_command => "check_local_swap!20!10", |
35 | }; | 19 | }; |
36 | "fail2ban is active": | 20 | "fail2ban is active": |
37 | local => { | 21 | sudos => { |
22 | "naemon-fail2ban" => "naemon ALL=(root) NOPASSWD: /usr/bin/fail2ban-client ping", | ||
23 | }, | ||
24 | local => { | ||
38 | check_command => "check_command_output!fail2ban-client ping!pong!-r root", | 25 | check_command => "check_command_output!fail2ban-client ping!pong!-r root", |
39 | require => Sudo::Conf["naemon-fail2ban"], | ||
40 | }; | 26 | }; |
41 | "NTP is activated and working": | 27 | "NTP is activated and working": |
42 | local => { | 28 | local => { |
@@ -50,4 +36,6 @@ class profile::monitoring::services { | |||
50 | check_command => "check_md_raid", | 36 | check_command => "check_md_raid", |
51 | }; | 37 | }; |
52 | } | 38 | } |
39 | |||
40 | Profile::Monitoring::Local_service <| |> | ||
53 | } | 41 | } |