class profile::monitoring (
Optional[String] $naemon_url = undef,
Optional[String] $naemon_token = undef,
-) {
+) inherits profile::monitoring::params {
ensure_packages(["naemon", "cnagios"])
file { "/etc/naemon":
content => template("profile/monitoring/naemon.cfg.erb"),
}
->
- file { "/etc/naemon/objects.cfg":
+ file { $objects:
ensure => "file",
owner => "naemon",
group => "naemon",
class profile::monitoring::commands inherits profile::monitoring {
ensure_packages(["monitoring-plugins"])
- file { "/etc/naemon/monitoring-plugins":
+ file { $plugins:
ensure => "directory",
owner => "root",
group => "naemon",
"check_postgres_replication",
"check_last_file_date",
].each |$file| {
- file { "/etc/naemon/monitoring-plugins/$file":
+ file { "$plugins/$file":
ensure => "present",
owner => "root",
group => "naemon",
ensure => "present",
owner => "naemon",
group => "naemon",
- target => "/etc/naemon/objects.cfg",
+ target => $objects,
notify => Service["naemon"],
before => Service["naemon"],
require => File["/etc/naemon"],
command_line => '$USER1$/check_ntp_time -H 0.arch.pool.ntp.org';
"check_md_raid":
command_line => '$USER2$/check_md_raid',
- require => File["/etc/naemon/monitoring-plugins/check_md_raid"];
+ require => File["$plugins/check_md_raid"];
"check_command_output":
command_line => '$USER2$/check_command -c "$ARG1$" -o "$ARG2$" $ARG3$',
- require => File["/etc/naemon/monitoring-plugins/check_command"];
+ require => File["$plugins/check_command"];
"check_postgresql_replication":
command_line => '/usr/bin/sudo -u postgres $USER2$/check_postgres_replication "$ARG1$" "$ARG2$" "$ARG3$"',
- require => File["/etc/naemon/monitoring-plugins/check_postgres_replication"];
+ require => File["$plugins/check_postgres_replication"];
"check_last_file_date":
command_line => '$USER2$/check_last_file_date "$ARG1$" "$ARG2$" "$ARG3$"',
- require => File["/etc/naemon/monitoring-plugins/check_last_file_date"],
+ require => File["$plugins/check_last_file_date"],
}
unless empty($naemon_url) {
-class profile::monitoring::contacts {
+class profile::monitoring::contacts inherits profile::monitoring::params {
Nagios_contactgroup {
ensure => "present",
owner => "naemon",
group => "naemon",
- target => "/etc/naemon/objects.cfg",
+ target => $objects,
notify => Service["naemon"],
before => Service["naemon"],
require => File["/etc/naemon"],
-class profile::monitoring::hosts {
+class profile::monitoring::hosts inherits profile::monitoring::params {
$real_hostname = lookup("base_installation::real_hostname")
Nagios_hostgroup {
ensure => "present",
owner => "naemon",
group => "naemon",
- target => "/etc/naemon/objects.cfg",
+ target => $objects,
notify => Service["naemon"],
before => Service["naemon"],
require => File["/etc/naemon"],
ensure => "present",
owner => "naemon",
group => "naemon",
- target => "/etc/naemon/objects.cfg",
+ target => $objects,
notify => Service["naemon"],
before => Service["naemon"],
require => File["/etc/naemon"],
Optional[Hash] $master = {},
Optional[Hash] $local = {},
) {
+ include profile::monitoring::params
+
$service_description = $title
- $real_hostname = lookup("base_installation::real_hostname")
Nagios_service {
ensure => "present",
require => File["/etc/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 => "0",
- 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",
- })
-
$sudos.each |$sudo_name, $content| {
ensure_resource("sudo::conf", $sudo_name, {
content => $content,
if $services_for_master {
$default_local = {
mode => "0644",
- target => "/etc/naemon/services_for_master.cfg",
- check_interval => $service_local["check_interval"],
- retry_interval => $service_local["retry_interval"],
- host_name => $service_local["host_name"],
- use => "external-service",
+ target => $::profile::monitoring::params::services_for_master,
+ check_interval => $::profile::monitoring::params::service_local["check_interval"],
+ retry_interval => $::profile::monitoring::params::service_local["retry_interval"],
+ host_name => $::profile::monitoring::params::service_local["host_name"],
+ use => "external-passive-service",
notify => [],
}
$t = "master - "
$services_key = $master
} else {
- $default_local = merge($service_local, { target => "/etc/naemon/objects.cfg" })
+ $default_local = merge(
+ $::profile::monitoring::params::service_local,
+ { target => $::profile::monitoring::params::objects }
+ )
$t = ""
$services_key = $local
}
--- /dev/null
+class profile::monitoring::params {
+ $real_hostname = lookup("base_installation::real_hostname")
+
+ $services_for_master = "/etc/naemon/services_for_master.cfg"
+ $objects = "/etc/naemon/objects.cfg"
+ $plugins = "/etc/naemon/monitoring-plugins"
+
+ $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 => "0",
+ 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",
+ })
+
+}
-class profile::monitoring::times {
+class profile::monitoring::times inherits profile::monitoring::params {
Nagios_timeperiod {
ensure => "present",
owner => "naemon",
group => "naemon",
- target => "/etc/naemon/objects.cfg",
+ target => $objects,
notify => Service["naemon"],
before => Service["naemon"],
require => File["/etc/naemon"],
# if you wish (as shown below), or keep them all in a single config file.
# You can specify individual object config files as shown below:
-cfg_file=/etc/naemon/objects.cfg
+cfg_file=<%= @objects %>
#cfg_file=/etc/naemon/objects/commands.cfg
#cfg_file=/etc/naemon/objects/contacts.cfg
#cfg_file=/etc/naemon/objects/timeperiods.cfg
# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/lib/monitoring-plugins
-$USER2$=/etc/naemon/monitoring-plugins
+$USER2$=<%= @plugins %>
# Sets $USER2$ to be the path to event handlers
#$USER2$=/usr/lib/monitoring-plugins/eventhandlers