Browse Source

Merge branch 'master' of ssh://code.ffdn.org:55555/asr/nagios-irssi

Conflicts:
	README.md
Gaétan RYCKEBOER 10 years ago
parent
commit
2d500a88a3

+ 1 - 1
LICENSE

@@ -671,4 +671,4 @@ into proprietary programs.  If your program is a subroutine library, you
 may consider it more useful to permit linking proprietary applications with
 the library.  If this is what you want to do, use the GNU Lesser General
 Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 33 - 27
README.md

@@ -3,16 +3,22 @@ nagios-fifo
 
 IRSSI BOT to handle nagios/irssi communication.
 
+Presentation
+------------
+
 To ease the use of the bot configuration, I use to link different
 files from the BOT configuration director etc/ bin/ var/ up to
 respective irssi directories :
 
-1/ setup an irssi client, inside a screen.
-2/ symlink ~/.irssi/ as etc/config.directory
-3/ symlink the scripts you want to load to as ~/.irssi/scripts/autorun
-4/ edit the ~/.irssi/config to join the communication channel
-5/ symlink it to etc/config.local
-6/ start "screen irssi"
+1. setup an irssi client, inside a screen.
+2. symlink ~/.irssi/ as etc/config.directory
+3. symlink the scripts you want to load to as ~/.irssi/scripts/autorun
+4. edit the ~/.irssi/config to join the communication channel
+5. symlink it to etc/config.local
+6. start "screen irssi  "
+
+How does it works
+------------
 
 The bot is made of 3 scripts :
 - nagios bot ;
@@ -21,31 +27,31 @@ The bot is made of 3 scripts :
 
 all are designed to work standalone.
 
-Commands allowed by nagios-fifo.pl / Nagios module :
+Using the bots
+---------
+
+Commands allowed by *nagios-fifo.pl* / Nagios module :
 The nagios bot is designed to work with nagios notifications, via commands.cfg configuration file.
-- !nagios list [PATTERN] : list of received alerts
-- !nagios help : l'aide");
-- !nagios ack <#ALERT> <message> 
-               : ACK the alert");
-- !nagios check <#ALERT> 
-               : recheck any alert (service/host)
-- !nagios refresh [silent] 
-               : request nagios livestatus and import all unack alerts
-
-Commands allowed by tc-14.pl / Dumb module :
-- !status      to have a look on inner variables / structures (particularly for the bingo module)
-- !password    to generate a random password
-- !help        totally useless
+- `!nagios list [PATTERN]` : list of received alerts
+- `!nagios list` : list of received alerts
+- `!nagios help` : l'aide
+- `!nagios ack <#ALERT> <message>` : ACK the alert
+- `!nagios check <#ALERT>` : recheck any alert (service/host)
+- `!nagios refresh [silent]` : request nagios livestatus and import all unack alerts
+
+Commands allowed by *tc-14.pl* / Dumb module :
+- `!status`      to have a look on inner variables / structures (particularly for the bingo module)
+- `!password`    to generate a random password
+- `!help`        totally useless
 - react to some words (essentially in french, feel free to adapt to your needs) :
   * fortune (displays a fortune cookie sentence) ;
   * any french/flemish/irish beer ;
   * any animal name ;
   * some pedant words, used to check a bingo business card
   * his own name
-  
-Commands allowed by tweet.pl / admin module :
-- !tweet        : tweet a tweet, on twitter and identi.ca (twitter module broken, to be redisigned)
-- !tweet last   : what was last tweet ?
-- !changelog    : add/list lasts changelogs
-- !lastlog [pattern] 
-                : display last 20 messages [about pattern]
+
+Commands allowed by *tweet.pl* / admin module :
+- `!tweet`        : tweet a tweet, on twitter and identi.ca (twitter module broken, to be redisigned)
+- `!tweet last`   : what was last tweet ?
+- `!changelog`    : add/list lasts changelogs
+- `!lastlog [pattern]` : display last 20 messages [about pattern]

+ 23 - 23
bin/nagios-fifo.pl

@@ -89,20 +89,20 @@ my %C = (
 	Ma => "\x0313", #	12. Light Blue (Royal)
 	Gr => "\x0314", #	13. Pink (Light Purple) (Fuchsia)
 	W  => "\x0315", #	14. Grey
-                        #	15. Light Grey (Silver)             
+                        #	15. Light Grey (Silver)
 	Z => "\x03",
 );
 
 # Numeric to string conversion of nagios status
 # 0..4   : hosts
 # 10..14 : services
