Me n my Space !

July 4, 2011

This article will help to post your host and service status messages from Opsview to your Twitter account. For configuring this you need to have access to the shell of your Opsview server. Note that I do not assume any responsibility if any of the steps below results in unexpected behavior of Opsview or your system. Comments and improvements are welcomed.The service notifications from Opsview are posted to my Twitter account (@shib4u) as shown below...

My setup...

OS - CentOS release 5.5Opsview community Version: 3.11.3The server should be able to access the internet.What is Opsview?In a nutshell, Opsview is better Nagios. Nagios monitors your entire IT infrastructure to ensure systems, applications, services. In the event of a failure, Nagios can alert technical staff of the problem. Here we are using Twitter to notify us.I am not going to cover the steps for CentOS or Opsview installation, as they can be found here.To access Twitter from Opsview, I installed Tweepy. Tweepy is a Python library for accessing the Twitter API. It requires Python 2.5 or later, hence, I installed Python 2.6 as described in this blog.# wget http://dagobah.ftphosting.net/yum/smartfile.repo -O /etc/yum.repos.d/smartfile.repoThen you can use YUM to install python26 package:# yum install python26 python26-distributeTo get a list of installed packages, do:# yum list *python26* | grep -i installed

Installed Packagespython26.x86_64 2.6.5-6.el5 installedpython26-distribute.noarch 0.6.10-4.el5 installedpython26-libs.x86_64 2.6.5-6.el5 installedInstall Tweepy/usr/bin/easy_install-2.6 tweepyNext, I had to authenticate twitter from the command line. Jeff Miller has written an excellent blog about achieving this.I suggest you create a new Twitter account which will be used to post the notifications. Do enable Tweet Privacy under Settings, in the Twitter account, so that posts are not made public. (You do not want others to know that your servers are erratic, do you !?!). After creating the Twitter account, check out the blog and register a new client app with Twitter (as shown in step 2 there).Do Step 3 "Connect the app to your Twitter account" with a minor change in the first line.. write python26 instead of python#!/usr/bin/env python26

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)api = tweepy.API(auth)api.update_status(sys.argv[1])After step 5 "Send a test tweet from the command line" and if the test is successful, do the following.

Move the script to /usr/local/nagios/libexec/notifications/. I call the script as connect_twitter, hence my script is at /usr/local/nagios/libexec/notifications/connect_twitter

Log in to Opsview with an user with admin privileges.Go to Advanced then Notification Methods from the drop down menu.On the extreme top right, click Actions and then Create new Notification Method as following...

Next, in Opsview top bar, go to Configuration, then Contacts. Click on the contact you want to set twitter alerts for. Click the Notifications button. Add you Twitter id (this id will receive the Tweets).

Click on Submit and Edit Notification Profiles.Click Actions, and Create new Notification Profile for user.

Reboot one of your server or stop a service which is added in Opsview. Note that Twitter allows 250 direct messages per day, do not cross this limit as tweets won't come in after you exceed this number.The Tweets should start coming in.

July 15, 2010

Sorry folks, haven't been writing for a long time... pretty tied up with work and better part of the time goes playing with my kid... But I'll keep posting here, more of pictures and less of text. To start off, I post some of the pictures of t-shirts which were on sale at Goa, in a few shops on the road from Calangute to Baga (I went there Jan'10 end). There were a few shops selling those t-shirts. The tailor was doing the embroidery work there itself, in the shop. Amazing skill and designs...