JSONBOT plugin

Afternoon y’all!

Last weekend I decided to give observium a try. Observium is a network monitoring system and fully snmp-based. There are also alternatives like Zabbix and/or Nagios but Observium differs that it’s very very easy to set-up.

I’ve spent like half-an hour installing observium on a clean debian server and after those 30 minutes it was already graphing 3 devices in my network. I’ve spent a couple of hours after that toying around, discovering what’s possible and what not.

Something observium does is when it discovers a problem, for example a device that got disconnected, it sends an e-mail to the snmp-syscontact (or if overridden another email address).

I usually also have an irc window open when I’m sitting behind my computer like many of you I suppose. And I almost immediately had the wish that the irc-bot (jsonbot) that I have running would be connected somehow to observium and inform me of those messages. A couple of friends also use observium (one of them has been pushing me around a lot when o when I would start using observium :P ) and they also liked the idea.

So today I got up around 8:30 in the morning brewed a fresh pot of coffee and opened my editor. Now some hours and I don’t know how many cups of coffee later I’d like to present to you my observium-jsonbot-plugin!

What it does is check an imap e-mail box for new messages and inform you about it. The features it provides are:

  • Present a list of unread e-mails
  • Display the contents of a given message
  • Automatically check for new messages (by default every 60 secs. when enabled)

Here’s how it works! First of all you need to configure your bot with the options for the observium imapbox. The following options can be set:

imap-host (default: mail.example.com)
imap-username (default: observ@example.com)
imap-password (default: password)
imap-folder (default: INBOX)
imap-ssl (default: True)
imap-interval (default: 60)
watcher-enabled (default: False)

These options can be set using:

!observium-cfg

#Example
!observium-cfg imap-host mail.yourdomain.com

# Don't forget to save and reload when you're done using:
!observium-cfgsave
#and
!reload observium

When you’ve configured the plugin these are the commands available to you:

# retrieve all unread message-subjects from the configured imap-folder
!observ

#example output:
[#3] Device Up: host.yourdomain.tld
[#2] Device Down: host.yourdomain.tld

# retrieve the contents of a specific message
!observ-msg 3

#example output:
[Subject]: Device Up: host.yourdomain.tld
[Message]: Device up: host.yourdomain.tld at 16-05-2011 10:45:56

# if you've enabled the watcher in the config you can enable it for the current channel using:
!observ-watch-enable

#or disable it using:
!observ-watch-disable

#or list the channels for which it has been enabled:
!observ-watch-list

If you’ve enabled the watcher for a certain channel the bot will check the mailbox every 60 seconds (unless you’ve changed the interval) and if new messages have been found it will post a list of subjects in the channel.

Of course you’ve been waiting for the downloadlink: well here it is: Download

You should put this file in <yourbotdirectory>/jsb/plugs/socket/
Then restart your bot and enable the plugin using:

!plug-enable observium

I hope you have fun with it and if you’ve got any comments and/or find bugs, please let me know :)

Kind regards,

Lammert

This entry was posted in Networking, Programming, Systems Administration. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>