During the college days, I had much fun doing the dumbest things which had absolutely no hope of finding any practical application – but just made me feel good. To bring back the good times, this weekend I thought of doing something similar.
Have you ever:
- Felt getting sms reminder from your Google Calender makes you more efficient
- Felt the need what’s going on in your server when you are not looking at it
- Felt Python is the neatest language around
Wondering what’s common in the three of them? How about using Google’s free sms service to get updated about the health of your server? Google’s gdata api allows you to do that, just with a few lines of python.
What’s the big deal about that? Nagios already has that feature, you might say! But unfortunately, I’m using windows these days, and all the free sms gateways in India are worthless.
Peeped into the sample in the samplescalendar folder, and took out the required part from the calendarExample.py and made some little changes, and it was done. Here is the script.
The script isn’t really good and just checks if the Remote Registry Service is up or not. But with more love, cool things (like sms alert on unauthorised access, low isk space etc.) can be done.
However, to remove the ugliness of the script, firstly the hardcoding needs to go.
start_time = time.strftime(‘%Y-%m-%dT%H:%M:%S+05:30’, time.localtime(time.time() + 600))
where +05:30 indicates my time zone, ie IST and the 600 seconds, the time lag between the running of the script and the creation of the event. The sms reminder is sent 1 minute before the event begins, making the time lag 9 minutes.
But more importantly, there should be saner way of passing a password to a script. I had my dad’s cell registered with a less important google account and scheduled a .bat file in Winodws Scheduler that calls the script to set events every 10 minutes. Unfortunately, he did not enjoy it as much as I did.