From 79122eec1e9fd411394572bc6a93d5a6ede9e34f Mon Sep 17 00:00:00 2001 From: Ivan Ponovarev Date: Fri, 1 Feb 2013 19:02:11 +0400 Subject: [PATCH] centos support --- .../files/common/etc/nagios/nrpe.cfg.erb | 228 ++++++++++++++++++ .../files/common/etc/nagios/nrpe.d/disk.cfg | 2 +- .../files/common/etc/nagios/nrpe.d/load.cfg | 6 - .../files/common/etc/nagios/nrpe.d/mailq.cfg | 6 - .../common/etc/nagios/nrpe.d/openstack.cfg | 17 -- .../files/common/etc/nagios/nrpe.d/procs.cfg | 7 - .../files/common/etc/nagios/nrpe.d/smart.cfg | 6 - .../files/common/etc/nagios/nrpe.d/swap.cfg | 6 - .../files/common/etc/nagios/nrpe.d/users.cfg | 6 - deployment/puppet/nagios/manifests/command.pp | 9 + .../nagios/manifests/command/commands.pp | 2 +- .../nagios/manifests/contact/contactgroups.pp | 2 +- .../nagios/manifests/contact/contacts.pp | 2 +- .../nagios/manifests/host/hostextinfo.pp | 10 +- .../nagios/manifests/host/hostgroups.pp | 2 +- .../puppet/nagios/manifests/host/hosts.pp | 2 +- deployment/puppet/nagios/manifests/init.pp | 47 ++-- deployment/puppet/nagios/manifests/master.pp | 168 ++++++------- .../puppet/nagios/manifests/nrpeconfig.pp | 4 +- deployment/puppet/nagios/manifests/params.pp | 39 +++ .../nagios/manifests/service/servicegroups.pp | 2 +- .../nagios/manifests/service/services.pp | 2 +- .../common/etc/nagios/nrpe.d/commands.cfg.erb | 12 + .../templates/openstack/openstack.cfg.erb | 20 ++ .../templates/openstack/sample_hosts.cfg | 3 + .../templates/openstack/templates.cfg.erb | 4 + 26 files changed, 435 insertions(+), 179 deletions(-) create mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.cfg.erb delete mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/load.cfg delete mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/mailq.cfg delete mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/openstack.cfg delete mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/procs.cfg delete mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/smart.cfg delete mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/swap.cfg delete mode 100644 deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/users.cfg create mode 100644 deployment/puppet/nagios/templates/common/etc/nagios/nrpe.d/commands.cfg.erb create mode 100644 deployment/puppet/nagios/templates/openstack/openstack.cfg.erb diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.cfg.erb b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.cfg.erb new file mode 100644 index 0000000000..a5657253bf --- /dev/null +++ b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.cfg.erb @@ -0,0 +1,228 @@ +# +# THIS FILE IS MANAGED BY PUPPET +# <%= file %> +# + +############################################################################# +# Sample NRPE Config File +# Written by: Ethan Galstad (nagios@nagios.org) +# +# +# NOTES: +# This is a sample configuration file for the NRPE daemon. It needs to be +# located on the remote host that is running the NRPE daemon, not the host +# from which the check_nrpe client is being executed. +############################################################################# + + +# LOG FACILITY +# The syslog facility that should be used for logging purposes. + +log_facility=daemon + + + +# PID FILE +# The name of the file in which the NRPE daemon should write it's process ID +# number. The file is only written if the NRPE daemon is started by the root +# user and is running in standalone mode. + +pid_file=/var/run/nagios/nrpe.pid + + + +# PORT NUMBER +# Port number we should wait for connections on. +# NOTE: This must be a non-priviledged port (i.e. > 1024). +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +server_port=5666 + + + +# SERVER ADDRESS +# Address that nrpe should bind to in case there are more than one interface +# and you do not want nrpe to bind on all interfaces. +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +#server_address=127.0.0.1 + + + +# NRPE USER +# This determines the effective user that the NRPE daemon should run as. +# You can either supply a username or a UID. +# +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +nrpe_user=nagios + + + +# NRPE GROUP +# This determines the effective group that the NRPE daemon should run as. +# You can either supply a group name or a GID. +# +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +nrpe_group=nagios + + + +# ALLOWED HOST ADDRESSES +# This is an optional comma-delimited list of IP address or hostnames +# that are allowed to talk to the NRPE daemon. +# +# Note: The daemon only does rudimentary checking of the client's IP +# address. I would highly recommend adding entries in your /etc/hosts.allow +# file to allow only the specified host to connect to the port +# you are running this daemon on. +# +# NOTE: This option is ignored if NRPE is running under either inetd or xinetd + +<% if whitelist.kind_of?(Array) -%> +allowed_hosts=<%= whitelist.join(",") %> +<% else -%> +allowed_hosts=<%= whitelist %> +<% end -%> + + + +# COMMAND ARGUMENT PROCESSING +# This option determines whether or not the NRPE daemon will allow clients +# to specify arguments to commands that are executed. This option only works +# if the daemon was configured with the --enable-command-args configure script +# option. +# +# *** ENABLING THIS OPTION IS A SECURITY RISK! *** +# Read the SECURITY file for information on some of the security implications +# of enabling this variable. +# +# Values: 0=do not allow arguments, 1=allow command arguments + +dont_blame_nrpe=1 + + + +# COMMAND PREFIX +# This option allows you to prefix all commands with a user-defined string. +# A space is automatically added between the specified prefix string and the +# command line from the command definition. +# +# *** THIS EXAMPLE MAY POSE A POTENTIAL SECURITY RISK, SO USE WITH CAUTION! *** +# Usage scenario: +# Execute restricted commmands using sudo. For this to work, you need to add +# the nagios user to your /etc/sudoers. An example entry for alllowing +# execution of the plugins from might be: +# +# nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/ +# +# This lets the nagios user run all commands in that directory (and only them) +# without asking for a password. If you do this, make sure you don't give +# random users write access to that directory or its contents! + +# command_prefix=/usr/bin/sudo + + + +# DEBUGGING OPTION +# This option determines whether or not debugging messages are logged to the +# syslog facility. +# Values: 0=debugging off, 1=debugging on + +debug=0 + + + +# COMMAND TIMEOUT +# This specifies the maximum number of seconds that the NRPE daemon will +# allow plugins to finish executing before killing them off. + +command_timeout=60 + + + +# CONNECTION TIMEOUT +# This specifies the maximum number of seconds that the NRPE daemon will +# wait for a connection to be established before exiting. This is sometimes +# seen where a network problem stops the SSL being established even though +# all network sessions are connected. This causes the nrpe daemons to +# accumulate, eating system resources. Do not set this too low. + +connection_timeout=300 + + + +# WEEK RANDOM SEED OPTION +# This directive allows you to use SSL even if your system does not have +# a /dev/random or /dev/urandom (on purpose or because the necessary patches +# were not applied). The random number generator will be seeded from a file +# which is either a file pointed to by the environment valiable $RANDFILE +# or $HOME/.rnd. If neither exists, the pseudo random number generator will +# be initialized and a warning will be issued. +# Values: 0=only seed from /dev/[u]random, 1=also seed from weak randomness + +#allow_weak_random_seed=1 + + + +# INCLUDE CONFIG FILE +# This directive allows you to include definitions from an external config file. + +#include= + + + +# INCLUDE CONFIG DIRECTORY +# This directive allows you to include definitions from config files (with a +# .cfg extension) in one or more directories (with recursion). + +#include_dir= +#include_dir= +include_dir=<%= include_dir %> + + +# COMMAND DEFINITIONS +# Command definitions that this daemon will run. Definitions +# are in the following format: +# +# command[]= +# +# When the daemon receives a request to return the results of +# it will execute the command specified by the argument. +# +# Unlike Nagios, the command line cannot contain macros - it must be +# typed exactly as it should be executed. +# +# Note: Any plugins that are used in the command lines must reside +# on the machine that this daemon is running on! The examples below +# assume that you have plugins installed in a /usr/local/nagios/libexec +# directory. Also note that you will have to modify the definitions below +# to match the argument format the plugins expect. Remember, these are +# examples only! + + +# The following examples use hardcoded command arguments... + +#command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10 +#command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 +#command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1 +#command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z +#command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200 + + +# The following examples allow user-supplied arguments and can +# only be used if the NRPE daemon was compiled with support for +# command arguments *AND* the dont_blame_nrpe directive in this +# config file is set to '1'. This poses a potential security risk, so +# make sure you read the SECURITY file before doing this. + +#command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$ +#command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$ +#command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ +#command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ + +# +# local configuration: +# if you'd prefer, you can instead place directives here +include=/etc/nagios/nrpe_local.cfg diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/disk.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/disk.cfg index f7a1de666f..58cadc21c6 100644 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/disk.cfg +++ b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/disk.cfg @@ -3,4 +3,4 @@ # /etc/puppet/modules/production/nagios/files/common/etc/nagios/nrpe.d/disk.cfg # -command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ +command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/load.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/load.cfg deleted file mode 100644 index e0773f1e77..0000000000 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/load.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# -# THIS FILE IS MANAGED BY PUPPET -# /etc/puppet/modules/production/nagios/files/common/etc/nagios/nrpe.d/load.cfg -# - -command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$,$ARG2$,$ARG3$ -c $ARG4$,$ARG5$,$ARG6$ diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/mailq.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/mailq.cfg deleted file mode 100644 index 1e21c5cace..0000000000 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/mailq.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# -# THIS FILE IS MANAGED BY PUPPET -# /etc/puppet/modules/production/nagios/files/common/etc/nagios/nrpe.d/mailq.cfg -# - -command[check_mailq]=/usr/lib/nagios/plugins/check_mailq -w $ARG1$ -c $ARG2$ diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/openstack.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/openstack.cfg deleted file mode 100644 index 816f5cd3fe..0000000000 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/openstack.cfg +++ /dev/null @@ -1,17 +0,0 @@ -command[check_nova_compute]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C nova-compute -command[check_nova_network]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C nova-network -command[check_nova_scheduler]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C nova-scheduler -command[check_nova_consoleauth]=/usr/lib/nagios/plugins/check_procs -c 1:10 -a nova-consoleauth -command[check_nova_cert]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C nova-cert -command[check_cinder_scheduler]=/usr/lib/nagios/plugins/check_procs -c 1:10 -a cinder-scheduler -command[check_cinder_volume]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C cinder-volume -command[check_haproxy]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C haproxy -command[check_memcached]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C memcached -command[check_glance_registry]=/usr/lib/nagios/plugins/check_procs -c 1:10 -C glance-registry -command[check_nova_novncproxy]=/usr/lib/nagios/plugins/check_procs -c 1:10 -a nova-novncproxy -command[check_swift_proxy]=/usr/lib/nagios/plugins/check_procs -c 1:10 -a swift-proxy-server -command[check_swift_account]=/usr/lib/nagios/plugins/check_procs -c 1:10 -a swift-account-server -command[check_swift_object]=/usr/lib/nagios/plugins/check_procs -c 1:10 -a swift-object-server -command[check_swift_container]=/usr/lib/nagios/plugins/check_procs -c 1:10 -a swift-container-server -command[check_swift_ring]=/usr/lib/nagios/plugins/check_os_swiftrecon objmd5 -command[check_libvirt]=/usr/lib/nagios/plugins/check_os_libvirt connect -H 127.0.0.1 -m qemu+tcp diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/procs.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/procs.cfg deleted file mode 100644 index 098942da9c..0000000000 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/procs.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# -# THIS FILE IS MANAGED BY PUPPET -# /etc/puppet/modules/production/nagios/files/common/etc/nagios/nrpe.d/procs.cfg -# - -command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -command[check_procs_zombie]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s Z diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/smart.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/smart.cfg deleted file mode 100644 index 74d24a231e..0000000000 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/smart.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# -# THIS FILE IS MANAGED BY PUPPET -# /etc/puppet/modules/production/nagios/files/common/etc/nagios/nrpe.d/smart.cfg -# - -command[check_ide_smart]=sudo /usr/lib/nagios/plugins/check_ide_smart -d $ARG1$ -n diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/swap.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/swap.cfg deleted file mode 100644 index f1014bd722..0000000000 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/swap.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# -# THIS FILE IS MANAGED BY PUPPET -# /etc/puppet/modules/production/nagios/files/common/etc/nagios/nrpe.d/swap.cfg -# - -command[check_swap]=/usr/lib/nagios/plugins/check_swap -w $ARG1$ -c $ARG2$ diff --git a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/users.cfg b/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/users.cfg deleted file mode 100644 index 87320b7312..0000000000 --- a/deployment/puppet/nagios/files/common/etc/nagios/nrpe.d/users.cfg +++ /dev/null @@ -1,6 +0,0 @@ -# -# THIS FILE IS MANAGED BY PUPPET -# /etc/puppet/modules/production/nagios/files/common/etc/nagios/nrpe.d/users.cfg -# - -command[check_users]=/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$ diff --git a/deployment/puppet/nagios/manifests/command.pp b/deployment/puppet/nagios/manifests/command.pp index 6088c4e1d7..4c52454091 100644 --- a/deployment/puppet/nagios/manifests/command.pp +++ b/deployment/puppet/nagios/manifests/command.pp @@ -4,6 +4,15 @@ class nagios::command inherits nagios::master { command => '$USER1$/check_ntp_time -H $HOSTADDRESS$', } + if $::osfamily == 'RedHat' { + nagios::command::commands { + 'check_nrpe': + command => '/usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$'; + 'check_nrpe_1arg': + command => '/usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$'; + } + } + # Remote nagios::command::commands { 'check_http_api': diff --git a/deployment/puppet/nagios/manifests/command/commands.pp b/deployment/puppet/nagios/manifests/command/commands.pp index ae5bf7aa08..9938737658 100644 --- a/deployment/puppet/nagios/manifests/command/commands.pp +++ b/deployment/puppet/nagios/manifests/command/commands.pp @@ -3,6 +3,6 @@ define nagios::command::commands( $command = false ) { @@nagios_command { $name: ensure => present, command_line => $command, - target => "/etc/nagios3/${proj_name}/commands.cfg", + target => "/etc/${nagios::params::masterdir}/${proj_name}/commands.cfg", } } diff --git a/deployment/puppet/nagios/manifests/contact/contactgroups.pp b/deployment/puppet/nagios/manifests/contact/contactgroups.pp index f9a9ed88f2..790ab68aaa 100644 --- a/deployment/puppet/nagios/manifests/contact/contactgroups.pp +++ b/deployment/puppet/nagios/manifests/contact/contactgroups.pp @@ -6,6 +6,6 @@ notify {$name:} nagios_contactgroup { $name: ensure => present, alias => $alias, - target => "/etc/nagios3/${proj_name}/contactgroups.cfg", + target => "/etc/${nagios::params::masterdir}/${proj_name}/contactgroups.cfg", } } diff --git a/deployment/puppet/nagios/manifests/contact/contacts.pp b/deployment/puppet/nagios/manifests/contact/contacts.pp index 82ade0e752..55e2ef1d06 100644 --- a/deployment/puppet/nagios/manifests/contact/contacts.pp +++ b/deployment/puppet/nagios/manifests/contact/contacts.pp @@ -15,6 +15,6 @@ $group = false, email => $t_email, contactgroups => $group, use => 'generic-contact', - target => "/etc/nagios3/${proj_name}/contacts.cfg", + target => "/etc/${nagios::params::masterdir}/${proj_name}/contacts.cfg", } } diff --git a/deployment/puppet/nagios/manifests/host/hostextinfo.pp b/deployment/puppet/nagios/manifests/host/hostextinfo.pp index 44e4502c72..f3e15dc4e2 100644 --- a/deployment/puppet/nagios/manifests/host/hostextinfo.pp +++ b/deployment/puppet/nagios/manifests/host/hostextinfo.pp @@ -1,15 +1,13 @@ define nagios::host::hostextinfo() { - $distro = inline_template("<%= scope.lookupvar('::lsbdistid').downcase -%>") - @@nagios_hostextinfo { $name: ensure => present, host_name => $::fqdn, notes => $::lsbdistid, - icon_image => "base/${distro}.png", + icon_image => "base/${nagios::params::distro}.png", icon_image_alt => $::lsbdistid, - statusmap_image => "base/${distro}.gd2", - vrml_image => "${distro}.png", - target => "/etc/nagios3/${proj_name}/${::hostname}_hostextinfo.cfg", + statusmap_image => "base/${nagios::params::distro}.gd2", + vrml_image => "${nagios::params::distro}.png", + target => "/etc/${nagios::params::masterdir}/${proj_name}/${::hostname}_hostextinfo.cfg", } } diff --git a/deployment/puppet/nagios/manifests/host/hostgroups.pp b/deployment/puppet/nagios/manifests/host/hostgroups.pp index c924b79009..e30a5ee7a1 100644 --- a/deployment/puppet/nagios/manifests/host/hostgroups.pp +++ b/deployment/puppet/nagios/manifests/host/hostgroups.pp @@ -5,6 +5,6 @@ define nagios::host::hostgroups() { nagios_hostgroup { $name: ensure => present, alias => $alias, - target => "/etc/nagios3/${proj_name}/hostgroups.cfg", + target => "/etc/${nagios::params::masterdir}/${proj_name}/hostgroups.cfg", } } diff --git a/deployment/puppet/nagios/manifests/host/hosts.pp b/deployment/puppet/nagios/manifests/host/hosts.pp index e9d0cbcd9c..0fa92e4153 100644 --- a/deployment/puppet/nagios/manifests/host/hosts.pp +++ b/deployment/puppet/nagios/manifests/host/hosts.pp @@ -7,6 +7,6 @@ define nagios::host::hosts() { use => 'default-host', address => $::fqdn, host_name => $::fqdn, - target => "/etc/nagios3/${proj_name}/${::hostname}_hosts.cfg", + target => "/etc/${nagios::params::masterdir}/${proj_name}/${::hostname}_hosts.cfg", } } diff --git a/deployment/puppet/nagios/manifests/init.pp b/deployment/puppet/nagios/manifests/init.pp index a1ba1df3ef..baa7b8b6e9 100644 --- a/deployment/puppet/nagios/manifests/init.pp +++ b/deployment/puppet/nagios/manifests/init.pp @@ -22,38 +22,43 @@ $whitelist = '127.0.0.1', include_dir => "/etc/nagios/${proj_name}", } - file { "/etc/nagios/${proj_name}": + package { $nagios::params::nrpepkg: + ensure => present, + } + + File { force => true, purge => true, recurse => true, owner => root, group => root, mode => '0644', - notify => Service['nagios-nrpe-server'], - source => 'puppet:///modules/nagios/common/etc/nagios/nrpe.d', - require => Package['nagios-nrpe-server'], } - file { '/usr/local/lib/nagios': - force => true, - purge => true, - recurse => true, - owner => root, - group => staff, + file { "/etc/nagios/${proj_name}/openstack.cfg": + content => template('nagios/openstack/openstack.cfg.erb'), + notify => Service[$nagios::params::nrpeservice], + require => Package[$nagios::params::nrpepkg], + } + + file { "/etc/nagios/${proj_name}/commands.cfg": + content => template('nagios/common/etc/nagios/nrpe.d/commands.cfg.erb'), + notify => Service[$nagios::params::nrpeservice], + require => Package[$nagios::params::nrpepkg], + } + + file { "/etc/nagios/${proj_name}": + source => 'puppet:///modules/nagios/common/etc/nagios/nrpe.d', + notify => Service[$nagios::params::nrpeservice], + require => Package[$nagios::params::nrpepkg], + } + + file { "/usr/local/lib/nagios": mode => '0755', source => 'puppet:///modules/nagios/common/usr/local/lib/nagios', } - package { [ - 'binutils', - 'libnagios-plugin-perl', - 'nagios-nrpe-server', - 'nagios-plugins-basic', - 'nagios-plugins-standard' ]: - ensure => present, - } - - service { 'nagios-nrpe-server': + service {$nagios::params::nrpeservice: ensure => running, enable => true, hasrestart => true, @@ -61,7 +66,7 @@ $whitelist = '127.0.0.1', pattern => 'nrpe', require => [ File['nrpe.cfg'], - Package['nagios-nrpe-server'] + Package[$nagios::params::nrpepkg] ], } } diff --git a/deployment/puppet/nagios/manifests/master.pp b/deployment/puppet/nagios/manifests/master.pp index 0df85ff11f..7f0f5075b4 100644 --- a/deployment/puppet/nagios/manifests/master.pp +++ b/deployment/puppet/nagios/manifests/master.pp @@ -23,7 +23,7 @@ $contactgroups = {'group' => 'admins', 'alias' => 'Admins'}, $contacts = {'user' => 'hotkey', 'alias' => 'Dennis Hoppe', 'email' => 'nagios@%{domain}', 'group' => 'admins'}, -) { +) inherits nagios::params { validate_hash($htpasswd) validate_hash($templateservice) @@ -36,104 +36,96 @@ $contacts = {'user' => 'hotkey', 'alias' => 'Dennis Hoppe', include nagios::command include nagios::contact - exec { 'external-commands': - command => 'dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3 && dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw', - path => ['/bin','/sbin','/usr/sbin/','/usr/sbin/'], - unless => 'dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3 && dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw', - notify => Service['nagios3'], + if $::osfamily == 'Debian' { + exec { 'external-commands': + command => 'dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3 && dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw', + path => ['/bin','/sbin','/usr/sbin/','/usr/sbin/'], + unless => 'dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3 && dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw', + notify => Service[$nagios::params::masterservice], + } } # Bug: 3299 - exec { 'fix-permissions': - command => "chmod -R go+r /etc/nagios3/${proj_name}", - path => ['/bin','/sbin','/usr/sbin/','/usr/sbin/'], - refreshonly => true, - notify => Service['nagios3'], - } + exec { 'fix-permissions': + command => "chmod -R go+r /etc/${nagios::params::masterdir}/${proj_name}", + path => ['/bin','/sbin','/usr/sbin/','/usr/sbin/'], + refreshonly => true, + notify => Service[$nagios::params::masterservice], + } - - augeas {'configs': - context => '/files/etc/nagios3/nagios.cfg', - changes => [ - "set cfg_dir[2] \"/etc/nagios3/${proj_name}\"", - 'set check_external_commands 1', - ], - } - - file { '/etc/nagios3/htpasswd.users': - owner => root, - group => root, - mode => '0644', - content => template('nagios/common/etc/nagios3/htpasswd.users.erb'), - require => Package['nagios3'], - } - - file { "/etc/nagios3/${proj_name}/templates.cfg": - owner => root, - group => root, - mode => '0644', - content => template('nagios/openstack/templates.cfg.erb'), - require => Package['nagios3'], - } - - file { "/etc/nagios3/${proj_name}/hostgroup.cfg": - owner => root, - group => root, - mode => '0644', - content => template('nagios/openstack/hostgroups.cfg.erb'), - require => Package['nagios3'], - } - - file { "/etc/nagios3/${proj_name}": - recurse => true, - owner => root, - group => root, - mode => '0644', - alias => 'conf.d', - notify => Service['nagios3'], - source => 'puppet:///modules/nagios/common/etc/nagios3/conf.d', - require => Package['nagios3'], - } - - package { [ - 'nagios3', - 'nagios-nrpe-plugin' ]: + package { $nagios::params::nagios3pkg: ensure => present, } - resources { 'nagios_command': + case $::osfamily { + 'RedHat': { + augeas {'configs': + lens => 'NagiosCfg.lns', + incl => '/etc/nagios*/*.cfg', + context => "/files/etc/${nagios::params::masterdir}/nagios.cfg", + changes => [ + 'rm cfg_file[position() > 1]', + "set cfg_dir \"/etc/${masterdir}/${nagios::master::proj_name}\"", + 'set check_external_commands 1', + ], + require => Package[$nagios::params::nagios3pkg], + notify => Service[$nagios::params::masterservice], + } + } + 'Debian': { + augeas {'configs': + lens => 'NagiosCfg.lns', + incl => '/etc/nagios*/*.cfg', + context => "/files/etc/${nagios::params::masterdir}/nagios.cfg", + changes => [ + "set cfg_dir[2] \"/etc/${masterdir}/${nagios::master::proj_name}\"", + 'set check_external_commands 1', + ], + require => Package[$nagios::params::nagios3pkg], + notify => Service[$nagios::params::masterservice], + } + } + } + + File { + owner => root, + group => root, + mode => '0644', + require => Package[$nagios::params::nagios3pkg], + } + + file { + "/etc/${nagios::params::masterdir}/${proj_name}/templates.cfg": + content => template('nagios/openstack/templates.cfg.erb'); + "/etc/${nagios::params::masterdir}/${proj_name}/hostgroup.cfg": + content => template('nagios/openstack/hostgroups.cfg.erb'); + "/etc/${nagios::params::masterdir}/${nagios::params::htpasswd}": + content => template('nagios/common/etc/nagios3/htpasswd.users.erb'); + } + + file { "/etc/${nagios::params::masterdir}/${proj_name}": + recurse => true, + alias => 'conf.d', + notify => Service[$nagios::params::masterservice], + source => 'puppet:///modules/nagios/common/etc/nagios3/conf.d', + } + + Resources { purge => true, } - resources { 'nagios_contact': - purge => true, + resources { + 'nagios_command':; + 'nagios_contact':; + 'nagios_contactgroup':; + 'nagios_host':; + 'nagios_hostgroup':; + 'nagios_hostextinfo':; + 'nagios_service':; + 'nagios_servicegroup':; } - resources { 'nagios_contactgroup': - purge => true, - } - - resources { 'nagios_host': - purge => true, - } - - resources { 'nagios_hostgroup': - purge => true, - } - - resources { 'nagios_hostextinfo': - purge => true, - } - - resources { 'nagios_service': - purge => true, - } - - resources { 'nagios_servicegroup': - purge => true, - } - - service { 'nagios3': + service { $nagios::params::masterservice: ensure => running, enable => true, hasrestart => true, @@ -141,7 +133,7 @@ $contacts = {'user' => 'hotkey', 'alias' => 'Dennis Hoppe', require => [ Augeas['configs'], File['conf.d'], - Package['nagios3'] + Package[$nagios::params::nagios3pkg] ], } } diff --git a/deployment/puppet/nagios/manifests/nrpeconfig.pp b/deployment/puppet/nagios/manifests/nrpeconfig.pp index 6c58d89bfe..241befa374 100644 --- a/deployment/puppet/nagios/manifests/nrpeconfig.pp +++ b/deployment/puppet/nagios/manifests/nrpeconfig.pp @@ -8,8 +8,8 @@ $include_dir = '/etc/nagios/nrpe.d', group => root, mode => '0644', alias => 'nrpe.cfg', - notify => Service['nagios-nrpe-server'], + notify => Service[$nagios::params::nrpeservice], content => template('nagios/common/etc/nagios/nrpe.cfg.erb'), - require => Package['nagios-nrpe-server'], + require => Package[$nagios::params::nrpepkg], } } diff --git a/deployment/puppet/nagios/manifests/params.pp b/deployment/puppet/nagios/manifests/params.pp index 993feb30ea..2c37d7c50e 100644 --- a/deployment/puppet/nagios/manifests/params.pp +++ b/deployment/puppet/nagios/manifests/params.pp @@ -34,4 +34,43 @@ class nagios::params { 'swap' => 'nrpe_check_swap!20%!10%', 'user' => 'nrpe_check_users!5!10', } + + case $::osfamily { + 'RedHat': { + $nagios3pkg = [ + 'nagios', + 'nagios-plugins-nrpe', + 'nagios-plugins-all' ] + $nrpepkg = [ + 'binutils', + 'openssl', + 'nrpe', + 'nagios-plugins-nrpe', + 'perl-Nagios-Plugin', + 'nagios-plugins-all' ] + $masterdir = 'nagios' + $htpasswd = 'passwd' + $libdir = '/usr/lib64' + $nrpeservice = 'nrpe' + $masterservice = 'nagios' + $distro = inline_template("<%= scope.lookupvar('::operatingsystem').downcase -%>") + } + 'Debian': { + $nagios3pkg = [ + 'nagios3', + 'nagios-nrpe-plugin' ] + $nrpepkg = [ + 'binutils', + 'libnagios-plugin-perl', + 'nagios-nrpe-server', + 'nagios-plugins-basic', + 'nagios-plugins-standard'] + $masterdir = 'nagios3' + $htpasswd = 'htpasswd.users' + $libdir = '/usr/lib' + $nrpeservice = 'nagios-nrpe-server' + $masterservice = 'nagios3' + $distro = inline_template("<%= scope.lookupvar('::lsbdistid').downcase -%>") + } + } } diff --git a/deployment/puppet/nagios/manifests/service/servicegroups.pp b/deployment/puppet/nagios/manifests/service/servicegroups.pp index 0dd48f37f4..6e6abb63f8 100644 --- a/deployment/puppet/nagios/manifests/service/servicegroups.pp +++ b/deployment/puppet/nagios/manifests/service/servicegroups.pp @@ -5,6 +5,6 @@ define nagios::service::servicegroups() { nagios_servicegroup { $name: ensure => present, # alias => $alias, - target => "/etc/nagios3/${proj_name}/servicegroups.cfg", + target => "/etc/${nagios::params::masterdir}/${proj_name}/servicegroups.cfg", } } diff --git a/deployment/puppet/nagios/manifests/service/services.pp b/deployment/puppet/nagios/manifests/service/services.pp index 0249ddb072..8018b5d659 100644 --- a/deployment/puppet/nagios/manifests/service/services.pp +++ b/deployment/puppet/nagios/manifests/service/services.pp @@ -9,6 +9,6 @@ $group = false, check_command => $command, service_description => $name, host_name => $::fqdn, - target => "/etc/nagios3/${proj_name}/${::hostname}_services.cfg", + target => "/etc/${nagios::params::masterdir}/${proj_name}/${::hostname}_services.cfg", } } diff --git a/deployment/puppet/nagios/templates/common/etc/nagios/nrpe.d/commands.cfg.erb b/deployment/puppet/nagios/templates/common/etc/nagios/nrpe.d/commands.cfg.erb new file mode 100644 index 0000000000..b7c8c13f63 --- /dev/null +++ b/deployment/puppet/nagios/templates/common/etc/nagios/nrpe.d/commands.cfg.erb @@ -0,0 +1,12 @@ +# +# THIS FILE IS MANAGED BY PUPPET +# + +command[check_disk]=<%= libdir %>/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ +command[check_load]=<%= libdir %>/nagios/plugins/check_load -w $ARG1$,$ARG2$,$ARG3$ -c $ARG4$,$ARG5$,$ARG6$ +command[check_mailq]=<%= libdir %>/nagios/plugins/check_mailq -w $ARG1$ -c $ARG2$ +command[check_procs]=<%= libdir %>/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ +command[check_procs_zombie]=<%= libdir %>/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s Z +command[check_ide_smart]=sudo <%= libdir %>/nagios/plugins/check_ide_smart -d $ARG1$ -n +command[check_swap]=<%= libdir %>/nagios/plugins/check_swap -w $ARG1$ -c $ARG2$ +command[check_users]=<%= libdir %>/nagios/plugins/check_users -w $ARG1$ -c $ARG2$ diff --git a/deployment/puppet/nagios/templates/openstack/openstack.cfg.erb b/deployment/puppet/nagios/templates/openstack/openstack.cfg.erb new file mode 100644 index 0000000000..9f3ec13bed --- /dev/null +++ b/deployment/puppet/nagios/templates/openstack/openstack.cfg.erb @@ -0,0 +1,20 @@ +# +# THIS FILE IS MANAGED BY PUPPET +# +command[check_nova_compute]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C nova-compute +command[check_nova_network]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C nova-network +command[check_nova_scheduler]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C nova-scheduler +command[check_nova_consoleauth]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -a nova-consoleauth +command[check_nova_cert]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C nova-cert +command[check_cinder_scheduler]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -a cinder-scheduler +command[check_cinder_volume]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C cinder-volume +command[check_haproxy]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C haproxy +command[check_memcached]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C memcached +command[check_glance_registry]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -C glance-registry +command[check_nova_novncproxy]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -a nova-novncproxy +command[check_swift_proxy]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -a swift-proxy-server +command[check_swift_account]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -a swift-account-server +command[check_swift_object]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -a swift-object-server +command[check_swift_container]=<%= libdir %>/nagios/plugins/check_procs -c 1:10 -a swift-container-server +command[check_swift_ring]=<%= libdir %>/nagios/plugins/check_os_swiftrecon objmd5 +command[check_libvirt]=<%= libdir %>/nagios/plugins/check_os_libvirt connect -H 127.0.0.1 -m qemu+tcp diff --git a/deployment/puppet/nagios/templates/openstack/sample_hosts.cfg b/deployment/puppet/nagios/templates/openstack/sample_hosts.cfg index 65725c7bf4..cc27077fc7 100644 --- a/deployment/puppet/nagios/templates/openstack/sample_hosts.cfg +++ b/deployment/puppet/nagios/templates/openstack/sample_hosts.cfg @@ -1,3 +1,6 @@ +# +# THIS FILE IS MANAGED BY PUPPET +# define host { use default-host address cont-01-qa.qa.rr.lan diff --git a/deployment/puppet/nagios/templates/openstack/templates.cfg.erb b/deployment/puppet/nagios/templates/openstack/templates.cfg.erb index 4e3944d34e..3230dfb6de 100644 --- a/deployment/puppet/nagios/templates/openstack/templates.cfg.erb +++ b/deployment/puppet/nagios/templates/openstack/templates.cfg.erb @@ -1,3 +1,7 @@ +# +# THIS FILE IS MANAGED BY PUPPET +# + <% if templatehost.kind_of? Hash %> define host { <% templatehost.keys.each do |key| %>