]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - modules/profile/manifests/monitoring/local_service.pp
Add postgresql monitoring
[perso/Immae/Projets/Puppet.git] / modules / profile / manifests / monitoring / local_service.pp
1 define profile::monitoring::local_service (
2 Optional[Hash] $sudos = {},
3 Optional[Hash] $common = {},
4 Optional[Hash] $master = {},
5 Optional[Hash] $local = {},
6 ) {
7 $service_description = $title
8 $real_hostname = lookup("base_installation::real_hostname")
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
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| {
49 sudo::conf { $sudo_name:
50 content => $content,
51 before => Nagios_service[$service_description],
52 }
53 }
54
55 [true, false].each |$services_for_master| {
56 if $services_for_master {
57 $default_local = {
58 mode => "0644",
59 target => "/etc/naemon/services_for_master.cfg",
60 check_interval => $service_local["check_interval"],
61 retry_interval => $service_local["retry_interval"],
62 host_name => $service_local["host_name"],
63 use => "external-service",
64 notify => [],
65 }
66 $t = "master - "
67 $services_key = $master
68 } else {
69 $default_local = merge($service_local, { target => "/etc/naemon/objects.cfg" })
70 $t = ""
71 $services_key = $local
72 }
73
74 $hash = merge($default_local, $common, $services_key)
75
76 nagios_service { "$t$service_description":
77 service_description => $service_description,
78 * => $hash
79 }
80 }
81 }