Welcome to It-Slav.Net blog
Peter Andersson
peter@it-slav.net

I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0

Background

I sometimes get the question if I have any tips on a op5 Monitor alarm console. I stumbled on the possibility to use irc to present the alerts generated by op5 Monitor or Nagios. A nice feature is that the number of connected clients can be very many, severla systems can send all alerts to the same irc channel and best of all, it's geeky.

 

Solution

The solution is using four components:

  • A working op5 Monitor or Nagios implementation (will not be covered in this article)
  • An irc channel where the alerts are presented
  • A bot that collects the op5 Monitor status and sends it to the irc channel
  • An irc client i.e. weechat

 

The irc server

I wanted to use my own irc server, mainly because I want it to run in my own controlled environment. There are toons of implementations but i picked new generation irc daemon, ngircd which existed in my distributions repository.

Simple configuration in /etc/ngircd.conf added to the end of configuration.

[Channel]
        Name = #op5_Monitor
        Topic = op5 Monitor Alerts
        MaxUsers = 23

 

Start the irc server:

# /etc/init.d/ngircd start
Starting ngircd:                                           [  OK  ]

Making sure it starts the next reboot

# chkconfig ngircd on

 

The bot

I found a boot called nagircbot

Download and compile.

# make && make install

Start the bot:

nagircbot -f /opt/monitor/var/status.log -X -s mail:6667 -c \#op5_Monitor -n Monitor -N op5_Monitor-- -C

 

Connect the client

Start the irc client

$ weechat-curses

 

Connect the irc server

/connect <my_irc_server>

 

Set nick

/nick <my_nick>

 

Join the correct channel

/join #op5_Monitor

 

Screenshoot:

 

Links:

  • op5 Monitor, a nagios based eneteprise monitor solution
  • Nagircbot, a bot that sends nagios events to irc
  • ngIRCd, new generation irc daemon
  • WeeChat, nice irc client with rich functionality

One Response to “Using IRC as op5 Monitor or Nagios alarm console”

  1. Magnus Says:

    Thanks for the hint!
    I realized that if you've got a service that outputs longer messages than 410 bytes, the bot will be disconnected from the IRC server (all in accordance to RFC 2812, http://tools.ietf.org/html/rfc2812Internet Relay Chat: Client Protocol, section 2.3).

    I patched the file "anna.cpp", 
     
    int send_irc(server_t server_conn, char *format, …)
    {
            int rc;
            char buffer[4096];
            va_list ap;
            va_start(ap, format);
            vsnprintf(buffer, sizeof(buffer) – 3, format, ap);
            va_end(ap);
     
    // #— Added change starts here
            if (strlen(buffer) > 410) {
              if (verbose > 1) dolog("Note: buffer > 410 – trimming");
              buffer[410] = 0x00;
            }
    // #— Added change ends here
     
            if (verbose > 1) dolog("OUT: `%s'", buffer);
            strcat(buffer, "\r\n"); /* yes this is safe: check the vsnprintf command */
            rc = IRCWRITE(server_conn, buffer, strlen(buffer));
            if (rc == -1)
            {
                    dolog("error sending: -1");
                    return -1;
            }
            else if (rc == 0)
            {
                    dolog("connection closed");
                    return -1;
            }
            time(&last_irc_io);
            return 0;
    }

     
    This will effectively trim the string. Recompiled it with "make clean; make". With that hack it works; the bot is not thrown out of the IRC chat.
     

Leave a Reply





Book reviews
FreePBX 2.5
Powerful Telephony Solutions






Asterisk 1.6
Build a feature rich telephony system with Asterisk






Learning NAGIOS 3.0





Cacti 0.8 Network Monitoring,
Monitor your network with ease!