summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authorGabriel Filion <lelutin@gmail.com>2010-12-14 15:14:54 -0500
committerGabriel Filion <lelutin@gmail.com>2010-12-21 15:38:16 -0500
commit7c9f6d224d9bf66bc1c69b1baa066f98b9302999 (patch)
tree1da169bde639d82b4cd5c8c98c4f81468f68b563 /manifests
parent5d5ec8c28d0fe39359af8db159b14faeae397e1f (diff)
Add nagios IRC bot
Koumbit is using an IRC bot that Micah provided. It is a pair of perl scripts that send Nagios notifications as messages in an IRC channel. Add a class to make installing this IRC bot easy. It also defines commands 'notify-by-irc' and 'host-notify-by-irc' that can be used with checks to send notifications via the bot. Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Diffstat (limited to 'manifests')
-rw-r--r--manifests/irc_bot.pp71
1 files changed, 71 insertions, 0 deletions
diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp
new file mode 100644
index 0000000..4092e67
--- /dev/null
+++ b/manifests/irc_bot.pp
@@ -0,0 +1,71 @@
+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")
+ }
+
+ $nagios_nsa_socket = $nagios_nsa_socket ? {
+ '' => '/var/run/nagios3/nsa.socket',
+ default => $nagios_nsa_socket,
+ }
+ $nagios_nsa_pidfile = $nagios_nsa_pidfile ? {
+ '' => '/var/run/nagios3/nsa.pid',
+ default => $nagios_nsa_pidfile,
+ }
+ $nagios_nsa_port = $nagios_nsa_port ? {
+ '' => '6667',
+ default => $nagios_nsa_port,
+ }
+ $nagios_nsa_realname = $nagios_nsa_realname ? {
+ '' => 'Nagios',
+ default => $nagios_nsa_realname,
+ }
+
+ if (! $nagios_nsa_password) {
+ $nagios_nsa_password = ''
+ }
+
+ file { "/usr/local/bin/riseup-nagios-client.pl":
+ owner => root, group => root, mode => 0755,
+ source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl",
+ }
+ file { "/usr/local/bin/riseup-nagios-server.pl":
+ owner => root, group => root, mode => 0755,
+ source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl",
+ }
+ file { "/etc/init.d/nagios-nsa":
+ owner => root, group => root, mode => 0755,
+ content => template('nagios/irc_bot/nagios-nsa.sh.erb'),
+ require => File["/usr/local/bin/riseup-nagios-server.pl"],
+ }
+ file { "/etc/nagios_nsa.cfg":
+ ensure => present,
+ owner => nagios, group => root, mode => 0400,
+ content => template('nagios/irc_bot/nsa.cfg.erb'),
+ }
+
+ package { "libnet-irc-perl":
+ ensure => present,
+ }
+
+ exec { "nagios_nsa_init_script":
+ command => "/usr/sbin/update-rc.d nagios-nsa defaults",
+ unless => "/bin/ls /etc/rc3.d/ | /bin/grep nagios-nsa",
+ require => File["/etc/init.d/nagios-nsa"],
+ }
+ service { "nagios-nsa":
+ ensure => "running",
+ pattern => "riseup-nagios-server.pl",
+ hasstatus => true,
+ require => [File["/etc/nagios_nsa.cfg"],
+ Exec["nagios_nsa_init_script"],
+ Package["libnet-irc-perl"],
+ Service['nagios'] ],
+ }
+
+ nagios_command {
+ "notify-by-irc":
+ command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ n.$SERVICEATTEMPT$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"';
+ "host-notify-by-irc":
+ command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ n.$HOSTATTEMPT$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"';
+ }
+}