Sunday, November 27, 2011

Using Twitter To Monitor Your Linux Server!

Yes, you can use Twitter for monitoring your server. I won't say that it is a complete monitoring solution nor I will ask you to throw away your existing monitoring mechanisms. In fact the script I am talking about, MYST (AGPLv3), was not created for this purpose. It was created so that I could tweet without using browser with inspiration from Hiemanshu, a Fedora contributor, using python-twitter api.

It is just a fun script which you can use to tweet the health of your server periodically to a private account which only a moderated set of people can follow. So here is how you do it:

Step 1: Create a Twitter account. From settings page, mark it private.

Step 2: Open Twitter's new application page and fill the form. Put the name as 'MYST' and website as 'http://myst.adityapatawari.com'.

Step 3: Download 'MYST: Twitter for Shell' and extract it.

Step 4: Open your application 'MYST' listed at Twitter's apps page and fill .myst.conf with the relevant details.
Copy it to your home directory.

Step 5: Install python-twitter (version 0.82) on your server along with dependencies.

Step 6: Put a cron with appropriate time (and path to scripts) to execute the following periodically:

./myst.py update `./monitor.sh`

This is a cool method to check out the system health and you can modify monitor.sh to add more parameters to monitor.
Please contribute to the MYST project on Gitorious.org

6 comments:

  1. Hi, I have tried your application. But it show error.

    ./myst.py update `./monitor.sh`
    Traceback (most recent call last):
    File "./myst.py", line 50, in ?
    user=twitter.Api(consumer_key=conskey, consumer_secret=conssec, access_token_key=accstkn, access_token_secret=accssec)
    TypeError: __init__() got an unexpected keyword argument 'access_token_key'

    I have completed all step like your guide. Please correct me

    ReplyDelete
  2. Hi Ngapak-ers,
    You are getting this error because you are using older version of python-twitter. You need to install the latest version. Download it from [1] and follow the instruction given on their home page at [2]. Make sure that you have all the required dependencies.

    [1]: http://code.google.com/p/python-twitter/downloads/detail?name=python-twitter-0.8.2.tar.gz
    [2]: http://code.google.com/p/python-twitter/

    ReplyDelete
  3. How about this error?

    Traceback (most recent call last):
    File "./myst.py", line 64, in ?
    user.PostUpdates(status)
    File "build/bdist.linux-x86_64/egg/twitter.py", line 2799, in PostUpdates
    File "build/bdist.linux-x86_64/egg/twitter.py", line 2765, in PostUpdate
    File "build/bdist.linux-x86_64/egg/twitter.py", line 3763, in _FetchUrl
    File "build/bdist.linux-x86_64/egg/oauth2/__init__.py", line 493, in sign_request
    TypeError: 'module' object is not callable

    ReplyDelete
  4. Found a similar bug in tweepy at [1]. Looks like this is because of locale. Maybe you are using a locale which is not supported by python-twitter. I'll try to dig more and get it fixed.

    [1]: https://github.com/tweepy/tweepy/issues/13

    ReplyDelete
  5. What is locale?

    i will wait your next information

    ReplyDelete
  6. Locale defines things which are local to your computer like language, fonts etc. Read more about it on wikipedia. http://en.wikipedia.org/wiki/Locale

    ReplyDelete

Note: Only a member of this blog may post a comment.