summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2012-09-25 16:27:37 -0400
committerMicah Anderson <micah@riseup.net>2012-09-25 16:27:37 -0400
commit16e77b3a8b257dafcf059bfcebc095178995fda5 (patch)
tree2673fa226de03b0be14ceef4df64140372643ea6
parentad1f714b06faf229ec1b0f310e81c425a6906581 (diff)
parenteafb4c73ee82915bf83eac01bb26265c531a68e2 (diff)
Merge branch 'merge_immerda'
Conflicts: manifests/apache.pp this conflict was just a indentation difference.
-rw-r--r--README87
-rw-r--r--files/nrpe/nrpe_commands.cfg1
-rw-r--r--files/plugins/check_jabber_login30
-rw-r--r--manifests/apache.pp42
-rw-r--r--manifests/base.pp109
-rw-r--r--manifests/centos.pp2
-rw-r--r--manifests/debian.pp4
-rw-r--r--manifests/defaults/commands.pp6
-rw-r--r--manifests/defaults/plugins.pp2
-rw-r--r--manifests/defaults/templates.pp22
-rw-r--r--manifests/defaults/vars.pp6
-rw-r--r--manifests/init.pp46
-rw-r--r--manifests/irc_bot.pp14
-rw-r--r--manifests/irc_bot/base.pp28
-rw-r--r--manifests/lighttpd.pp14
-rw-r--r--manifests/nrpe.pp47
-rw-r--r--manifests/nrpe/base.pp50
-rw-r--r--manifests/nrpe/command.pp33
-rw-r--r--manifests/nrpe/freebsd.pp16
-rw-r--r--manifests/nrpe/linux.pp9
-rw-r--r--manifests/nrpe/xinetd.pp11
-rw-r--r--manifests/nsca/client.pp6
-rw-r--r--manifests/nsca/server.pp4
-rw-r--r--manifests/plugin.pp12
-rw-r--r--manifests/plugin/deploy.pp12
-rw-r--r--manifests/plugin/scriptpaths.pp2
-rw-r--r--manifests/plugins/jabber.pp10
-rw-r--r--manifests/service.pp4
-rw-r--r--manifests/service/http.pp5
-rw-r--r--manifests/service/mysql.pp8
-rw-r--r--manifests/service/ntp.pp8
-rw-r--r--manifests/service/ping.pp16
-rw-r--r--manifests/target.pp27
-rw-r--r--manifests/target/fqdn.pp13
-rw-r--r--templates/irc_bot/CentOS/nagios-nsa.sh.erb4
-rw-r--r--templates/irc_bot/Debian/nagios-nsa.sh.erb4
-rw-r--r--templates/irc_bot/nsa.cfg.erb23
-rw-r--r--templates/nrpe/nrpe.cfg9
38 files changed, 463 insertions, 283 deletions
diff --git a/README b/README
index de50806..551738f 100644
--- a/README
+++ b/README
@@ -17,6 +17,11 @@ puppetmaster.
You need to be running verison 0.25 or later of puppet.
+! Upgrade Notice !
+
+ * the irc bot variables changed, they previously had $nagios_ prepended
+ but no longer have that. So you will need to change your local config
+ to use $nsa_server instead of $nagios_nsa_server, for example.
Monitor
-------
@@ -31,11 +36,11 @@ Hosts
-----
On a node which shall be monitored with nagios, include the "nagios::target".
-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.
+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
+Pass the $parents variable to the target class 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).
@@ -82,14 +87,14 @@ 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
+. 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
+. 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
@@ -101,7 +106,7 @@ IRC bot
Notifications can easily be sent to an IRC channel by using a bot. To do so,
simply include 'nagios::irc_bot' on the nagios server and define the right
-$nagios_nsa_* variables (see the 'Variables' section below).
+$nsa_* variables (see the 'Variables' section below).
You can then use the notification commands 'notify-by-irc' and
'host-notify-by-irc' with service and host definitions to make them report
@@ -142,41 +147,48 @@ See : http://projects.reductivelabs.com/issues/1180
Variables
=========
-Options to change the behavior of the nagios module:
+Options to change the behavior of the nagios class:
+
+- allow_external_cmd: Set to true, if you'd like to ensure that your http
+ daemon can write to the external command file. You
+ may also need to flip "check_external_commands" in
+ "nagios.cfg" to enable this functionality.
+
+For the irc_bot class:
-- nagios_allow_external_cmd: Set to true, if you'd like to ensure that your http
- daemon can write to the external command file. You
- may also need to flip "check_external_commands" in
- "nagios.cfg" to enable this functionality.
+- nsa_socket: This optional variable can be used to specify the path to
+ the socket file that the IRC daemon should use.
-- nagios_nsa_socket: This optional variable can be used to specify the path to
- the socket file that the IRC daemon should use.
+- nsa_server: When using the IRC bot, this defines the server address of
+ the IRC network on which the bot will connect.
-- nagios_nsa_server: When using the IRC bot, this defines the server address of
- the IRC network on which the bot will connect.
+- nsa_port: Defines the port number on the IRC server on which the bot
+ should connect. When this variable is not set, the port used
+ by default is 6667.
-- nagios_nsa_port: Defines the port number on the IRC server on which the bot
- should connect. When this variable is not set, the port used
- by default is 6667.
+- nsa_nickname: This is the nickname that the IRC bot will take.
-- nagios_nsa_nickname: This is the nickname that the IRC bot will take.
+- nsa_password: Some networks require a password to connect to them.
+ This defines such a password.
-- nagios_nsa_password: Some networks require a password to connect to them.
- This defines such a password.
+- nsa_channel: The name of the channel that the IRC bot will join and
+ will post notifications to.
-- nagios_nsa_channel: The name of the channel that the IRC bot will join and
- will post notifications to.
+- nsa_pidfile: This optional variable can be used to define the path to
+ the file that will contain the process ID of the IRC bot
+ daemon.
+- nsa_realname: The IRC bot user's real name that will be displayed. By
+ default, the real name is 'Nagios'.
-- nagios_nsa_pidfile: This optional variable can be used to define the path to
- the file that will contain the process ID of the IRC bot
- daemon.
-- nagios_nsa_realname: The IRC bot user's real name that will be displayed. By
- default, the real name is 'Nagios'.
+- nsa_usenotices: The IRC bot will by default "say" to the channel the
+ nagios message, but you can switch this variable to
+ 'notice' if you would prefer them to be sent as IRC
+ NOTICE messages.
-- nagios_nsa_usenotices: The IRC bot will by default "say" to the channel the
- nagios message, but you can switch this variable to
- 'notice' if you would prefer them to be sent as IRC
- NOTICE messages.
+PNP4Nagios Nagios Grapher integration
+=====================================
+
+see README.pnp4nagios
PNP4Nagios integration
======================
@@ -231,9 +243,10 @@ $HOSTADDRESS$'
node target {
- # Monitor th () is host
- $nagios_parents = 'router01'
- include nagios::target
+ # Monitor this host
+ class{'nagios::target':
+ parents = 'router01'
+ }
# monitor a service
$apache2_port = 8080
diff --git a/files/nrpe/nrpe_commands.cfg b/files/nrpe/nrpe_commands.cfg
index 1a26cc3..b725a36 100644
--- a/files/nrpe/nrpe_commands.cfg
+++ b/files/nrpe/nrpe_commands.cfg
@@ -1,6 +1,5 @@
# default plugins
command[check_users]=/usr/lib/nagios/plugins/check_users $ARG1$
-command[check_load]=/usr/lib/nagios/plugins/check_load $ARG1$
command[check_disk]=/usr/lib/nagios/plugins/check_disk $ARG1$ -x "/dev" -x "/dev/shm" -x "/lib/init/rw"
command[check_apt]=sudo /usr/lib/nagios/plugins/check_apt -u $ARG1$
command[check_swap]=/usr/lib/nagios/plugins/check_swap $ARG1$
diff --git a/files/plugins/check_jabber_login b/files/plugins/check_jabber_login
new file mode 100644
index 0000000..dac0e1f
--- /dev/null
+++ b/files/plugins/check_jabber_login
@@ -0,0 +1,30 @@
+#!/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/manifests/apache.pp b/manifests/apache.pp
index 59a62f6..a90d0ee 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -1,21 +1,29 @@
-class nagios::apache inherits ::apache {
- $nagios_httpd = 'apache'
- include nagios
+class nagios::apache(
+ $allow_external_cmd = false,
+ $manage_shorewall = false,
+ $manage_munin = false
+) {
+ class{'nagios':
+ httpd => 'apache',
+ allow_external_cmd => $allow_external_cmd,
+ manage_munin => $manage_munin,
+ manage_shorewall => $manage_shorewall,
+ }
- case $operatingsystem {
- 'debian': {
- file { "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf":
- ensure => present,
- source => ["puppet:///modules/site_nagios/configs/${fqdn}/apache2.conf",
- "puppet:///modules/site_nagios/configs/apache2.conf",
- "puppet:///modules/nagios/configs/apache2.conf"],
- }
+ case $::operatingsystem {
+ 'debian': {
+ file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf":
+ ensure => present,
+ source => [ "puppet:///site_nagios/configs/${::fqdn}/apache2.conf",
+ "puppet:///site_nagios/configs/apache2.conf",
+ "puppet:///nagios/configs/apache2.conf"],
+ }
- apache::config::global { "nagios3.conf":
- ensure => link,
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf",
- require => File["${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf"],
- }
- }
+ apache::config::global { "nagios3.conf":
+ ensure => link,
+ target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf",
+ require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"],
+ }
}
+ }
}
diff --git a/manifests/base.pp b/manifests/base.pp
index 589e98b..d4d6590 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -4,7 +4,7 @@ class nagios::base {
package { 'nagios':
alias => 'nagios',
- ensure => present,
+ ensure => present,
}
service { 'nagios':
@@ -16,15 +16,15 @@ class nagios::base {
# this file should contain all the nagios_puppet-paths:
file { 'nagios_main_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",
+ path => "${nagios::defaults::vars::int_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_commands_cfg':
path => "${nagios::defaults::vars::int_nagios_cfgdir}/commands.cfg",
@@ -34,26 +34,25 @@ class nagios::base {
}
file { 'nagios_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",
+ path => "${nagios::defaults::vars::int_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::defaults::vars::int_nagios_cfgdir}/htpasswd.users",
- source => [ "puppet:///modules/site-nagios/htpasswd.users",
+ path => "${nagios::defaults::vars::int_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::defaults::vars::int_nagios_cfgdir}/private/",
- source => "puppet:///modules/common/empty",
+ path => "${nagios::defaults::vars::int_cfgdir}/private/",
ensure => directory,
purge => true,
recurse => true,
@@ -62,24 +61,21 @@ class nagios::base {
}
file { 'nagios_private_resource_cfg':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/resource.cfg",
- source => [ "puppet:///modules/site-nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}",
- "puppet:///modules/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}" ],
+ path => "${nagios::defaults::vars::int_cfgdir}/private/resource.cfg",
+ source => [ "puppet:///modules/site_nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}",
+ "puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ],
notify => Service['nagios'],
owner => root, group => nagios, mode => '0640';
}
file { 'nagios_confd':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/",
- source => "puppet:///modules/common/empty",
+ path => "${nagios::defaults::vars::int_cfgdir}/conf.d/",
ensure => directory,
purge => true,
recurse => true,
notify => Service['nagios'],
mode => '0750', owner => root, group => nagios;
}
- Package <<| tag == 'nagios::plugin::deploy::package' |>>
- File <<| tag == 'nagios::plugin::deploy::file' |>>
Nagios_command <<||>>
Nagios_contactgroup <<||>>
Nagios_contact <<||>>
@@ -94,91 +90,90 @@ class nagios::base {
Nagios_serviceextinfo <<||>>
Nagios_service <<||>>
Nagios_timeperiod <<||>>
- File <<| tag == 'nagios_plugin' |>>
Nagios_command <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_contact <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_contactgroup <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_host <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_hostdependency <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg",
notify => Service['nagios'],
}
Nagios_hostescalation <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg",
notify => Service['nagios'],
}
Nagios_hostextinfo <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_hostgroup <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_service <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_servicegroup <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg",
notify => Service['nagios'],
}
Nagios_servicedependency <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_serviceescalation <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_serviceextinfo <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_timeperiod <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
- 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_hostdependency.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.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_servicegroup.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg" ]:
+ file{[ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroupescalation.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg" ]:
ensure => file,
replace => false,
notify => Service['nagios'],
@@ -188,17 +183,11 @@ class nagios::base {
# manage nagios cfg files
# must be defined after exported resource overrides and cfg file defs
file { 'nagios_cfgdir':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/",
- source => "puppet:///modules/common/empty",
+ path => "${nagios::defaults::vars::int_cfgdir}/",
ensure => directory,
recurse => true,
purge => true,
notify => Service['nagios'],
mode => 0755, owner => root, group => root;
}
-
- if $use_munin {
- include nagios::munin
- }
-
}
diff --git a/manifests/centos.pp b/manifests/centos.pp
index 35379b8..5a2ba23 100644
--- a/manifests/centos.pp
+++ b/manifests/centos.pp
@@ -9,7 +9,7 @@ class nagios::centos inherits nagios::base {
hasstatus => true,
}
- if ($nagios_allow_external_cmd) {
+ if $nagios::allow_external_cmd {
file { '/var/spool/nagios/cmd':
ensure => 'directory',
require => Package['nagios'],
diff --git a/manifests/debian.pp b/manifests/debian.pp
index b9e87ec..bb9bb38 100644
--- a/manifests/debian.pp
+++ b/manifests/debian.pp
@@ -14,13 +14,13 @@ class nagios::debian inherits nagios::base {
File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' }
- file { "${nagios::defaults::vars::int_nagios_cfgdir}/stylesheets":
+ file { "${nagios::defaults::vars::int_cfgdir}/stylesheets":
ensure => directory,
purge => false,
recurse => true,
}
- if ($nagios_allow_external_cmd) {
+ if $nagios::allow_external_cmd {
exec { 'nagios_external_cmd_perms_overrides':
command => 'dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3',
unless => 'dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3',
diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp
index 1213485..bb19638 100644
--- a/manifests/defaults/commands.pp
+++ b/manifests/defaults/commands.pp
@@ -4,7 +4,7 @@ class nagios::defaults::commands {
include nagios::command::imap_pop3
# common service commands
- case $operatingsystem {
+ case $::operatingsystem {
debian,ubuntu: {
nagios_command {
check_dummy:
@@ -66,7 +66,7 @@ class nagios::defaults::commands {
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$';
+ command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$';
check_https_url:
command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$';
check_https_url_regex:
@@ -124,7 +124,7 @@ class nagios::defaults::commands {
# notification commands
- $mail_cmd_location = $operatingsystem ? {
+ $mail_cmd_location = $::operatingsystem ? {
centos => '/bin/mail',
default => '/usr/bin/mail'
}
diff --git a/manifests/defaults/plugins.pp b/manifests/defaults/plugins.pp
index 18f8161..abd8b52 100644
--- a/manifests/defaults/plugins.pp
+++ b/manifests/defaults/plugins.pp
@@ -1,5 +1,4 @@
class nagios::defaults::plugins {
-
nagios::plugin {
'check_mysql_health':
source => 'nagios/plugins/check_mysql_health';
@@ -8,5 +7,4 @@ class nagios::defaults::plugins {
'check_dnsbl':
source => 'nagios/plugins/check_dnsbl';
}
-
}
diff --git a/manifests/defaults/templates.pp b/manifests/defaults/templates.pp
index c97eee4..0e73c97 100644
--- a/manifests/defaults/templates.pp
+++ b/manifests/defaults/templates.pp
@@ -1,15 +1,15 @@
class nagios::defaults::templates {
- include nagios::defaults::vars
+ include nagios::defaults::vars
- file { 'nagios_templates':
- 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;
- }
+ file { 'nagios_templates':
+ path => "${nagios::defaults::vars::int_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
index 6302f13..87f41f8 100644
--- a/manifests/defaults/vars.pp
+++ b/manifests/defaults/vars.pp
@@ -1,10 +1,10 @@
class nagios::defaults::vars {
- case $nagios_cfgdir {
- '': { $int_nagios_cfgdir = $operatingsystem ? {
+ case $nagios::cfgdir {
+ '': { $int_cfgdir = $::operatingsystem ? {
centos => '/etc/nagios/',
default => '/etc/nagios3'
}
}
- default: { $int_nagios_cfgdir = $nagios_cfgdir }
+ default: { $int_cfgdir = $nagios::cfgdir }
}
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 1aecc3a..12d3db2 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -8,28 +8,36 @@
# Marcel Härry haerry+puppet(at)puzzle.ch
# Simon Josi josi+puppet(at)puzzle.ch
#
-# This program is free software; you can redistribute
-# it and/or modify it under the terms of the GNU
-# General Public License version 3 as published by
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of the GNU
+# General Public License version 3 as published by
# the Free Software Foundation.
#
-class nagios {
- case $nagios_httpd {
- 'absent': { }
- 'lighttpd': { include lighttpd }
- 'apache': { include apache }
- default: { include apache }
+class nagios(
+ $httpd = 'apache',
+ $allow_external_cmd = false,
+ $manage_shorewall = false,
+ $manage_munin = false
+) {
+ case $nagios::httpd {
+ 'absent': { }
+ 'lighttpd': { include ::lighttpd }
+ 'apache': { include ::apache }
+ default: { include ::apache }
+ }
+ case $::operatingsystem {
+ 'centos': {
+ $cfgdir = '/etc/nagios'
+ include nagios::centos
}
- case $operatingsystem {
- 'centos': {
- $nagios_cfgdir = '/etc/nagios'
- include nagios::centos
- }
- 'debian': {
- $nagios_cfgdir = '/etc/nagios3'
- include nagios::debian
- }
- default: { fail("No such operatingsystem: $operatingsystem yet defined") }
+ 'debian': {
+ $cfgdir = '/etc/nagios3'
+ include nagios::debian
}
+ default: { fail("No such operatingsystem: ${::operatingsystem} yet defined") }
+ }
+ if $manage_munin {
+ include nagios::munin
+ }
}
diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp
index 7629b94..a034fe0 100644
--- a/manifests/irc_bot.pp
+++ b/manifests/irc_bot.pp
@@ -1,22 +1,22 @@
class nagios::irc_bot {
- if ( ! ($nagios_nsa_server and $nagios_nsa_nickname and $nagios_nsa_channel) ) {
- fail("Please provide values at least for \$nagios_nsa_server, \$nagios_nsa_nickname and \$nagios_nsa_channel")
+ if ( ! ($nsa_server and $nsa_nickname and $nsa_channel) ) {
+ fail("Please provide values at least for \$nsa_server, \$nsa_nickname and \$nsa_channel")
}
case $operatingsystem {
centos: {
- $nagios_nsa_default_socket = '/var/run/nagios-nsa/nsa.socket'
- $nagios_nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid'
+ $nsa_default_socket = '/var/run/nagios-nsa/nsa.socket'
+ $nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid'
include nagios::irc_bot::centos
}
default: {
- $nagios_nsa_default_socket = '/var/run/nagios3/nsa.socket'
- $nagios_nsa_default_pidfile = '/var/run/nagios3/nsa.pid'
+ $nsa_default_socket = '/var/run/nagios3/nsa.socket'
+ $nsa_default_pidfile = '/var/run/nagios3/nsa.pid'
include nagios::irc_bot::base
}
}
- if $use_shorewall {
+ if $nagios::manage_shorewall {
include shorewall::rules::out::irc
}
}
diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp
index c36d8e6..6fab2ac 100644
--- a/manifests/irc_bot/base.pp
+++ b/manifests/irc_bot/base.pp
@@ -1,29 +1,29 @@
class nagios::irc_bot::base {
# Default values for the two first variables are defined in nagios::irc_bot
- $nagios_nsa_socket = $nagios_nsa_socket ? {
- '' => $nagios_nsa_default_socket,
- default => $nagios_nsa_socket,
+ $nsa_socket = $nsa_socket ? {
+ '' => $nsa_default_socket,
+ default => $nsa_socket,
}
- $nagios_nsa_pidfile = $nagios_nsa_pidfile ? {
- '' => $nagios_nsa_default_pidfile,
- default => $nagios_nsa_pidfile,
+ $nsa_pidfile = $nsa_pidfile ? {
+ '' => $nsa_default_pidfile,
+ default => $nsa_pidfile,
}
- $nagios_nsa_port = $nagios_nsa_port ? {
+ $nsa_port = $nsa_port ? {
'' => '6667',
- default => $nagios_nsa_port,
+ default => $nsa_port,
}
- $nagios_nsa_realname = $nagios_nsa_realname ? {
+ $nsa_realname = $nsa_realname ? {
'' => 'Nagios',
- default => $nagios_nsa_realname,
+ default => $nsa_realname,
}
- if (! $nagios_nsa_password) {
- $nagios_nsa_password = ''
+ if (! $nsa_password) {
+ $nsa_password = ''
}
- if (! $nagios_nsa_usenotices) {
- $nagios_nsa_usenotices = ''
+ if (! $nsa_usenotices) {
+ $nsa_usenotices = ''
}
file { "/usr/local/bin/riseup-nagios-client.pl":
diff --git a/manifests/lighttpd.pp b/manifests/lighttpd.pp
index 27aff43..0f29896 100644
--- a/manifests/lighttpd.pp
+++ b/manifests/lighttpd.pp
@@ -1,4 +1,12 @@
-class nagios::lighttpd {
- $nagios_httpd = 'lighttpd'
- include nagios
+class nagios::lighttpd(
+ $allow_external_cmd = false,
+ $manage_shorewall = false,
+ $manage_munin = false
+) {
+ class{'nagios':
+ httpd => 'lighttpd',
+ allow_external_cmd => $allow_external_cmd,
+ manage_munin => $manage_munin,
+ manage_shorewall => $manage_shorewall,
+ }
}
diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp
index ff22441..5c05ed4 100644
--- a/manifests/nrpe.pp
+++ b/manifests/nrpe.pp
@@ -1,37 +1,22 @@
class nagios::nrpe {
- if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' }
+ case $operatingsystem {
+ 'FreeBSD': {
+ if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/usr/local/etc' }
+ if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/spool/nagios/nrpe2.pid' }
+ if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/local/libexec/nagios' }
- package { "nagios-nrpe-server": ensure => latest;
- "nagios-plugins-basic": ensure => latest;
- "nagios-plugins-standard": ensure => latest;
- "libnagios-plugin-perl": ensure => present;
- "libwww-perl": ensure => present; # für check_apache
- "ksh": ensure => present; # für check_cpustats.sh
- "sysstat": ensure => present; # für check_cpustats.sh
- }
+ include nagios::nrpe::freebsd
+ }
+ default: {
+ if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nrpe.pid' }
+ if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' }
- file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]:
- ensure => directory }
-
- file { "$nagios_nrpe_cfgdir/nrpe.cfg":
- content => template('nagios/nrpe/nrpe.cfg'),
- owner => root, group => root, mode => 644;
- }
-
- # default commands
- file { "$nagios_nrpe_cfgdir/nrpe.d/nrpe_commands.cfg":
- source => [ "puppet:///site-nagios/nrpe/nrpe_commands.cfg",
- "puppet:///nagios/nrpe/nrpe_commands.cfg" ],
- owner => root, group => root, mode => 644;
- }
-
- service { "nagios-nrpe-server":
- ensure => running,
- enable => true,
- pattern => "nrpe",
- subscribe => [ File["$nagios_nrpe_cfgdir/nrpe.cfg"],
- File["$nagios_nrpe_cfgdir/nrpe.d/nrpe_commands.cfg"] ]
- }
+ case $kernel {
+ linux: { include nagios::nrpe::linux }
+ default: { include nagios::nrpe::base }
+ }
+ }
+ }
}
diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp
new file mode 100644
index 0000000..17abb04
--- /dev/null
+++ b/manifests/nrpe/base.pp
@@ -0,0 +1,50 @@
+class nagios::nrpe::base {
+
+ if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' }
+ if $processorcount == '' { $processorcount = 1 }
+
+ package { "nagios-nrpe-server": ensure => present;
+ "nagios-plugins-basic": ensure => present;
+ "libwww-perl": ensure => present; # for check_apache
+ }
+
+ # Special-case lenny. the package doesn't exist
+ if $lsbdistcodename != 'lenny' {
+ package { "libnagios-plugin-perl": ensure => present; }
+ }
+
+ file { [ $nagios_nrpe_cfgdir, "$nagios_nrpe_cfgdir/nrpe.d" ]:
+ ensure => directory }
+
+ if $nagios_nrpe_dont_blame == '' { $nagios_nrpe_dont_blame = 1 }
+ file { "$nagios_nrpe_cfgdir/nrpe.cfg":
+ content => template('nagios/nrpe/nrpe.cfg'),
+ owner => root, group => 0, mode => 644;
+ }
+
+ # default commands
+ nagios::nrpe::command { "basic_nrpe":
+ source => [ "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.${fqdn}.cfg",
+ "puppet:///modules/site-nagios/configs/nrpe/nrpe_commands.cfg",
+ "puppet:///modules/nagios/nrpe/nrpe_commands.cfg" ],
+ }
+ # the check for load should be customized for each server based on number
+ # of CPUs and the type of activity.
+ $warning_1_threshold = 7 * $processorcount
+ $warning_5_threshold = 6 * $processorcount
+ $warning_15_threshold = 5 * $processorcount
+ $critical_1_threshold = 10 * $processorcount
+ $critical_5_threshold = 9 * $processorcount
+ $critical_15_threshold = 8 * $processorcount
+ nagios::nrpe::command { "check_load":
+ command_line => "${nagios_plugin_dir}/check_load -w ${warning_1_threshold},${warning_5_threshold},${warning_15_threshold} -c ${critical_1_threshold},${critical_5_threshold},${critical_15_threshold}",
+ }
+
+ service { "nagios-nrpe-server":
+ ensure => running,
+ enable => true,
+ pattern => "nrpe",
+ subscribe => File["$nagios_nrpe_cfgdir/nrpe.cfg"],
+ require => Package["nagios-nrpe-server"],
+ }
+}
diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp
new file mode 100644
index 0000000..e6ebdae
--- /dev/null
+++ b/manifests/nrpe/command.pp
@@ -0,0 +1,33 @@
+define nagios::nrpe::command (
+ $ensure = present,
+ $command_line = '',
+ $source = '' )
+{
+ if ($command_line == '' and $source == '') {
+ fail ( "Either one of 'command_line' or 'source' must be given to nagios::nrpe::command." )
+ }
+
+ if $nagios_nrpe_cfg_dir == '' {
+ $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir
+ }
+
+ file { "$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg":
+ ensure => $ensure,
+ mode => 644, owner => root, group => 0,
+ notify => Service['nagios-nrpe-server'],
+ require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ]
+ }
+
+ case $source {
+ '': {
+ File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] {
+ content => template( "nagios/nrpe/nrpe_command.erb" ),
+ }
+ }
+ default: {
+ File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] {
+ source => $source,
+ }
+ }
+ }
+}
diff --git a/manifests/nrpe/freebsd.pp b/manifests/nrpe/freebsd.pp
new file mode 100644
index 0000000..063b79b
--- /dev/null
+++ b/manifests/nrpe/freebsd.pp
@@ -0,0 +1,16 @@
+class nagios::nrpe::freebsd inherits nagios::nrpe::base {
+
+ Package["nagios-nrpe-server"] { name => "nrpe" }
+ Package["nagios-plugins-basic"] { name => "nagios-plugins" }
+ Package["libnagios-plugin-perl"] { name => "p5-Nagios-Plugin" }
+ Package["libwww-perl"] { name => "p5-libwww" }
+
+ # TODO check_cpustats.sh is probably not working as of now. the package 'sysstat' is not available under FreeBSD
+
+ Service["nagios-nrpe-server"] {
+ pattern => "^/usr/local/sbin/nrpe2",
+ path => "/usr/local/etc/rc.d",
+ name => "nrpe2",
+ hasstatus => "false",
+ }
+}
diff --git a/manifests/nrpe/linux.pp b/manifests/nrpe/linux.pp
new file mode 100644
index 0000000..14e007f
--- /dev/null
+++ b/manifests/nrpe/linux.pp
@@ -0,0 +1,9 @@
+class nagios::nrpe::linux inherits nagios::nrpe::base {
+
+ package {
+ "nagios-plugins-standard": ensure => present;
+ "ksh": ensure => present; # for check_cpustats.sh
+ "sysstat": ensure => present; # for check_cpustats.sh
+ }
+
+}
diff --git a/manifests/nrpe/xinetd.pp b/manifests/nrpe/xinetd.pp
new file mode 100644
index 0000000..e13ed76
--- /dev/null
+++ b/manifests/nrpe/xinetd.pp
@@ -0,0 +1,11 @@
+# This is created only to cope with cases where we're not the only ones
+# administering a machine and NRPE is running in xinetd.
+class nagios::nrpe::xinetd inherits base {
+
+ Service ["nagios-nrpe-server"] {
+ ensure => stopped,
+ }
+
+ # TODO manage the xinetd config file that glues with NRPE
+
+}
diff --git a/manifests/nsca/client.pp b/manifests/nsca/client.pp
index 6e2c472..e58721d 100644
--- a/manifests/nsca/client.pp
+++ b/manifests/nsca/client.pp
@@ -1,10 +1,10 @@
class nagios::nsca::client {
package { 'nsca': ensure => installed }
-
+
file { '/etc/send_nsca.cfg':
- source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/send_nsca.cfg",
- "puppet:///modules/site-nagios/nsca/send_nsca.cfg",
+ source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/send_nsca.cfg",
+ "puppet:///modules/site_nagios/nsca/send_nsca.cfg",
"puppet:///modules/nagios/nsca/send_nsca.cfg" ],
owner => 'nagios',
group => 'nogroup',
diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp
index 238e49e..bd5389d 100644
--- a/manifests/nsca/server.pp
+++ b/manifests/nsca/server.pp
@@ -10,8 +10,8 @@ class nagios::nsca::server {
}
file { '/etc/nsca.cfg':
- source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/nsca.cfg",
- "puppet:///modules/site-nagios/nsca/nsca.cfg",
+ source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/nsca.cfg",
+ "puppet:///modules/site_nagios/nsca/nsca.cfg",
"puppet:///modules/nagios/nsca/nsca.cfg" ],
owner => 'nagios',
group => 'nogroup',
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
index abaa6e5..d32606b 100644
--- a/manifests/plugin.pp
+++ b/manifests/plugin.pp
@@ -2,15 +2,15 @@ define nagios::plugin(
$source = 'absent',
$ensure = present
){
- @@file{$name:
- path => $hardwaremodel ? {
- 'x86_64' => "/usr/lib64/nagios/plugins/$name",
- default => "/usr/lib/nagios/plugins/$name",
+ file{$name:
+ path => $::hardwaremodel ? {
+ 'x86_64' => "/usr/lib64/nagios/plugins/${name}",
+ default => "/usr/lib/nagios/plugins/${name}",
},
ensure => $ensure,
source => $source ? {
- 'absent' => "puppet:///modules/nagios/plugins/$name",
- default => "puppet:///modules/$source"
+ 'absent' => "puppet:///modules/nagios/plugins/${name}",
+ default => "puppet:///modules/${source}"
},
tag => 'nagios_plugin',
require => Package['nagios-plugins'],
diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp
index 75f87d7..3f2a1a4 100644
--- a/manifests/plugin/deploy.pp
+++ b/manifests/plugin/deploy.pp
@@ -5,26 +5,26 @@ define nagios::plugin::deploy($source = '', $ensure = 'present', $config = '', $
default => $ensure
}
$real_source = $source ? {
- '' => "nagios/plugins/$plugin_src",
+ '' => "nagios/plugins/${plugin_src}",
default => $source
}
if !defined(Package[$require_package]) {
- @@package { $require_package:
+ package { $require_package:
ensure => installed,
tag => "nagios::plugin::deploy::package";
}
}
-
+
include nagios::plugin::scriptpaths
- @@file { "nagios_plugin_${name}":
+ file { "nagios_plugin_${name}":
path => "$nagios::plugin::scriptpaths::script_path/${name}",
- source => "puppet://$server/modules/$real_source",
+ source => "puppet:///modules/${real_source}",
mode => 0755, owner => root, group => 0,
require => Package[$require_package],
tag => "nagios::plugin::deploy::file";
}
# register the plugin
- @@nagios::plugin{$name: ensure => $ensure, require => Package['nagios-plugins'] }
+ nagios::plugin{$name: ensure => $ensure, require => Package['nagios-plugins'] }
}
diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp
index 6065709..9cd4b5d 100644
--- a/manifests/plugin/scriptpaths.pp
+++ b/manifests/plugin/scriptpaths.pp
@@ -1,5 +1,5 @@
class nagios::plugin::scriptpaths {
- case $hardwaremodel {
+ case $::hardwaremodel {
x86_64: { $script_path = "/usr/lib64/nagios/plugins/" }
default: { $script_path = "/usr/lib/nagios/plugins" }
}
diff --git a/manifests/plugins/jabber.pp b/manifests/plugins/jabber.pp
new file mode 100644
index 0000000..380a5c0
--- /dev/null
+++ b/manifests/plugins/jabber.pp
@@ -0,0 +1,10 @@
+class nagios::plugins::jabber {
+
+ # for check_jabber_login
+ require rubygems::xmpp4r
+
+ nagios::plugin { 'check_jabber_login':
+ source => 'nagios/plugins/check_jabber_login'
+ }
+}
+
diff --git a/manifests/service.pp b/manifests/service.pp
index 55b2254..71f78b0 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -1,6 +1,6 @@
define nagios::service (
$ensure = present,
- $host_name = $fqdn,
+ $host_name = $::fqdn,
$check_command,
$check_period = '',
$normal_check_interval = '',
@@ -19,7 +19,7 @@ define nagios::service (
# TODO: this resource should normally accept all nagios_host parameters
- $real_name = "${hostname}_${name}"
+ $real_name = "${::hostname}_${name}"
if ($use_nrpe == 'true') {
include nagios::command::nrpe_timeout
diff --git a/manifests/service/http.pp b/manifests/service/http.pp
index 8fd5059..ef63abb 100644
--- a/manifests/service/http.pp
+++ b/manifests/service/http.pp
@@ -6,6 +6,7 @@
define nagios::service::http(
$ensure = present,
$check_domain = 'absent',
+ $port = '80',
$check_url = '/',
$check_code = 'OK',
$use = 'generic-service',
@@ -27,7 +28,7 @@ define nagios::service::http(
nagios::service{"httprd_${name}":
ensure => $ensure,
use => $use,
- check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'301'",
+ check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'301'",
}
}
}
@@ -38,7 +39,7 @@ define nagios::service::http(
nagios::service{"http_${name}_${check_code}":
ensure => $ensure,
use => $use,
- check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'${check_code}'",
+ check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'${check_code}'",
}
}
}
diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp
index 2fde402..94881d8 100644
--- a/manifests/service/mysql.pp
+++ b/manifests/service/mysql.pp
@@ -1,11 +1,11 @@
-# Checks a mysql instance via tcp or socket
+# Checks a mysql instance via tcp or socket
define nagios::service::mysql(
$ensure = present,
$check_host = 'absent',
$check_port = '3306',
$check_username = 'nagios',
- $check_password = $nagios_mysql_password,
+ $check_password = trocla("mysql_nagios_${::fqdn}",'plain','length: 32'),
$check_database = 'information_schema',
$check_warning = undef,
$check_critical = undef,
@@ -28,7 +28,7 @@ define nagios::service::mysql(
if $check_warning != undef {
$real_check_warning = "!--warning $check_warning"
}
-
+
if $check_critical != undef {
$real_check_critical = "!--critical $check_critical"
}
@@ -51,7 +51,7 @@ define nagios::service::mysql(
}
}
}
-
+
nagios::service { "mysql_health_${name}":
ensure => $ensure,
check_command => "check_mysql_health!${real_check_host}!${check_port}!${check_username}!${check_password}!${check_health_mode}!${check_database}${real_check_name}${real_check_warning}${real_check_critical}",
diff --git a/manifests/service/ntp.pp b/manifests/service/ntp.pp
index eca255a..b3cde2a 100644
--- a/manifests/service/ntp.pp
+++ b/manifests/service/ntp.pp
@@ -1,9 +1,9 @@
# manifests/service/ntp.pp
class nagios::service::ntp {
- nagios::service{ "check_ntp":
- check_command => "check_ntp_time",
- host_name => $fqdn,
- }
+ nagios::service{ "check_ntp":
+ check_command => "check_ntp_time",
+ host_name => $::fqdn,
+ }
}
diff --git a/manifests/service/ping.pp b/manifests/service/ping.pp
index c705c68..f1c8d87 100644
--- a/manifests/service/ping.pp
+++ b/manifests/service/ping.pp
@@ -1,13 +1,9 @@
define nagios::service::ping(
- $ensure = present
+ $ensure = present,
+ $ping_rate = '!100.0,20%!500.0,60%'
){
- $real_nagios_ping_rate = $nagios_ping_rate ? {
- '' => '!100.0,20%!500.0,60%',
- default => $nagios_ping_rate
- }
-
- nagios::service{ "check_ping":
- ensure => $ensure,
- check_command => "check_ping${real_nagios_ping_rate}",
- }
+ nagios::service{ "check_ping":
+ ensure => $ensure,
+ check_command => "check_ping${ping_rate}",
+ }
}
diff --git a/manifests/target.pp b/manifests/target.pp
index 675ac1a..f9b7e13 100644
--- a/manifests/target.pp
+++ b/manifests/target.pp
@@ -1,15 +1,22 @@
# manifests/target.pp
-class nagios::target {
+class nagios::target(
+ $parents = 'absent',
+ $address = $::ipaddress,
+ $nagios_alias = $::hostname,
+ $hostgroups = 'absent'
+){
+ @@nagios_host { $::fqdn:
+ address => $address,
+ alias => $nagios_alias,
+ use => 'generic-host',
+ }
- @@nagios_host { "${fqdn}":
- address => $ipaddress,
- alias => $hostname,
- use => 'generic-host',
- }
-
- if ($nagios_parents != '') {
- Nagios_host["${fqdn}"] { parents => $nagios_parents }
- }
+ if ($parents != 'absent') {
+ Nagios_host["${::fqdn}"] { parents => $parents }
+ }
+ if ($hostgroups != 'absent') {
+ Nagios_host["${::fqdn}"] { hostgroups => $hostgroups }
+ }
}
diff --git a/manifests/target/fqdn.pp b/manifests/target/fqdn.pp
index acac5d6..6bb16c1 100644
--- a/manifests/target/fqdn.pp
+++ b/manifests/target/fqdn.pp
@@ -1,5 +1,10 @@
-class nagios::target::fqdn inherits nagios::target {
-
- Nagios_host["${fqdn}"] { address => "${fqdn}" }
-
+class nagios::target::fqdn(
+ $hostgroups = 'absent',
+ $parents = 'absent'
+) {
+ class{'nagios::target':
+ address => $::fqdn,
+ hostgroups => $hostgroups,
+ parents => $parents
+ }
}
diff --git a/templates/irc_bot/CentOS/nagios-nsa.sh.erb b/templates/irc_bot/CentOS/nagios-nsa.sh.erb
index 1561afd..0f9f87b 100644
--- a/templates/irc_bot/CentOS/nagios-nsa.sh.erb
+++ b/templates/irc_bot/CentOS/nagios-nsa.sh.erb
@@ -19,8 +19,8 @@
exec="/usr/local/bin/riseup-nagios-server.pl"
prog="nsa"
-PIDFILE=<%= nagios_nsa_pidfile %>
-SOCKFILE=<%= nagios_nsa_socket %>
+PIDFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_pidfile') %>
+SOCKFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_socket') %>
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
diff --git a/templates/irc_bot/Debian/nagios-nsa.sh.erb b/templates/irc_bot/Debian/nagios-nsa.sh.erb
index c9d1966..43c0e79 100644
--- a/templates/irc_bot/Debian/nagios-nsa.sh.erb
+++ b/templates/irc_bot/Debian/nagios-nsa.sh.erb
@@ -9,8 +9,8 @@
# Short-Description: Nagios Simple IRC Agent
### END INIT INFO
-PIDFILE=<%= nagios_nsa_pidfile %>
-SOCKFILE=<%= nagios_nsa_socket %>
+PIDFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_pidfile') %>
+SOCKFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_socket') %>
. /lib/lsb/init-functions
diff --git a/templates/irc_bot/nsa.cfg.erb b/templates/irc_bot/nsa.cfg.erb
index da6b2f0..9109b55 100644
--- a/templates/irc_bot/nsa.cfg.erb
+++ b/templates/irc_bot/nsa.cfg.erb
@@ -1,14 +1,15 @@
-%Nsa = (
- 'socket' => '<%= nagios_nsa_socket %>',
- 'server' => '<%= nagios_nsa_server %>',
- 'port' => '<%= nagios_nsa_port %>',
- 'nickname' => '<%= nagios_nsa_nickname %>',
- 'password' => '<%= nagios_nsa_password %>',
+%%Nsa = (
+ 'socket' => '<%= scope.lookupvar('nagios::irc_bot::real_nsa_socket') %>',
+ 'server' => '<%= scope.lookupvar('nagios::irc_bot::nsa_server') %>',
+ 'port' => '<%= scope.lookupvar('nagios::irc_bot::nsa_port') %>',
+ 'nickname' => '<%= scope.lookupvar('nagios::irc_bot::nsa_nickname') %>',
+ 'password' => '<%= scope.lookupvar('nagios::irc_bot::nsa_password') %>',
# this needs libio-socket-ssl-perl
# doesn't actually works because Net::IRC is braindead and tries to use IO::Socket::SSL->read/write instead of the builtin print, see http://search.cpan.org/dist/IO-Socket-SSL/SSL.pm
- #'SSL' => 0,
- 'channel' => '<%= nagios_nsa_channel %>',
- 'pidfile' => '<%= nagios_nsa_pidfile %>', # set to undef to disable
- 'realname' => "<%= nagios_nsa_realname %>",
- 'usenotices' => "<%= nagios_nsa_usenotices %>",
+ #'SSL' => 0,
+ 'channel' => '<%= scope.lookupvar('nagios::irc_bot::nsa_channel') %>',
+ 'pidfile' => '<%= scope.lookupvar('nagios::irc_bot::real_nsa_pidfile') %>', # set to undef to disable
+ 'realname' => "<%= scope.lookupvar('nagios::irc_bot::nsa_realname') %>",
+ 'realname' => "<%= scope.lookupvar('nagios::irc_bot::nsa_realname') %>",
+ 'usenotices' => "<%= scope.lookupvar('nagios::irc_bot::nsa_usenotices') %>",
);
diff --git a/templates/nrpe/nrpe.cfg b/templates/nrpe/nrpe.cfg
index b31e5f9..5368bc8 100644
--- a/templates/nrpe/nrpe.cfg
+++ b/templates/nrpe/nrpe.cfg
@@ -16,7 +16,7 @@
# 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/nrpe.pid
+pid_file=<%= nagios_nrpe_pid_file %>
@@ -34,8 +34,11 @@ server_port=5666
# 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=192.168.1.1
-
+<%- if has_variable?("nagios_nrpe_server_address") then %>
+<%- if not nagios_nrpe_server_address.to_s.empty? then %>
+server_address=<%= nagios_nrpe_server_address %>
+<%- end %>
+<%- end %>
# NRPE USER