summaryrefslogtreecommitdiff
path: root/templates
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 /templates
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 'templates')
-rw-r--r--templates/irc_bot/nagios-nsa.sh.erb71
-rw-r--r--templates/irc_bot/nsa.cfg.erb13
2 files changed, 84 insertions, 0 deletions
diff --git a/templates/irc_bot/nagios-nsa.sh.erb b/templates/irc_bot/nagios-nsa.sh.erb
new file mode 100644
index 0000000..61cc063
--- /dev/null
+++ b/templates/irc_bot/nagios-nsa.sh.erb
@@ -0,0 +1,71 @@
+#! /bin/sh
+
+### BEGIN INIT INFO
+# Provides: nagios-nsa
+# Required-Start: $remote_fs $syslog $nagios
+# Required-Stop: $remote_fs $syslog $nagios
+# Default-Start: 2 3 4 5
+# Default-Stop: 1 6 0
+# Short-Description: Nagios Simple IRC Agent
+### END INIT INFO
+
+PIDFILE=<%= nagios_nsa_pidfile %>
+SOCKFILE=<%= nagios_nsa_socket %>
+
+. /lib/lsb/init-functions
+
+start() {
+ log_daemon_msg "Starting nagios IRC bot" "nagios-nsa"
+ if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --user nagios --exec /usr/local/bin/riseup-nagios-server.pl; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+}
+
+stop () {
+ log_daemon_msg "Stopping nagios IRC bot" "nagios-nsa"
+ if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE; then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+}
+
+remove_socket() {
+ [ -e $SOCKFILE ] && rm $SOCKFILE
+}
+
+cleanup() {
+ if [ -r $PIDFILE ]; then
+ ps -p `cat $PIDFILE` | grep -v 'PID' || {
+ echo "not running"
+ remove_socket
+ }
+ else
+ echo "no pid file"
+ remove_socket
+ fi
+}
+
+case $1
+in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ cleanup
+ start
+ ;;
+ status)
+ status_of_proc -p $PIDFILE /usr/local/bin/riseup-nagios-server.pl && exit 0 || exit $?
+ ;;
+ *)
+ log_action_msg "Usage: /etc/init.d/nagios-nsa {start|stop|restart|status}"
+ exit 1
+esac
+
diff --git a/templates/irc_bot/nsa.cfg.erb b/templates/irc_bot/nsa.cfg.erb
new file mode 100644
index 0000000..7cba62c
--- /dev/null
+++ b/templates/irc_bot/nsa.cfg.erb
@@ -0,0 +1,13 @@
+%Nsa = (
+ 'socket' => '<%= nagios_nsa_socket %>',
+ 'server' => '<%= nagios_nsa_server %>',
+ 'port' => '<%= nagios_nsa_port %>',
+ 'nickname' => '<%= nagios_nsa_nickname %>',
+ 'password' => '<%= nagios_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 %>",
+);