diff options
author | mh <mh@immerda.ch> | 2010-08-11 15:57:58 +0200 |
---|---|---|
committer | mh <mh@immerda.ch> | 2010-08-11 15:57:58 +0200 |
commit | 01bb8dfee9c3981994d1697fc96470798445a050 (patch) | |
tree | dcd4266d6eeb8dc48ae1b69aacea53594e6560a8 | |
parent | 33b091b896fbb0b54ee9968c452ef2a8867893d8 (diff) | |
parent | a5d8b5b8b1f4d5afcb549e28bf1eef12169b81c7 (diff) |
Merge branch 'master' of git.puppet.immerda.ch:module-nagios
-rw-r--r-- | README | 37 | ||||
-rw-r--r-- | files/configs/Debian/nagios.cfg | 3 | ||||
l--------- | files/configs/Debian/private/resource.cfg.amd64 | 1 | ||||
l---------[-rw-r--r--] | files/configs/Debian/private/resource.cfg.x86_64 | 32 | ||||
-rw-r--r-- | files/htpasswd.users | 0 | ||||
-rw-r--r-- | files/plugins/check_jabber_login | 30 | ||||
-rw-r--r-- | lib/facter/mountpoints.rb | 50 | ||||
-rw-r--r-- | manifests/apache.pp | 2 | ||||
-rw-r--r-- | manifests/base.pp | 110 | ||||
-rw-r--r-- | manifests/debian.pp | 2 | ||||
-rw-r--r-- | manifests/defaults/commands.pp | 80 | ||||
-rw-r--r-- | manifests/defaults/host_templates.pp | 12 | ||||
-rw-r--r-- | manifests/defaults/hostgroups.pp | 20 | ||||
-rw-r--r-- | manifests/defaults/service_templates.pp | 18 | ||||
-rw-r--r-- | manifests/defaults/templates.pp | 13 | ||||
-rw-r--r-- | manifests/defaults/vars.pp | 10 | ||||
-rw-r--r-- | manifests/nsca/client.pp | 6 | ||||
-rw-r--r-- | manifests/nsca/server.pp | 6 | ||||
-rw-r--r-- | manifests/plugin.pp | 9 | ||||
-rw-r--r-- | manifests/target/fqdn.pp (renamed from manifests/target/nat.pp) | 2 |
20 files changed, 261 insertions, 182 deletions
@@ -12,7 +12,10 @@ In it's current form, this module can be used on CentOS and Debian. Overview ======== -To use the nagios resources, activate storeconfigs on the puppetmaster. +To use the nagios resources, activate storeconfigs on the +puppetmaster. + +You need to be running verison 0.25 or later of puppet. Monitor @@ -28,8 +31,11 @@ Hosts ----- On a node which shall be monitored with nagios, include the "nagios::target". -This just creates a host declaration for this hosts "$fqdn". -Set the $nagios_parent variable in the node scope for enabling the reachability +This just creates a host declaration for this host's "$ipaddress" fact. If +the $ipaddress of your target is not the one you wish to modify, you can use +"nagios::target::fqdn" instead, which will use the $fqdn fact of the host instead. + +Set the $nagios_parents variable in the node scope for enabling the reachability features of nagios. If a node needs more customisation, use the native "@@nagios_host" type directly (the double-ampersand declares the object as an exported resource). @@ -60,6 +66,25 @@ Obviously, the check command must either be defined using nagios_command objects files directly. +Upgrade Notes +============= + +The nagios::target bits have been reworked, the notable changes that +may affect an upgrade are: + +. previous versions had nagios::target::nat which used the $fqdn for +the address part of nagios::target, this has been renamed to +nagios::target::fqdn to be more clear. if you were using +nagios::target::nat then you will need to change those references to +::fqdn + +. previous versions of this module used $fqdn for the nagios::target +address, now it is using $ipaddress. If you need $fqdn, use +nagios::target::fqdn instead of nagios::target + +. previous versions of nagios_host used the parameter named 'ip', that +has been changed to 'address' + Caveats ======= @@ -137,8 +162,8 @@ $HOSTADDRESS$' node target { - # Monitor this host - $nagios_parent = 'router01' + # Monitor th () is host + $nagios_parents = 'router01' include nagios::target # monitor a service @@ -167,3 +192,5 @@ License Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> See the file LICENSE in the top directory for the full license. +Copyright (C) 2010 Riseup Networks <micah@riseup.net> + diff --git a/files/configs/Debian/nagios.cfg b/files/configs/Debian/nagios.cfg index a588f55..8eae393 100644 --- a/files/configs/Debian/nagios.cfg +++ b/files/configs/Debian/nagios.cfg @@ -20,13 +20,14 @@ log_file=/var/log/nagios3/nagios.log # host groups, contacts, contact groups, services, etc. # You can split your object definitions across several config files # if you wish (as shown below), or keep them all in a single config file. +cfg_file=/etc/nagios3/commands.cfg # Puppet-managed configuration files cfg_dir=/etc/nagios3/conf.d # Debian also defaults to using the check commands defined by the debian # nagios-plugins package -#cfg_dir=/etc/nagios-plugins/config +cfg_dir=/etc/nagios-plugins/config diff --git a/files/configs/Debian/private/resource.cfg.amd64 b/files/configs/Debian/private/resource.cfg.amd64 new file mode 120000 index 0000000..4d5f0a3 --- /dev/null +++ b/files/configs/Debian/private/resource.cfg.amd64 @@ -0,0 +1 @@ +resource.cfg.i386
\ No newline at end of file diff --git a/files/configs/Debian/private/resource.cfg.x86_64 b/files/configs/Debian/private/resource.cfg.x86_64 index 3ed732b..4d5f0a3 100644..120000 --- a/files/configs/Debian/private/resource.cfg.x86_64 +++ b/files/configs/Debian/private/resource.cfg.x86_64 @@ -1,31 +1 @@ -########################################################################### -# -# RESOURCE.CFG - Resource File for Nagios -# -# You can define $USERx$ macros in this file, which can in turn be used -# in command definitions in your host config file(s). $USERx$ macros are -# useful for storing sensitive information such as usernames, passwords, -# etc. They are also handy for specifying the path to plugins and -# event handlers - if you decide to move the plugins or event handlers to -# a different directory in the future, you can just update one or two -# $USERx$ macros, instead of modifying a lot of command definitions. -# -# The CGIs will not attempt to read the contents of resource files, so -# you can set restrictive permissions (600 or 660) on them. -# -# Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$) -# -# Resource files may also be used to store configuration directives for -# external data sources like MySQL... -# -########################################################################### - -# Sets $USER1$ to be the path to the plugins -$USER1$=/usr/lib/nagios/plugins - -# Sets $USER2$ to be the path to event handlers -#$USER2$=/usr/lib/nagios/plugins/eventhandlers - -# Store some usernames and passwords (hidden from the CGIs) -#$USER3$=someuser -#$USER4$=somepassword +resource.cfg.i386
\ No newline at end of file diff --git a/files/htpasswd.users b/files/htpasswd.users new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/files/htpasswd.users diff --git a/files/plugins/check_jabber_login b/files/plugins/check_jabber_login deleted file mode 100644 index dac0e1f..0000000 --- a/files/plugins/check_jabber_login +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env ruby -require 'rubygems' -require 'xmpp4r' - - -def usage - puts "#{$0} jabberid password" - exit 3 -end - -usage unless ARGV.size == 2 - -begin - my_client = Jabber::Client.new(ARGV[0]) - my_client.connect - my_client.auth(ARGV[1]) -rescue Jabber::ClientAuthenticationFailure => detail - puts "CRITICAL: Login Error" - exit 2 -rescue Errno::ECONNREFUSED => detail - puts "CRITICAL: Connection refused" - exit 2 -rescue SocketError => detail - puts "CRITICAL: Socket Error" - exit 2 -#rescue -# puts "CRITICAL: Unknown Error" -# exit 2 -end -puts "OK: Login for #{ARGV[0]} successfull" diff --git a/lib/facter/mountpoints.rb b/lib/facter/mountpoints.rb new file mode 100644 index 0000000..c51e6e6 --- /dev/null +++ b/lib/facter/mountpoints.rb @@ -0,0 +1,50 @@ +begin + + mountpoints = [] + # we show devices, but we avoid outputing duplicate devices + devices = [] + Facter.add("mountpoints") do + ignorefs = ["NFS", "nfs", "nfs4", "nfsd", "afs", "binfmt_misc", "proc", "smbfs", + "autofs", "iso9660", "ncpfs", "coda", "devpts", "ftpfs", "devfs", + "mfs", "shfs", "sysfs", "cifs", "lustre_lite", "tmpfs", "usbfs", "udf", + "fusectl", "fuse.snapshotfs", "rpc_pipefs"] + begin + require 'filesystem' + rescue Exception => e + confine :kernel => :linux + ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin" + fs_source = nil + if FileTest.exists?("/etc/mtab") + fs_source = "/etc/mtab" + elsif FileTest.exists?("/proc/mounts") + fs_source = "/proc/mounts" + end + + mounts = File.read(fs_source).split("\n") + mounts.each do |mount| + mount = mount.split(" ") + if ((not ignorefs.include?(mount[2])) && (mount[3] !~ /bind/) && (not devices.include?(mount[0])) && (not mountpoints.include?(mount[1]))) + mountpoints.push(mount[1]) + end + devices.push(mount[0]) if not devices.include?(mount[0]) + end + else + FileSystem.mounts.each do |m| + if ((not ignorefs.include?(m.fstype)) && (m.options !~ /bind/) && !devices.include?(mount[0])) + mountpoints.push(m.mount) + end + devices.push(m.mount) if not devices.include?(m.mount) + end + end + setcode do + mountpoints.join(",") + end + end + Facter.add("devices") do + setcode do + devices.join(",") + end + end + +rescue Exception => e +end diff --git a/manifests/apache.pp b/manifests/apache.pp index 36994f8..c00b1d9 100644 --- a/manifests/apache.pp +++ b/manifests/apache.pp @@ -1,4 +1,4 @@ -class nagios::apache { +class nagios::apache inherits ::apache { $nagios_httpd = 'apache' include nagios } diff --git a/manifests/base.pp b/manifests/base.pp index 6106ab2..071f22c 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -1,4 +1,6 @@ class nagios::base { + # include the variables + include nagios::defaults::vars package { 'nagios': alias => 'nagios', @@ -14,37 +16,37 @@ class nagios::base { # this file should contain all the nagios_puppet-paths: file { 'nagios_main_cfg': - path => "${nagios_cfgdir}/nagios.cfg", - source => [ "puppet://$server/modules/site-nagios/configs/${fqdn}/nagios.cfg", - "puppet://$server/modules/site-nagios/configs/${operatingsystem}/nagios.cfg", - "puppet://$server/modules/site-nagios/configs/nagios.cfg", - "puppet://$server/modules/nagios/configs/${operatingsystem}/nagios.cfg", - "puppet://$server/modules/nagios/configs/nagios.cfg" ], + path => "${nagios::defaults::vars::int_nagios_cfgdir}/nagios.cfg", + source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios.cfg", + "puppet:///modules/site-nagios/configs/${operatingsystem}/nagios.cfg", + "puppet:///modules/site-nagios/configs/nagios.cfg", + "puppet:///modules/nagios/configs/${operatingsystem}/nagios.cfg", + "puppet:///modules/nagios/configs/nagios.cfg" ], notify => Service['nagios'], mode => 0644, owner => root, group => root; } file { 'nagios_cgi_cfg': - path => "${nagios_cfgdir}/cgi.cfg", - source => [ "puppet://$server/modules/site-nagios/configs/${fqdn}/cgi.cfg", - "puppet://$server/modules/site-nagios/configs/${operatingsystem}/cgi.cfg", - "puppet://$server/modules/site-nagios/configs/cgi.cfg", - "puppet://$server/modules/nagios/configs/${operatingsystem}/cgi.cfg", - "puppet://$server/modules/nagios/configs/cgi.cfg" ], + path => "${nagios::defaults::vars::int_nagios_cfgdir}/cgi.cfg", + source => [ "puppet:///modules/site-nagios/configs/${fqdn}/cgi.cfg", + "puppet:///modules/site-nagios/configs/${operatingsystem}/cgi.cfg", + "puppet:///modules/site-nagios/configs/cgi.cfg", + "puppet:///modules/nagios/configs/${operatingsystem}/cgi.cfg", + "puppet:///modules/nagios/configs/cgi.cfg" ], mode => '0644', owner => 'root', group => 0, notify => Service['apache'], } file { 'nagios_htpasswd': - path => "${nagios_cfgdir}/htpasswd.users", - source => [ "puppet://$server/modules/site-nagios/htpasswd.users", - "puppet://$server/modules/nagios/htpasswd.users" ], + path => "${nagios::defaults::vars::int_nagios_cfgdir}/htpasswd.users", + source => [ "puppet:///modules/site-nagios/htpasswd.users", + "puppet:///modules/nagios/htpasswd.users" ], mode => 0640, owner => root, group => apache; } file { 'nagios_private': - path => "${nagios_cfgdir}/private/", - source => "puppet://$server/modules/common/empty", + path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/", + source => "puppet:///modules/common/empty", ensure => directory, purge => true, recurse => true, @@ -53,15 +55,16 @@ class nagios::base { } file { 'nagios_private_resource_cfg': - path => "${nagios_cfgdir}/private/resource.cfg", - source => "puppet://$server/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}", + path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/resource.cfg", + source => [ "puppet:///modules/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}", + "puppet:///modules/site-nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}" ], notify => Service['nagios'], owner => root, group => nagios, mode => '0640'; } file { 'nagios_confd': - path => "${nagios_cfgdir}/conf.d/", - source => "puppet://$server/modules/common/empty", + path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/", + source => "puppet:///modules/common/empty", ensure => directory, purge => true, recurse => true, @@ -81,68 +84,81 @@ class nagios::base { Nagios_serviceescalation <<||>> Nagios_serviceextinfo <<||>> Nagios_timeperiod <<||>> + File <<| tag == 'nagios_plugin' |>> Nagios_command <||> { - target => "${nagios_cfgdir}/conf.d/nagios_command.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_contact <||> { - target => "${nagios_cfgdir}/conf.d/nagios_contact.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_contactgroup <||> { - target => "${nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_host <||> { - target => "${nagios_cfgdir}/conf.d/nagios_host.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_hostextinfo <||> { - target => "${nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_hostgroup <||> { - target => "${nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_hostgroupescalation <||> { - target => "${nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_service <||> { - target => "${nagios_cfgdir}/conf.d/nagios_service.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_servicedependency <||> { - target => "${nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_serviceescalation <||> { - target => "${nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_serviceextinfo <||> { - target => "${nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } Nagios_timeperiod <||> { - target => "${nagios_cfgdir}/conf.d/nagios_timeperiod.cfg", + target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg", + require => File['nagios_confd'], notify => Service['nagios'], } - file{[ "${nagios_cfgdir}/conf.d/nagios_command.cfg", - "${nagios_cfgdir}/conf.d/nagios_contact.cfg", - "${nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", - "${nagios_cfgdir}/conf.d/nagios_host.cfg", - "${nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", - "${nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", - "${nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", - "${nagios_cfgdir}/conf.d/nagios_service.cfg", - "${nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", - "${nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", - "${nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", - "${nagios_cfgdir}/conf.d/nagios_timeperiod.cfg" ]: + file{[ "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", + "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg" ]: ensure => file, replace => false, notify => Service['nagios'], @@ -152,8 +168,8 @@ class nagios::base { # manage nagios cfg files # must be defined after exported resource overrides and cfg file defs file { 'nagios_cfgdir': - path => "${nagios_cfgdir}/", - source => "puppet://$server/modules/common/empty", + path => "${nagios::defaults::vars::int_nagios_cfgdir}/", + source => "puppet:///modules/common/empty", ensure => directory, recurse => true, purge => true, diff --git a/manifests/debian.pp b/manifests/debian.pp index a503324..b9e87ec 100644 --- a/manifests/debian.pp +++ b/manifests/debian.pp @@ -14,7 +14,7 @@ class nagios::debian inherits nagios::base { File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' } - file { "${nagios_cfgdir}/stylesheets": + file { "${nagios::defaults::vars::int_nagios_cfgdir}/stylesheets": ensure => directory, purge => false, recurse => true, diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp index c3190af..bbb6ce5 100644 --- a/manifests/defaults/commands.pp +++ b/manifests/defaults/commands.pp @@ -2,54 +2,84 @@ class nagios::defaults::commands { # common service commands - nagios_command { - check_dummy: + case $operatingsystem { + debian,ubuntu: { + nagios_command { + check_dummy: command_line => '$USER1$/check_dummy $ARG1$'; - check_ping: + check_https_cert: + command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$'; + check_http_url: + command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$'; + check_http_url_regex: + command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -e $ARG3$'; + check_https_url: + command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$'; + check_https_url_regex: + command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$'; + check_mysql_db: + command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$'; + check_ntp_time: + command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1'; + check_silc: + command_line => '$USER1$/check_tcp -p 706 -H $ARG1$'; + check_sobby: + command_line => '$USER1$/check_tcp -H $ARG1$ -p $ARG2$'; + check_jabber: + command_line => '$USER1$/check_jabber -H $ARG1$'; + } + } + default: { + nagios_command { + check_dummy: + command_line => '$USER1$/check_dummy $ARG1$'; + check_ping: command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$'; - check-host-alive: + check-host-alive: command_line => '$USER1$/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1'; - check_tcp: + check_tcp: command_line => '$USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$'; - check_udp: + check_udp: command_line => '$USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$'; - check_load: + check_load: command_line => '$USER1$/check_load --warning=$ARG1$,$ARG2$,$ARG3$ --critical=$ARG4$,$ARG5$,$ARG6$'; - check_disk: + check_disk: command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e -p $ARG3$'; - check_all_disks: + check_all_disks: command_line => '$USER1$/check_disk -w $ARG1$ -c $ARG2$ -e'; - check_ssh: + check_ssh: command_line => '$USER1$/check_ssh $HOSTADDRESS$'; - check_ssh_port: + ssh_port: command_line => '$USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$'; - check_http: + check_http: command_line => '$USER1$/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$'; - check_https: + check_https: command_line => '$USER1$/check_http --ssl -H $HOSTADDRESS$ -I $HOSTADDRESS$'; - check_https_cert: + check_https_cert: command_line => '$USER1$/check_http --ssl -C 20 -H $HOSTADDRESS$ -I $HOSTADDRESS$'; - check_http_url: + check_http_url: command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$'; - check_http_url_regex: + check_http_url_regex: command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -e $ARG3$'; - check_https_url: + check_https_url: command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$'; - check_https_url_regex: + check_https_url_regex: command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$'; - check_mysql: + check_mysql: command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$'; - check_mysql_db: + check_mysql_db: command_line => '$USER1$/check_mysql -H $ARG1$ -P $ARG2$ -u $ARG3$ -p $ARG4$ -d $ARG5$'; - check_ntp_time: + check_ntp_time: command_line => '$USER1$/check_ntp_time -H $HOSTADDRESS$ -w 0.5 -c 1'; - check_silc: + check_silc: command_line => '$USER1$/check_tcp -p 706 -H $ARG1$'; - check_sobby: + check_sobby: command_line => '$USER1$/check_tcp -H $ARG1$ -p $ARG2$'; - check_jabber: + check_jabber: command_line => '$USER1$/check_jabber -H $ARG1$'; - } + } + } + } # commands for services defined by other modules diff --git a/manifests/defaults/host_templates.pp b/manifests/defaults/host_templates.pp index 699b965..0f47324 100644 --- a/manifests/defaults/host_templates.pp +++ b/manifests/defaults/host_templates.pp @@ -12,12 +12,12 @@ class nagios::defaults::host_templates { process_perf_data => '1', retain_status_information => '1', retain_nonstatus_information => '1', - check_command => 'check-host-alive', - max_check_attempts => '10', - notification_interval => '0', - notification_period => '24x7', - notification_options => 'd,u,r', - contact_groups => 'admins', + check_command => 'check-host-alive', + max_check_attempts => '10', + notification_interval => '0', + notification_period => '24x7', + notification_options => 'd,u,r', + contact_groups => 'admins', register => '0', } diff --git a/manifests/defaults/hostgroups.pp b/manifests/defaults/hostgroups.pp index 3a4f4d1..8715ade 100644 --- a/manifests/defaults/hostgroups.pp +++ b/manifests/defaults/hostgroups.pp @@ -1,13 +1,11 @@ class nagios::defaults::hostgroups { - - nagios_hostgroup { - 'all': - alias => 'All Servers', - members => '*'; - 'debian-servers': - alias => 'Debian GNU/Linux Servers'; - 'centos-servers': - alias => 'CentOS GNU/Linux Servers'; - } - + nagios_hostgroup { + 'all': + alias => 'All Servers', + members => '*'; + 'debian-servers': + alias => 'Debian GNU/Linux Servers'; + 'centos-servers': + alias => 'CentOS GNU/Linux Servers'; + } } diff --git a/manifests/defaults/service_templates.pp b/manifests/defaults/service_templates.pp index 326ce05..84740af 100644 --- a/manifests/defaults/service_templates.pp +++ b/manifests/defaults/service_templates.pp @@ -17,15 +17,15 @@ class nagios::defaults::service_templates { process_perf_data => '1', retain_status_information => '1', retain_nonstatus_information => '1', - notification_interval => '0', - is_volatile => '0', - check_period => '24x7', - normal_check_interval => '5', - retry_check_interval => '1', - max_check_attempts => '4', - notification_period => '24x7', - notification_options => 'w,u,c,r', - contact_groups => 'admins', + notification_interval => '0', + is_volatile => '0', + check_period => '24x7', + normal_check_interval => '5', + retry_check_interval => '1', + max_check_attempts => '4', + notification_period => '24x7', + notification_options => 'w,u,c,r', + contact_groups => 'admins', register => '0', } diff --git a/manifests/defaults/templates.pp b/manifests/defaults/templates.pp index 5a3d23d..c97eee4 100644 --- a/manifests/defaults/templates.pp +++ b/manifests/defaults/templates.pp @@ -1,12 +1,13 @@ class nagios::defaults::templates { + include nagios::defaults::vars file { 'nagios_templates': - path => "${nagios::nagios_cfgdir}/conf.d/nagios_templates.cfg", - source => [ "puppet://$server/modules/site-nagios/configs/${fqdn}/nagios_templates.cfg", - "puppet://$server/modules/site-nagios/configs/${operatingsystem}/nagios_templates.cfg", - "puppet://$server/modules/site-nagios/configs/nagios_templates.cfg", - "puppet://$server/modules/nagios/configs/${operatingsystem}/nagios_templates.cfg", - "puppet://$server/modules/nagios/configs/nagios_templates.cfg" ], + path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_templates.cfg", + source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios_templates.cfg", + "puppet:///modules/site-nagios/configs/${operatingsystem}/nagios_templates.cfg", + "puppet:///modules/site-nagios/configs/nagios_templates.cfg", + "puppet:///modules/nagios/configs/${operatingsystem}/nagios_templates.cfg", + "puppet:///modules/nagios/configs/nagios_templates.cfg" ], notify => Service['nagios'], mode => 0644, owner => root, group => root; } diff --git a/manifests/defaults/vars.pp b/manifests/defaults/vars.pp new file mode 100644 index 0000000..6302f13 --- /dev/null +++ b/manifests/defaults/vars.pp @@ -0,0 +1,10 @@ +class nagios::defaults::vars { + case $nagios_cfgdir { + '': { $int_nagios_cfgdir = $operatingsystem ? { + centos => '/etc/nagios/', + default => '/etc/nagios3' + } + } + default: { $int_nagios_cfgdir = $nagios_cfgdir } + } +} diff --git a/manifests/nsca/client.pp b/manifests/nsca/client.pp index b4ca878..5314b3d 100644 --- a/manifests/nsca/client.pp +++ b/manifests/nsca/client.pp @@ -3,9 +3,9 @@ class nagios::nsca::client { package { 'nsca': ensure => installed } file { '/etc/send_nsca.cfg': - source => [ "puppet://${server}/site-nagios/nsca/{$fqdn}/send_nsca.cfg", - "puppet://${server}/site-nagios/nsca/send_nsca.cfg", - "puppet://${server}/nagios/nsca/send_nsca.cfg" ], + source => [ "puppet://${server}/modules/site-nagios/nsca/{$fqdn}/send_nsca.cfg", + "puppet://${server}/modules/site-nagios/nsca/send_nsca.cfg", + "puppet://${server}/modules/nagios/nsca/send_nsca.cfg" ], owner => 'nagios', group => 'nogroup', mode => '400', diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp index c682e24..e1cb83c 100644 --- a/manifests/nsca/server.pp +++ b/manifests/nsca/server.pp @@ -9,9 +9,9 @@ class nagios::nsca::server { } file { '/etc/nsca.cfg': - source => [ "puppet://${server}/site-nagios/nsca/{$fqdn}/nsca.cfg", - "puppet://${server}/site-nagios/nsca/nsca.cfg", - "puppet://${server}/nagios/nsca/nsca.cfg" ], + source => [ "puppet://${server}/modules/site-nagios/nsca/{$fqdn}/nsca.cfg", + "puppet://${server}/modules/site-nagios/nsca/nsca.cfg", + "puppet://${server}/modules/nagios/nsca/nsca.cfg" ], owner => 'nagios', group => 'nogroup', mode => '400', diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 4789345..abaa6e5 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -1,13 +1,18 @@ define nagios::plugin( + $source = 'absent', $ensure = present ){ - file{$name: + @@file{$name: path => $hardwaremodel ? { 'x86_64' => "/usr/lib64/nagios/plugins/$name", default => "/usr/lib/nagios/plugins/$name", }, ensure => $ensure, - source => "puppet://$server/modules/nagios/plugins/$name", + source => $source ? { + 'absent' => "puppet:///modules/nagios/plugins/$name", + default => "puppet:///modules/$source" + }, + tag => 'nagios_plugin', require => Package['nagios-plugins'], owner => root, group => 0, mode => 0755; } diff --git a/manifests/target/nat.pp b/manifests/target/fqdn.pp index abb0a1e..acac5d6 100644 --- a/manifests/target/nat.pp +++ b/manifests/target/fqdn.pp @@ -1,4 +1,4 @@ -class nagios::target::nat inherits nagios::target { +class nagios::target::fqdn inherits nagios::target { Nagios_host["${fqdn}"] { address => "${fqdn}" } |