MSN bot for nagios

First of all, thanks a lot to the team behind bitlbee for making such a nice IRC alike -> gateway.

I have with some ripoff/inspiration/help from kertz.in written the follow bot (which by now seems to be a dead link). For everyone who need a great getting started tutorial, here is a really nice guide that will help you princessleia.com.

About Rosie

This bot (Rosie) is made to be a gateway from my nagios server to my MSN account whenever im online.

Features

My version of this bot has to follow features:

Requirements

In order to be up and running with this bot, you need to following requirements:

And thats all :)

Download

Download rosie here.

Version 2

I have made some improvements for Rosie, now the code is a little more structured, and should be easier to modify for your needs.

Here is a complete step by step guide from a fresh CentOS installation.

Installation

Always verify the output from your commands, there might be something that differs on your setup.

$ yum update
$ yum install gcc php-cli wget glib2-devel openssl-devel make irssi screen
$ adduser --home=/var/lib/bitlbee
$ cd /usr/src
$ wget "http://get.bitlbee.org/src/bitlbee-1.2.8.tar.gz"
$ tar xzf bitlbee-1.2.8.tar.gz
$ cd bitlbee-1.2.8/
$ ./configure --jabber=0 --oscar=0 --yahoo=0 --twitter=0 --msn=1 --ssl=openssl
$ make
$ make install
$ make install-etc
$ sed 's/# RunMode = Inetd/RunMode = Daemon/' /usr/local/etc/bitlbee/bitlbee.conf > /tmp
$ mv /tmp/bitlbee.conf /usr/local/etc/bitlbee
$ bitlbee
$ mkdir -p /var/spool/bitlbee/outgoing/ /var/spool/bitlbee/sent/
$ chown bitlbee:bitlbee -R /var/spool/bitlbee/
$ netstat -ant | grep 6667 # If you see a single line, your installation has completed

And now we can move on to the configuration of the bot.

Configuration

Now we will login with a normal IRC client to control our bitlbee server, and prepare it for our automated Nagios -> MSN gateway.

This step require that you have a working MSN account already that you can dedicate to this nagios gateway.

$ epic username localhost
$ > register password
$ > account add msn msn@example.com password
$ > account on

Remember if you think its easier to maintain the bots friendlist in your normal MSN client (pidgin/MSN-live) you are free to do that. When you login to bitlbee, it will just fetch your global friendlist.

The last step is setup of Rosie, our Gateway.

Change the configuration to fit your needs (config.php), you have to special aware of the following fields.

Setup and startup

$ su - bitlbee
$ tar xzf rosie.tgz
$ screen
$ php rosie.php

As always, there MIGHT be something which differ on every server installation, so remember to check the output from rosie when you start it up :)

Nagios configuration is quite simple, here is a snap of configuration that i've use.

NAGIOS

define command{
 command_name host-notify-by-bitlbee
 command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" > /var/spool/bitlbee/outgoing/text.txt
}

Version 1

Now, what you can do is download my sample of a bitlbee bot (rosie) click here do view the source.

Put the source on your server, configure the first few lines to fit your needs.. and you will be up and running in no time.

Remember to search for the phrase <PASSWORD> in your script in order to identify with your bitlbee IRC network.

Future

I dont really have any plans for the future of this small project, if you like it you are free to give me some feedback.. How it can be made better, also if you have a patch.. please send me the patch and i will update the public version on this page.

Known bugs

There is a problem with the script, when i add people to the friend list, some error will sometimes be generated, which course i will have to restart the script, and everything works just fine again.

Contact

My name is Michael Holm, you can contact me on hollo@hollo.dk