diff options
author | Gabriel Filion <lelutin@gmail.com> | 2010-12-14 15:14:54 -0500 |
---|---|---|
committer | Gabriel Filion <lelutin@gmail.com> | 2010-12-21 15:38:16 -0500 |
commit | 7c9f6d224d9bf66bc1c69b1baa066f98b9302999 (patch) | |
tree | 1da169bde639d82b4cd5c8c98c4f81468f68b563 /files/irc_bot/riseup-nagios-client.pl | |
parent | 5d5ec8c28d0fe39359af8db159b14faeae397e1f (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 'files/irc_bot/riseup-nagios-client.pl')
-rw-r--r-- | files/irc_bot/riseup-nagios-client.pl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/files/irc_bot/riseup-nagios-client.pl b/files/irc_bot/riseup-nagios-client.pl new file mode 100644 index 0000000..fd28996 --- /dev/null +++ b/files/irc_bot/riseup-nagios-client.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w + +# ############################################################################## +# Infrabot-Client - a simple Infrabot client which sends it's whole command +# line arguments to a local UNIX domain socket. +# ############################################################################## + +use strict; +use IO::Socket; + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# >> CONFIGURATION >> + +my $SOCKET = '/var/run/nagios/nsa.socket'; + +# << CONFIGURATION << +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +if (@ARGV == 0) { + print "Hey - specify a message, sucker!\n"; + exit(1); +} + +unless (-S $SOCKET) { + die "Socket '$SOCKET' doesn't exist or isn't a socket!\n"; +} + +unless (-r $SOCKET) { + die "Socket '$SOCKET' can't be read!\n"; +} + +my $sock = IO::Socket::UNIX->new ( + Peer => $SOCKET, + Type => SOCK_DGRAM, + Timeout => 10 +) || die "Can't open socket '$SOCKET'!\n"; + +print $sock "@ARGV"; +close($sock); |