How to Post Status Messages from Opsview to your Twitter Account

 How to Get Twitter Notifications in OpsviewOpsview gives you lots of standard options for receiving status notifications, but with a bit of custom scripting you can also get status messages from Opsview and post them to a Twitter account.

This could be useful if you want to keep all your status messages in one place with a timeline. Plus you can also set up an account for other members of your team to follow so they can also see the updates. However it's probably best that the Twitter account is kept within your organisation unless you want the world to see the status of your servers!

This article tells you how to configure Opsview to send messages to Twitter. For configuring this you need to have access to the shell of your Opsview server. To access Twitter from Opsview, you'll need to install Tweepy. Tweepy is a Python library for accessing the Twitter API. It requires Python 2.5 or later.

If you need to install Python 2.6 you can follow the instructions on this blog.

# wget -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 you'll need to authenticate Twitter from the command line. This blog tells you how.

At this point you'll need to create a new Twitter account which will be used to post the notifications. Make sure you enable Tweet Privacy under Settings, in the Twitter account, so that posts are not made public (unless you want them to be!) After creating the Twitter account, you'll need to register a new client app with Twitter.

Select "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()
print "ACCESS_KEY = '%s'" % auth.access_token.key
print "ACCESS_SECRET = '%s'" % auth.access_token.secret

Again, in  "Create the command line script", change to python26. Don't 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)

Then "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/.

(call the script 'connect_twitter', hence 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:


The script:

dt=`date '+%H:%M %d%b%y'`
/usr/local/nagios/libexec/notifications/connect_twitter "$msg"
unset msg
/usr/local/nagios/libexec/notifications/connect_twitter "$msg"
unset msg


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 as a user with admin privileges. Go to Advanced then Notification Methods from the drop down menu. On the top right, click Actions and then Create new Notification Method as following:

Display Opsview Status in Twitter

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

Display Opsview Status on Twitter

Click on Submit and edit Notification Profiles. Click Actions, and create new Notification Profile for user.

Display Opsview Status on Twitter

Create the profile and submit changes. Reload your configuration (click on Configuration Status, top right, then Reload Configuration). Reboot one of your servers 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 now start coming in!

About the Author

Shibashish Satpathy is an Opsview Community user based in Mumbai, India. Shib works in IT Operations and enjoys photography, travelling and working with Linux!

Legal Disclaimer

This blog post is contributed by a member of the Opsview community. Opsview accept no responsibility for the accuracy of its content and are not liable for any direct or indirect damages caused by its use.

Try this out for yourself by downloading Opsview Core and get our latest tips and updates by following us on Twitter!


Ravi Katti's picture
22 November 2011 - 8:17am

A very useful one indeed !!

keenee's picture
20 January 2014 - 12:04pm

I agree with you that the article is really nice which helps the user to learn opsview nicely. Wordpress Theme Customization

jimmi's picture
18 February 2014 - 1:08pm

I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

photographic make up

sree's picture
22 November 2011 - 5:17pm

nice article, really helped!

K.Gopal's picture
22 November 2011 - 8:35pm

Nice article

Arthur's picture
14 December 2011 - 8:11am

I really hope that people make such tweets private, otherwise a search for opsview on twitter will become useless to find new information on opsview. Already happens with nagios, as a lot of people are tweeting their status messages publicly.

minhye's picture
27 January 2014 - 12:53am

I am really happy to study it and being able to reveal my ideas on it. Social media, using Twitter, Facebook, YouTube, Foursquare, Instagram and other social tools on the web. Its like an instrument for communicating, social media is a set of technologies. This is a great example of how social media can be used throughout a variety of purposes.

purchase twitter favorites

Thank you so much.

kimtan's picture
27 January 2014 - 4:01am

At last I can have found something from this post which feels pretty good. Social media definitely has influence on how we view ourselves and the people around us. And also social media are part of the culture now, and this has an influence on policy.

purchase u.s.a youtube subscribers and to know our other services.

leeyi's picture
28 January 2014 - 12:23am

I am happy to find this article and have a read it and I know how to post status messages form opsview to twitter account. This is really great article! I’ll definitely be back for updates. This is very interesting, I love reading and I am always searching for informative information like this. It gives me a lot of help because of this.

where to buy reverbnation audio plays

tedmosby545's picture
6 February 2014 - 8:15am

I’m really glad that I found this post.  Now I have a better idea about posting status messages to my twitter account from opsview. I can even configure the messages. Thanks a lot for posting this article. It was really useful.

microsoft word troubleshooting

malina's picture
7 February 2014 - 12:57am

I am researching this topic for a paper I am writing. Your article provided me great insight of my topic. Easily, the article is actually the best topic on this registry related issue.english to spanish translation audio

kanghaena's picture
17 February 2014 - 1:53am

I'd like to peer more posts like this. So nice to discover someone with genuine thoughts on this issue. The people who engage in such conversations are the people having the most fun of all on Twitter and are the coolest communicators. Twitter is the best way to connect with people,
express yourself and discover what's happening.

Here, just visit us to where to buy twitter followers

Sophie143's picture
20 February 2014 - 2:44am

I just stop and watch this website and i found out that this is very nice and interesting. I love to read blogs and articles i already bookmark this webpage. I'm looking forward to read more and I'll be back for more updates .

thank you 


how to get favorites on Twitter

tambal's picture
20 February 2014 - 1:06pm

I am preparing a research paper and collecting information on this topic. Your post is one of the better that I have read. Thank you for putting this information into one post.

get real twitter followers

krain's picture
21 February 2014 - 8:42am

I agree with you that the article is really nice which helps the user to learn more. Looking forward to read more of your post and updates in the future.

buy real instagram followers

exam's picture
10 March 2014 - 8:48am

This is just the information I am finding everywhere. Me and my friend were arguing about an issue similar to this! Now I know that I was right .Thanks for the information you  post.

ways to gain Twitter Re tweets


Call us for a quote


International numbers