Monday, July 4, 2011

Opsview and Twitter Notification

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.5
Opsview community Version: 3.11.3
The 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.repo

Then you can use YUM to install python26 package:

# yum install python26 python26-distribute

To get a list of installed packages, do:

# yum list *python26* | grep -i installed


Installed Packages
python26.x86_64             2.6.5-6.el5   installed
python26-distribute.noarch  0.6.10-4.el5  installed
python26-libs.x86_64        2.6.5-6.el5   installed

Install Tweepy

/usr/bin/easy_install-2.6 tweepy

Next, 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


import tweepy


CONSUMER_KEY = 'paste your Consumer Key here'
CONSUMER_SECRET = 'paste your Consumer Secret here'


auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth_url = auth.get_authorization_url()
print 'Please authorize: ' + auth_url
verifier = raw_input('PIN: ').strip()
auth.get_access_token(verifier)
print "ACCESS_KEY = '%s'" % auth.access_token.key
print "ACCESS_SECRET = '%s'" % auth.access_token.secret

Again, in step 4 "Create the command line script", change to python26. Do not forget to add your own keys.

#!/usr/bin/env python26


import sys
import tweepy


CONSUMER_KEY = 'paste your Consumer Key here'
CONSUMER_SECRET = 'paste your Consumer Secret here'
ACCESS_KEY = 'paste your Access Key here'
ACCESS_SECRET = 'paste your Access Secret here'


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.
  1. 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
  2. chown nagios:nagios /usr/local/nagios/libexec/notifications/connect_twitter
  3. chmod +x /usr/local/nagios/libexec/notifications/connect_twitter
Create another script to be used by Opsview
/usr/local/nagios/libexec/notifications/notify-by-twitter

The script:


dt=`date '+%H:%M %d%b%y'`
if [ -n "$NAGIOS_SERVICEDESC" ]
then
msg=`echo @$NAGIOS__CONTACTTWITTERID Time:$dt. $NAGIOS_SERVICEDESC @ $NAGIOS_HOSTNAME,$NAGIOS_HOSTADDRESS is $NAGIOS_SERVICESTATE. $NAGIOS_SERVICEOUTPUT | cut -c 0-140`
/usr/local/nagios/libexec/notifications/connect_twitter "$msg"
unset msg
else
msg=`echo @$NAGIOS__CONTACTTWITTERID Time:$dt. $NAGIOS_HOSTNAME,$NAGIOS_HOSTADDRESS is $NAGIOS_HOSTSTATE. $NAGIOS_HOSTOUTPUT| cut -c 0-140`
/usr/local/nagios/libexec/notifications/connect_twitter "$msg"
unset msg
fi



Again, chown nagios:nagios /usr/local/nagios/libexec/notifications/notify-by-twitter

chmod +x /usr/local/nagios/libexec/notifications/notify-by-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.
Create the profile and submit changes.
Reload your configuration (click on configuration status, top right, then Reload Configuration).


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.

Thursday, July 15, 2010

Go Goa for T-Shirts

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...
























Tuesday, August 4, 2009

Buying a Car - My experience

Disclaimer: The article here is no way connected with any of the vehicle manufacturer or dealer mentioned here. As a consumer, i have reproduced here my car buying experience.

The seeds of driving were sown early in life (in class VII) when I started learning driving on my Dad's Govt provided Willys Jeep. The Willys was later replaced by a Mahindra, and then an Ambassador car. Later we bought the Premier Padmini (a Fiat) and that was the first time I went driving solo . Next came home the Maruti Omni, a Wagon R and a Mahindra Scorpio. The passion for driving has always been there and I tried my hands on whatever vehicle I could catch hold of (of friends and family members). I even owned a couple of 2-wheelers, a Kinetic Luna Super and a Bajaj Kawasaki 4S Champion. Coming back to the main topic, of buying a car... the procedure I followed is described below...

Narrow down your preferences and requirements - Find out for what you need a car for... daily commuting, in-city or long drives, parking space, your budget (how much you want to spend), running costs, how many people would you normally carry, family size, a practical vehicle or a style statement, etc etc... the list goes on. Then comes your personal preferences, the color you want, the accessories provided, the variant you'd like to choose, if you'd like some off-roading, etc. Then comes the big question, petrol or diesel... again, I feel it is a personal choice. Petrol engines are peppy, responsive, trouble-free, light. Modern diesel engines are catching up with petrol, main advantage of diesel is great savings on running costs. Hire a mathematician who will work out what is better, depending on your daily running, fuel bills, difference in car costs, the EMI difference, etc etc. I wanted to keep it simple, I wanted a petrol!

I didn't want a hatch, hence all the hatchbacks were not considered. The Chevy Aveo, Hyundai Verna, Fiat Linea, New Honda City, Maruti SX4 and the Ford Fiesta were in the fray.

