Twitter server monitor
Posted: Thu Jul 16, 2009 8:32 am
Before coming to Amahi I spent some time testing out WHS and one thing I came to appreciate, even with its limitations, was an addon that would send system errors to twiiter, so I decided to create a script in python that would be able to send me information about the server, has I don't run any critical applications on my server I just want to know how things are from time to time.
In twitter terms I have an account just for the server that only allows private followers
This is how the message looks like :

For all but upload and download I used common system calls, so you can easily change the code for your own applications the only really specific case is the up/down, as I only have an Ethernet port active, I can't use its statistics (they would get mixed up with lan usage) so I had to fetch the data from my router statistics page that uses the Tomato firmware, If you are able to use it for other routers pls post here
Any suggestions and tips are really welcome!
TIPS: As the passwords are not safe I recommend that you make sure that only root can read it (chmod 711 for example as root).
Don't spam it, I for example only run it during the day and only in 4 hours interval (my crontab entrie 1 11,15,19,23 * * * /usr/local/bin/twitCron.py)
ATTENTION: this was written with the propose of getting to know python for shell scripting, this was in fact the second program I have ever written in python, I have a large experience in other languages but had never tried it, so do not yell if the code isn't the better you have ever seen...
In twitter terms I have an account just for the server that only allows private followers

This is how the message looks like :

For all but upload and download I used common system calls, so you can easily change the code for your own applications the only really specific case is the up/down, as I only have an Ethernet port active, I can't use its statistics (they would get mixed up with lan usage) so I had to fetch the data from my router statistics page that uses the Tomato firmware, If you are able to use it for other routers pls post here

Any suggestions and tips are really welcome!
TIPS: As the passwords are not safe I recommend that you make sure that only root can read it (chmod 711 for example as root).
Don't spam it, I for example only run it during the day and only in 4 hours interval (my crontab entrie 1 11,15,19,23 * * * /usr/local/bin/twitCron.py)
ATTENTION: this was written with the propose of getting to know python for shell scripting, this was in fact the second program I have ever written in python, I have a large experience in other languages but had never tried it, so do not yell if the code isn't the better you have ever seen...