-my @NagStates = qw/UP DOWN WARNING UNKNOWN .. .. .. .. .. .. 
+my @NagStates = qw/UP DOWN WARNING UNKNOWN .. .. .. .. .. ..
                   OK WARNING CRITICAL UNKNOWN/;
 
 #    Bold: U+0002 ("0x02") — Example: ^Bold Text^ whereas ^ represents the control character.
 #    Italics: U+001D ("0x1D") — Example: ^Italicized Text^ whereas ^ represents the control character.
 #    Underline: U+001F ("0x1F") — Example: ^Underlined Text^ whereas ^ represents the control character.
-#    The control character used for color is U+0003 ("0x03"). 
+#    The control character used for color is U+0003 ("0x03").
 
 my $state_to_color = {
 	OK => $C{G},
@@ -124,7 +124,7 @@ my ($d,$type,$host,$service,$state,$output);
 my ( $host, $svc, $state, $msg, $id );
 
 my ($server, $msg, $nick, $addr, $target);
-my ( $param, $server, $window ); 
+my ( $param, $server, $window );
 my (@issue, $issue);
 
 #my $state_to_color = { OK => '', UP => '', WARNING => '', CRITICAL => '', DOWN => '', UNKNOWN => '' };
@@ -133,7 +133,7 @@ my (@issue, $issue);
 
 my $last_alert;
 
-my $DEBUG=Irssi::settings_get_str("nagios_ack_channel"); 
+my $DEBUG=Irssi::settings_get_str("nagios_ack_channel");
 
 # Simple subs ############################################################
 sub TRUE()   { 1  }                            # some constants [perlsyn(1)
@@ -153,7 +153,7 @@ sub time2date($) {
 # where is the memory leak.
 
 # Four unused subs. Still there to be implemented later
-sub parse_status(); 
+sub parse_status();
 sub nagios_ack($$$);
 sub nagios_check($$$);
 sub nagios_inject;
@@ -216,9 +216,9 @@ sub event_privmsg ($$$$);
 
 # REFERENCES
 # ----------
-# 
+#
 # This script is mainly adapted from 3 other scripts related to nagios :
-# 
+#
 # https://github.com/zorkian/nagios-irc-bot/blob/master/nagiosirc.pl
 # http://www.update.uu.se/~zrajm/programs/irssi-scripts/fifo_remote.pl-0.5
 # https://github.com/mikegrb/irssi-scripts/blob/master/nagios-ack.pl
@@ -226,7 +226,7 @@ sub event_privmsg ($$$$);
 ##########################################################################
 # CODE ###################################################################
 ##########################################################################
- 
+
 ##########################################################################
 # Part B : user Actions ##################################################
 
@@ -294,11 +294,11 @@ sub insert_alert($$$$$) {
 			if (($ACKS[$i]->[0] eq $host) && ($ACKS[$i]->[1] eq $svc)) {
 				$ACKS[$i]->[4]=$d;
 				Irssi::print(">> found $i");
-				if ($ACKS[$i]->[2] ne $state) { 
+				if ($ACKS[$i]->[2] ne $state) {
 					# Same alert, but different level
-					$ACKS[$i]->[2]=$state; 
+					$ACKS[$i]->[2]=$state;
 					return format_alert_id('C', $i, $state);
-				} else { 
+				} else {
 					# Same alert
 					return format_alert_id('!', $i, $state);
 					# No need to display...
@@ -365,7 +365,7 @@ sub open_fifo($) {                             # [2004-08-14]
         fileno($FIFO_HANDLE), INPUT_READ,      #     there's input in the pipe
         \&read_fifo, '';                       #
     return 1;                                  #
-}             
+}
 
 # read from fifo
 # (called by fifo input signal)
@@ -383,7 +383,7 @@ sub read_fifo() {                              # [2004-08-14]
         # TODO: Is the above re-opening of fifo really necessary? -- If not
         # invoked here `read_fifo' is called repeatedly, even though no input
         # is to be found on the fifo. (This seems a waste of resources to me.)
-}                 
+}
 
 # create named fifo and open it for input
 # (called on script load and fifo name changes)
@@ -391,7 +391,7 @@ sub create_fifo($) {                           # [2004-08-14]
     my ($new_fifo) = @_;                       #   get args
     if (not -p $new_fifo) {                    #   create fifo if non-existant
         if (system "mkfifo '$new_fifo' &>/dev/null" and
-            system "chmod 777  '$new_fifo' &>/dev/null" and 
+            system "chmod 777  '$new_fifo' &>/dev/null" and
             system "mknod  '$new_fifo' &>/dev/null"){
             print CLIENTERROR "`mkfifo' failed -- could not create named pipe";
                 # TODO: capture `mkfifo's stderr and show that here
@@ -408,7 +408,7 @@ sub create_fifo($) {                           # [2004-08-14]
 sub nagios_query_status($){
 	# 1412478149;hyppocampe;apt;2;CRITICAL : unknown: qemu-utils, qemu-kvm, qemu-keymaps
 	my ($option)=@_;
-	my @unixcat; 
+	my @unixcat;
 	my $unixline;
 	$nagioscmd = Irssi::settings_get_str("nagios_command");
         foreach $unixline ( `echo "GET services
@@ -455,7 +455,7 @@ sub parse_nagios_log($){
 	# HOST ########################
 		($d,$host,$state,$output)=@match;
 		handle_alert($option,$d,"HOST",$host,$state,$output,$service);
-		
+
 	# SERVICE #####################
 	} elsif (@match=$status_line =~ /\[?(\d+)\]? (\w+) ALERT: ([^;@]+)[@;]([^;@]+)[@;]([^;@]+)[@;]HARD[@;][^;@]*[@;](.+)/) {
 		($d,$type,$host,$service,$state,$output)=@match;
@@ -488,7 +488,7 @@ sub handle_alert($$$$$$$) { # $d,$type,$host,$state,$output,$service
 	# HOST or SERVICE ?
 	$id = insert_alert($host,$service,$state,$output,$d);
 	$msg = "$id".$state_to_color->{$state} . "$host:$service".$C{Z}." is $state : $output";
-	#Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);		
+	#Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);
 
 	$last_alert="NAGIOS - $host/$service is $state";
 	$d=time2date($d);
@@ -498,7 +498,7 @@ sub handle_alert($$$$$$$) { # $d,$type,$host,$state,$output,$service
 	$nagios_ack_channel= Irssi::settings_get_str("nagios_ack_channel");
 	Irssi::active_server->command('MSG ' . $nagios_ack_channel .
 		" ".$message) unless ($option eq "silent");
-	#		Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);		
+	#		Irssi::print( "%B>>%n $IRSSI{name} $msg", MSGLEVEL_CLIENTCRAP);
 }
 
 ##########################################################################
@@ -532,8 +532,8 @@ sub event_privmsg($$$$) {
 		return if $target ne $nagios_ack_channel ;
 
 		# !nagios [*] :
-		
-		# !nagios list [*] : 
+
+		# !nagios list [*] :
 		if ($arg =~ /^refresh ?(.*)/i) {
 			$arg=$1;
 			Irssi::print(">> $arg");
@@ -618,9 +618,9 @@ print CLIENTCRAP "%B>>%n $IRSSI{name} $VERSION (by $IRSSI{authors}) loaded";
 ##########################################################################
 # REFERENCES
 # ----------
-# 
+#
 # This script is mainly adapted from 3 other scripts related to nagios :
-# 
+#
 # https://github.com/zorkian/nagios-irc-bot/blob/master/nagiosirc.pl
 # http://www.update.uu.se/~zrajm/programs/irssi-scripts/fifo_remote.pl-0.5
 # https://github.com/mikegrb/irssi-scripts/blob/master/nagios-ack.pl

+ 1 - 1
bin/tailgrep

@@ -2,4 +2,4 @@
 filename=$1
 shift
 #echo "parametres : $@"
-[ "$1" != "" ] && cat $filename | grep $* | tail 
+[ "$1" != "" ] && cat $filename | grep $* | tail

+ 8 - 8
bin/tc-14.pl

@@ -7,7 +7,7 @@
 use Irssi;
 
 use vars qw($VERSION %IRSSI);
-use POSIX qw(strftime); 
+use POSIX qw(strftime);
 
 use LWP::UserAgent;
 
@@ -123,7 +123,7 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 			$warndate=time();
 		}
 	}
-	
+
 	my $admin=0;
 
 	if (in_array(@chan,$target) || in_array(@admin_chan,$target))
@@ -153,11 +153,11 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 		if ( $text =~ /^tc-14:/i ) {
 			$clocky="J'cause pas aux cons, ca les instruit.";
 			send_server("msg", $target, $nick, "$clocky");
-		}	
+		}
 		elsif ( $text =~ /^tc-14/i ) {
 		   $clocky = $clockok[rand @clockok];
 			send_server("msg", $target, $nick, "$nick: $clocky");
-		}	
+		}
 		elsif ( $text =~ /^!password( .+)?/ ) {
 			my $password ="";
 			$length = $1;
@@ -197,18 +197,18 @@ my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
 					 $last=$nick;
 					 $clocky = "Coche la case.";
 					 if ($bingovar{$1} eq "coche") {$clocky = "deja coche"}
-						 else { 
+						 else {
 							$bingovar{$1} = "coche";
 							$bingo++;
 						 }
 					 $server->command ( "action $target $clocky" );
-					 if ( $bingo > 3 ) { 
+					 if ( $bingo > 3 ) {
 					   undef(%bingovar);
-					   $bingo=0; $clocky="FOUTAISES !"; 
+					   $bingo=0; $clocky="FOUTAISES !";
 					   $server->command ( "msg $target $clocky" );
 					   $warn=$nick;
 					 }
-				} 
+				}
 			}
 		}
 		elsif ( $text =~ /orval|landelin|kwak|duvel|guinness|chimay|bi..?re|leffe/i ) {

+ 6 - 0
contrib/README.md

@@ -0,0 +1,6 @@
+# nagbot Debian package
+
+Howto build nagbot Debian package
+
+* move debian directory in the root dir
+* and launch sbuild/pbuilder

+ 5 - 0
contrib/debian/changelog

@@ -0,0 +1,5 @@
+nagbot (1.0.0) unstable; urgency=low
+
+  * Initial release.
+
+ -- Sebastien Badia <seb@sebian.fr>  Wed, 29 Jan 2014 17:48:39 +0100

+ 1 - 0
contrib/debian/compat

@@ -0,0 +1 @@
+7

+ 22 - 0
contrib/debian/control

@@ -0,0 +1,22 @@
+Source: nagbot
+Section: net
+Priority: extra
+Maintainer: Sebastien Badia <seb@sebian.fr>
+Uploaders: Gaetan Ryckeboer <gaetan@ryckeboer.org>
+Build-Depends: debhelper (>= 7.0.50~)
+Standards-Version: 3.9.5
+Vcs-Git: git://code.ffdn.org/asr/nagios-irssi.git
+Vcs-Browser: https://code.ffdn.org/asr/nagios-irssi.git
+Homepage: https://code.ffdn.org/asr/nagios-irssi.git
+
+Package: nagbot
+Architecture: all
+Depends: irssi, perl, screen | tmux
+         ${misc:Depends}
+Recommends: nagios
+Description: IRC bot that announces Nagios status
+ An IRC (Internet Relay Chat) bot that reads Nagios status information and
+ emits alerts to an IRC channel. It can filter alerts based on severity
+ (CRITICAL, HARD, SOFT, and/or UNKNOWN) or by regular expression. It can
+ connect to IRC servers protected by password or SSL, and can optionally set
+ the topic to the current Nagios status.

+ 22 - 0
contrib/debian/copyright

@@ -0,0 +1,22 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: nagios-irssi
+Source: https://code.ffdn.org/asr/nagios-irssi
+
+Files: *
+Copyright: 2014 Gaétan Ryckeboer <gaetan@ryckeboer.org>
+License: GPL-3+
+
+Files: debian/*
+Copyright: 2014 Sebastien Badia <seb@sebian.fr>
+License: GPL-3+
+Comment: the Debian packaging is licensed under the same terms as the original package.
+
+License: GPL-3+
+ The files hereby included are free software; you can distribute them
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3 of the License, or (at
+ your option) any later version.
+ .
+ On Debian systems, the full text of the GNU General Public
+ License version 3 can be found in the file
+ `/usr/share/common-licenses/GPL-3'.

+ 3 - 0
contrib/debian/nagbot.dirs

@@ -0,0 +1,3 @@
+var/lib/nagbot/.irssi/
+etc/nagbot/
+usr/local/bin/

+ 2 - 0
contrib/debian/nagbot.docs

@@ -0,0 +1,2 @@
+INSTALL
+README.md

+ 3 - 0
contrib/debian/nagbot.install

@@ -0,0 +1,3 @@
+etc/config.template etc/nagbot/
+bin/* usr/local/bin/
+var/* var/lib/nagbot/

+ 1 - 0
contrib/debian/nagbot.links

@@ -0,0 +1 @@
+etc/nagbot/config var/lib/nagbot/.irssi/config

+ 31 - 0
contrib/debian/nagbot.postinst

@@ -0,0 +1,31 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "configure" ]; then
+
+  USER="nagbot"
+
+  # Create the "nagbot" user
+  if ! getent passwd ${USER} > /dev/null 2>&1
+  then
+    adduser --quiet --system --group --home /var/lib/${USER} \
+      --no-create-home \
+      --shell /bin/false \
+      --gecos "${USER} daemon" ${USER}
+  fi
+
+  # Create the "nagbot" group if it is missing and set the primary group
+  # of the "nagbot" user to this group.
+  if ! getent group ${USER} > /dev/null 2>&1
+  then
+    addgroup --quiet --system ${USER}
+    usermod -g ${USER} ${USER}
+  fi
+
+  chown -R ${USER}. /etc/${USER} /var/lib/${USER}
+  chmod 0750 /etc/${USER}
+
+fi
+
+#DEBHELPER#

+ 23 - 0
contrib/debian/nagbot.postrm

@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -e
+
+if [ "${1}" = "purge" ] ; then
+
+  USER="nagbot"
+
+  # Del user nagbot (and backup home)
+  if (which deluser && getent passwd ${USER}) > /dev/null 2>&1; then
+    deluser --system --quiet --backup-to /var/lib ${USER} || true
+  fi
+
+  # Del group nagbot
+  if (which delgroup && getent group ${USER}) > /dev/null 2>&1; then
+    delgroup --system --quiet ${USER} || true
+  fi
+
+  rm -rf /var/lib/${USER}
+
+fi
+
+#DEBHELPER#

+ 7 - 0
contrib/debian/rules

@@ -0,0 +1,7 @@
+#!/usr/bin/make -f
+#export DH_VERBOSE=1
+
+%:
+	dh $@
+
+override_dh_usrlocal:

+ 1 - 0
contrib/debian/source/format

@@ -0,0 +1 @@
+3.0 (native)

+ 2 - 0
contrib/debian/watch

@@ -0,0 +1,2 @@
+version=3
+https://code.ffdn.org/asr/nagios-irssi/releases .*/(\d\.\d\.\d)\.tar\.gz

+ 7 - 0
contrib/puppet-nagbot/Gemfile

@@ -0,0 +1,7 @@
+source 'https://rubygems.org'
+
+puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
+gem 'puppet', puppetversion
+gem 'puppetlabs_spec_helper', '>= 0.1.0'
+gem 'puppet-lint', '>= 0.3.2'
+gem 'facter', '>= 1.7.0'

+ 79 - 0
contrib/puppet-nagbot/README.md

@@ -0,0 +1,79 @@
+# nagbot
+
+#### Table of Contents
+
+1. [Overview](#overview)
+2. [Module Description - What the module does and why it is useful](#module-description)
+3. [Setup - The basics of getting started with nagbot](#setup)
+    * [What nagbot affects](#what-nagbot-affects)
+    * [Setup requirements](#setup-requirements)
+    * [Beginning with nagbot](#beginning-with-nagbot)
+4. [Usage - Configuration options and additional functionality](#usage)
+5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
+5. [Limitations - OS compatibility, etc.](#limitations)
+6. [Development - Guide for contributing to the module](#development)
+
+## Overview
+
+A one-maybe-two sentence summary of what the module does/what problem it solves.
+This is your 30 second elevator pitch for your module. Consider including
+OS/Puppet version it works with.
+
+## Module Description
+
+If applicable, this section should have a brief description of the technology
+the module integrates with and what that integration enables. This section
+should answer the questions: "What does this module *do*?" and "Why would I use
+it?"
+
+If your module has a range of functionality (installation, configuration,
+management, etc.) this is the time to mention it.
+
+## Setup
+
+### What nagbot affects
+
+* A list of files, packages, services, or operations that the module will alter,
+  impact, or execute on the system it's installed on.
+* This is a great place to stick any warnings.
+* Can be in list or paragraph form.
+
+### Setup Requirements **OPTIONAL**
+
+If your module requires anything extra before setting up (pluginsync enabled,
+etc.), mention it here.
+
+### Beginning with nagbot
+
+The very basic steps needed for a user to get the module up and running.
+
+If your most recent release breaks compatibility or requires particular steps
+for upgrading, you may wish to include an additional section here: Upgrading
+(For an example, see http://forge.puppetlabs.com/puppetlabs/firewall).
+
+## Usage
+
+Put the classes, types, and resources for customizing, configuring, and doing
+the fancy stuff with your module here.
+
+## Reference
+
+Here, list the classes, types, providers, facts, etc contained in your module.
+This section should include all of the under-the-hood workings of your module so
+people know what the module is touching on their system but don't need to mess
+with things. (We are working on automating this section!)
+
+## Limitations
+
+This is where you list OS compatibility, version compatibility, etc.
+
+## Development
+
+Since your module is awesome, other users will want to play with it. Let them
+know what the ground rules for contributing are.
+
+## Release Notes/Contributors/Etc **Optional**
+
+If you aren't using changelog, put your release notes here (though you should
+consider using changelog). You may also add any additional sections you feel are
+necessary or important to include here. Please use the `## ` header.

+ 6 - 0
contrib/puppet-nagbot/Rakefile

@@ -0,0 +1,6 @@
+require 'rubygems'
+require 'puppetlabs_spec_helper/rake_tasks'
+require 'puppet-lint/tasks/puppet-lint'
+
+PuppetLint.configuration.send('disable_80chars')
+PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]

+ 50 - 0
contrib/puppet-nagbot/manifests/init.pp

@@ -0,0 +1,50 @@
+# == Class: nagbot
+#
+# Nagbot IRC notification/commands bot.
+#
+# === Parameters
+#
+#
+# === Examples
+#
+#  class { 'nagbot': }
+#
+# === Authors
+#
+# Sebastien Badia <seb@sebian.fr
+#
+# === Copyright
+#
+# Copyright 2014 Sebastien Badia, unless otherwise noted.
+#
+class nagbot(
+  $irc_server       = 'irc.geeknode.net',
+  $irc_chatnet      = 'geeknode',
+  $irc_port         = '6697',
+  $irc_ssl          = 'no',
+  $irc_autoconnect  = 'no',
+  $irc_autosendcmd  = '/^msg C nick IDENTIFY mybotpassword',
+  $channel_name     = '#main_channel',
+  $channel_chatnet  = 'geeknode',
+  $channel_passwd   = 'password',
+  $channel_autojoin = 'Yes',
+  $nickname         = 'nagbot',
+  $nagios_command   = '/var/lib/nagios3/rw/live',
+  $fifo_remote_file = '/home/tc-14/var/nagios-fifo'
+
+) {
+
+  package { 'nagbot':
+    ensure => installed,
+  }
+
+  file { '/etc/nagbot/config' :
+    ensure  => present,
+    owner   => 'nagbot',
+    group   => 'nagbot',
+    mode    => '0644',
+    content => template('nagbot/config.erb'),
+    require => Package['nagbot'],
+  }
+
+}

+ 14 - 0
contrib/puppet-nagbot/metadata.json

@@ -0,0 +1,14 @@
+{
+  "name": "puppet-nagbot",
+  "version": "1.0.0",
+  "author": "sbadia",
+  "summary": "Irssi bot to handle nagios/irssi communication.",
+  "license": "Apache 2.0",
+  "source": "https://code.ffdn.org/asr/nagios-irssi.git",
+  "project_page": "https://code.ffdn.org/asr/nagios-irssi",
+  "issues_url": "https://code.ffdn.org/asr/nagios-irssi/issues",
+  "dependencies": [
+    {"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
+  ]
+}
+

+ 7 - 0
contrib/puppet-nagbot/spec/classes/init_spec.rb

@@ -0,0 +1,7 @@
+require 'spec_helper'
+describe 'nagbot' do
+
+  context 'with defaults for all parameters' do
+    it { should contain_class('nagbot') }
+  end
+end

+ 1 - 0
contrib/puppet-nagbot/spec/spec_helper.rb

@@ -0,0 +1 @@
+require 'puppetlabs_spec_helper/module_spec_helper'

+ 262 - 0
contrib/puppet-nagbot/templates/config.erb

@@ -0,0 +1,262 @@
+# Managed by puppet
+# Module:: nagbot
+#
+servers = (
+  {
+    address = "<%= @irc_server %>";
+    chatnet = "<%= @irc_chatnet %>";
+    autoconnect = "<%= @irc_autoconnect %>";
+    port = "<%= @irc_port %>";
+    use_ssl = "<%= @irc_ssl %>";
+    autosendcmd = "<%= @irc_autosendcmd %>";
+  }
+);
+
+chatnets = {};
+
+channels = (
+###################################
+  {
+    name = "<%= @channel_name %>";
+    chatnet = "<%= @channel_chatnet %>";
+    password = "<%= @channel_passwd %>";
+    autojoin = "<%= @channel_autojoin %>";
+  }
+);
+###################################
+
+aliases = {
+  J = "join";
+  WJOIN = "join -window";
+  WQUERY = "query -window";
+  LEAVE = "part";
+  BYE = "quit";
+  EXIT = "quit";
+  SIGNOFF = "quit";
+  DESCRIBE = "action";
+  DATE = "time";
+  HOST = "userhost";
+  LAST = "lastlog";
+  SAY = "msg *";
+  WI = "whois";
+  WII = "whois $0 $0";
+  WW = "whowas";
+  W = "who";
+  N = "names";
+  M = "msg";
+  T = "topic";
+  C = "clear";
+  CL = "clear";
+  K = "kick";
+  KB = "kickban";
+  KN = "knockout";
+  BANS = "ban";
+  B = "ban";
+  MUB = "unban *";
+  UB = "unban";
+  IG = "ignore";
+  UNIG = "unignore";
+  SB = "scrollback";
+  UMODE = "mode $N";
+  WC = "window close";
+  WN = "window new hide";
+  SV = "say Irssi $J ($V) - http://irssi.org/";
+  GOTO = "sb goto";
+  CHAT = "dcc chat";
+  RUN = "SCRIPT LOAD";
+  SBAR = "STATUSBAR";
+  INVITELIST = "mode $C +I";
+  Q = "QUERY";
+  "MANUAL-WINDOWS" = "set use_status_window off;set autocreate_windows off;set autocreate_query_level none;set autoclose_windows off;set reuse_unused_windows on;save";
+  EXEMPTLIST = "mode $C +e";
+  ATAG = "WINDOW SERVER";
+};
+
+
+#######################
+# Cosmetic parameters #
+#######################
+
+statusbar = {
+  # formats:
+  # when using {templates}, the template is shown only if it's argument isn't
+  # empty unless no argument is given. for example {sb} is printed always,
+  # but {sb $T} is printed only if $T isn't empty.
+
+  items = {
+    # start/end text in statusbars
+    barstart = "{sbstart}";
+    barend = "{sbend}";
+
+    topicbarstart = "{topicsbstart}";
+    topicbarend = "{topicsbend}";
+
+    # treated "normally", you could change the time/user name to whatever
+    time = "{sb $Z}";
+    user = "{sb {sbnickmode $cumode}$N{sbmode $usermode}{sbaway $A}}";
+
+    # treated specially .. window is printed with non-empty windows,
+    # window_empty is printed with empty windows
+    window = "{sb $winref:$itemname{sbmode $M}}";
+    window_empty = "{sb $winref{sbservertag $tag}}";
+    prompt = "{prompt $[.15]itemname}";
+    prompt_empty = "{prompt $winname}";
+    topic = " $topic";
+    topic_empty = " Irssi v$J - http://irssi.org/help/";
+
+    # all of these treated specially, they're only displayed when needed
+    lag = "{sb Lag: $0-}";
+    act = "{sb Act: $0-}";
+    more = "-- more --";
+  };
+
+  # there's two type of statusbars. root statusbars are either at the top
+  # of the screen or at the bottom of the screen. window statusbars are at
+  # the top/bottom of each split window in screen.
+  default = {
+    # the "default statusbar" to be displayed at the bottom of the window.
+    # contains all the normal items.
+    window = {
+      disabled = "no";
+
+      # window, root
+      type = "window";
+      # top, bottom
+      placement = "bottom";
+      # number
+      position = "1";
+      # active, inactive, always
+      visible = "active";
+
+      # list of items in statusbar in the display order
+      items = {
+        barstart = { priority = "100"; };
+        time = { };
+        user = { };
+        window = { };
+        window_empty = { };
+        lag = { priority = "-1"; };
+        act = { priority = "10"; };
+        more = { priority = "-1"; alignment = "right"; };
+        barend = { priority = "100"; alignment = "right"; };
+        usercount = { };
+      };
+    };
+
+    # statusbar to use in inactive split windows
+    window_inact = {
+      type = "window";
+      placement = "bottom";
+      position = "1";
+      visible = "inactive";
+      items = {
+        barstart = { priority = "100"; };
+        window = { };
+        window_empty = { };
+        more = { priority = "-1"; alignment = "right"; };
+        barend = { priority = "100"; alignment = "right"; };
+      };
+    };
+
+    # we treat input line as yet another statusbar :) It's possible to
+    # add other items before or after the input line item.
+    prompt = {
+      type = "root";
+      placement = "bottom";
+      # we want to be at the bottom always
+      position = "100";
+      visible = "always";
+      items = {
+        prompt = { priority = "-1"; };
+        prompt_empty = { priority = "-1"; };
+        # treated specially, this is the real input line.
+        input = { priority = "10"; };
+      };
+    };
+
+    # topicbar
+    topic = {
+      type = "root";
+      placement = "top";
+      position = "1";
+      visible = "always";
+      items = {
+        topicbarstart = { priority = "100"; };
+        topic = { };
+        topic_empty = { };
+        topicbarend = { priority = "100"; alignment = "right"; };
+      };
+    };
+    awl_0 = {
+      items = {
+        barstart = { priority = "100"; };
+        awl_0 = { };
+        barend = { priority = "100"; alignment = "right"; };
+      };
+    };
+  };
+};
+settings = {
+  "irc/core" = {
+    join_auto_chans_on_invite = "yes";
+    ctcp_version_reply = "nagbot 42";
+  };
+  core = {
+    real_name = "Protocol Droid 42, at your service.";
+    user_name = "<%= @nickname %>";
+    nick = "<%= @nickname %>";
+    recode_out_default_charset = "= utf8";
+    recode_autodetect_utf8 = "yes";
+    quit_message = "Sir, the possibility of successfully navigating an asteroid field is approximately 3,720 to 1. We should turn ar...";
+  };
+  "perl/core/scripts" = {
+    charsetwars_convert_in = "yes";
+    charsetwars_convert_out = "yes";
+    charsetwars_own = "utf";
+###################################
+    autorejoin_channels = "<%= @channel_name %>";
+    nagios_ack_channel = "<%= @channel_name %>";
+    nagios_ack_nick = "";
+    nagios_command = "<%= @nagios_command %>";
+    fifo_remote_file = "<%= @fifo_remote_file %>";
+}
+  };
+  "fe-common/core" = {
+    term_charset = "utf8";
+    autolog = "yes";
+    autolog_colors = "no";
+    autocreate_query_level = "NONE";
+  };
+  "fe-text" = { actlist_sort = "refnum"; };
+};
+conversions = {};
+hilights = ( { text = "<%= @nickname %>"; nick = "yes"; word = "yes"; } );
+windows = {
+  1 = {
+    immortal = "yes";
+    name = "(status)";
+    level = "ALL";
+    sticky = "yes";
+  };
+  2 = { immortal = "yes"; name = "hilight"; sticky = "yes"; };
+  3 = {
+###################################
+    items = (
+      {
+        type = "CHANNEL";
+        chat_type = "IRC";
+        name = "<%= @channel_name %>";
+        tag = "GeekNode";
+      }
+    );
+    sticky = "yes";
+###################################
+  };
+};
+mainwindows = {
+  2 = { first_line = "1"; lines = "5"; };
+  3 = { first_line = "19"; lines = "53"; };
+  1 = { first_line = "6"; lines = "13"; };
+};
+logs = { };
+ignores = ( { level = "CTCPS"; } );

+ 12 - 0
contrib/puppet-nagbot/tests/init.pp

@@ -0,0 +1,12 @@
+# The baseline for module testing used by Puppet Labs is that each manifest
+# should have a corresponding test manifest that declares that class or defined
+# type.
+#
+# Tests are then run by using puppet apply --noop (to check for compilation
+# errors and view a log of events) or by fully applying the test in a virtual
+# environment (to compare the resulting system state to the desired state).
+#
+# Learn more about module testing here:
+# http://docs.puppetlabs.com/guides/tests_smoke.html
+#
+include nagbot

+ 4 - 4
etc/config.template

@@ -24,13 +24,13 @@ servers = (
     use_ssl = "no";
     autosendcmd = "/^msg C nick IDENTIFY mybotpassword";
   },
-  { 
+  {
     address = "irc.undernet.org";
     chatnet = "Undernet";
     port = "6667";
   },
   { address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
-  { 
+  {
     address = "irc.quakenet.org";
     chatnet = "QuakeNet";
     port = "6667";
@@ -46,7 +46,7 @@ chatnets = {
     max_whois = "4";
     max_query_chans = "5";
   };
-  EFNet = { 
+  EFNet = {
     type = "IRC";
     max_kicks = "4";
     max_msgs = "3";
@@ -304,7 +304,7 @@ conversions = {
 };
 hilights = ( { text = "asr"; nick = "yes"; word = "yes"; } );
 windows = {
-  1 = { 
+  1 = {
     immortal = "yes";
     name = "(status)";
     level = "ALL";

+ 2 - 2
var/fortunes

@@ -504,5 +504,5 @@ You don't know the power of the dark side [VADOR 7925] I feel this lack of faith
 %
 « Si quelqun a compris quoi que ce soit à ce que je viens de dire, c'est que je me suis mal exprimé. » -- Alan Greenspan, économiste
 %
-Pour cause d'indiférence générale, demain est annulé. -- Anonyme su un mur 
-%
+Pour cause d'indiférence générale, demain est annulé. -- Anonyme su un mur
+%

+ 1 - 1
var/quotes

@@ -54,7 +54,7 @@
 %
  Sir, I don't know where your ship learned to communicate, but it has the most peculiar dialect.
 %
- [about Lando] 
+ [about Lando]
 %
  Don't worry about Master Luke. I'm sure he'll be all right. He's quite clever, you know... for a human being.
 %