A crash course in Python

Sometimes, you just need to figure out what you can do with the tools that you have available to you.

The situation: I have to check the status of a site that is on a server that I don’t control, and take various alert actions depending on specified parameters.

The tools that I have: a Linux server that I can reasonably assume to be up and available more often than the site that I’m checking on.

The fun part about this is that normally I would write a little PowerShell script, (or VBScript if I could not guarantee the presence of PowerShell) or a C# app and run it off of a Windows server. But, I don’t have a Windows server. So, that means looking for other options:

  1. Bash scripting – looked into this, unfortunately what I need to do is a little to complicated for Bash.
  2. Python scripting – much more powerful, and a reasonably familiar syntax. Yes! Lets do this!

So with the help of Google and Stack Overflow, I took a day and took a crash course in Python. I was able to set everything up to check the website, email if it met certain parameters, SMS me using Twilio if it met other parameters, and call me if there was a critical failure. All in all, not bad for what amounts to a quick and dirty script.

I’ve learned that I like working with Python, especially considering how many libraries are available for it, and will definitely consider using it for my next project. Especially if it’s something that needs to work cross-platform.

Leave a Reply

Your email address will not be published. Required fields are marked *