Chevrolet Aveo - I had rented the Aveo in the USA when it was launched (in 2007). After driving the VW Jetta there, the Aveo didn't feel inspiring. Back in India, I felt General Motors tried to strip it down and make it cheap. Hence, the interiors were not up to the mark, the engine... nothing great, the looks... too plain! They had the 1.4L engine which is still available, a 1.6 is available too.

Hyundai Verna - A nice roomy car, good for XL and XXL sized people. Looks are subjective, some like it, some don't. I felt it is a very practical daily car if you want to go from point A to B. If I had wanted a diesel car, i think Hyundai Verna Diesel would be the one... awesome power, nicely built! And the diesel comes with automatic transmission too.

Fiat Linea - Fiat's re-entry into India has been with a bang. Fiat Linea has been a great launch, a successful one too. The car looks great, feels and drives quite good too, this is combined with practical pricing. All these factors have led to success for Fiat. The Linea (petrol) felt a bit under-powered and sluggish. Overall it is a good package, loaded with accessories, and seems value for money.

Honda City - The 2009 Honda City has one of the best figures in India, the arrow-shot shape is killing. But Honda disappoints big-time on the features, accessories and the interiors of the car. The premium that Honda charges for its badge is very disappointing. The car is good on maneuverability, pulls along nicely and is fuel efficient.

Maruti SX4 - This is a value for money car, good for tall adults. It has decent performance, good handling. It is a bit low on fuel-efficiency though. The design and the looks are subjective, but I found the A-pillar obstructs the view. Also the high tail made me uneasy while reversing.

Ford Fiesta - A fun to drive, loaded with features, great handling car from Ford. It has won accolades for its great driving and is the most involving driver's car in India.



  • Start off with a test-drive - The first step is to try your hands on the cars you have short listed. Do make a point to list down the likes and dislikes about the car. Also, get the price quotes for the different variants, ask for special pricing, corporate discounts, etc. Having all these data will help you pin down the Make/Model.
  • Weigh the price and feature of the cars. Combine this with your personal driving experience as well as your preferences. For e.g. I am a young driver, I needed something sporty, which would look good and stand out in a crowd, fun for city as well as highway drive, moderately fuel-efficient.
  • Pricing - After you shortlist 2-3 cars, find out what the best price the dealer can offer. Also ask for freebies/accessories which will be given. Ask the pricing of extra accessory if something is not standard, e.g. alloy wheels or music system. I got a 58k corporate discount on the Fiesta. As Linea and City were newly launched, the discount was too low. Do check with pricing from other dealers in the city. For insurance premium rates, check out some sites like Apnainsurance. Also, refuse to pay additional charges like depot charges, etc.
  • Before finalising on the deal, go for another round of test drive, preferably with a close friend/relative or with your family.
  • Loan - Most of us go for a auto-loan. Check out for a good deal with your preferred bank or your salaried-bank. My salary bank gave me a loan, the interest of which was 1% less than the prevailing rates. Check out with nationalised banks like SBI, although they take a lot more time and paperwork than private banks. Loan comparison can be done at Apnaloan.
The final outcome: I decided to buy a Ford Fiesta 1.6S... why...
  • b'cos I got a good deal, 7.3Lacs on-road Mumbai (no real discounts on the Linea or the City)
  • b'cos the car came fully loaded at this price, with 6-spaker CD-mp3-aux-in audio system, 15" alloy wheels, side skirts, rear spoiler (top-end City doesn't even come with alloys, all others have 14" tyres)
  • b'cos it has a 1600cc engine (1300cc in Linea, 1500cc in City)
A word of caution: Find a bit about the dealer, check the promptness in service, make a visit to the service center too. I am not having a good time with SC Ford, Malad, Mumbai. The delivery was very much delayed, the sales-guy was un-responsive, they charged me extra at the last moment (for using a credit-card), registration took over a week, etc etc.

But finally I am very happy with my car, great pickup, nice handling, feels safe... the most imp part is that I enjoy every bit when I am in my car... and that matters most!





Hope this will help all potential car buyers. Comments welcomed !

Tuesday, July 14, 2009

Photo tour of California

^ Diving around in a Ford Focus


^ Flowers in full bloom

^ The White Focus

^ El Camino Real, Sunnyvale

^ Sun Microsystems and Webex, Silicon Valley


^ Yahoo!


^ In front of Intel

^ Union Bank of California

^ Adobe

^ A church in San Jose Dwntown

^ San Jose Museum of Art

^ San Jose Downtown

^ San Jose Museum of Art


^ USC road-show

^ San Jose Downtown


^ A trip to Half Moon Bay

^ Half Moon Bay







^ Country Roads



^ Flying back into Mumbai

^ Mumbai meri jaan!