Ex. What can we develop by using Python for DevOps?

Problem: Monitor web server logs and send out an email (or notification) when 500’s or 400’s appear more than 10 times in last 10 minutes.
Solution: Write a python script to parse the web server logs and keep a count of status codes. Set a cronjob or run this script as a daemon.

Problem: MySQL server is throwing too many connections.
Solution: Write a python script that connects to MySQL and parses `show processlist` to find the number of connections per user per host. Send an email with this information to team. This can again be a cronjob on the MySQL server itself or any server which can connect to MySQL.




Problem: We need to monitor uptime for our website.
Solution: Write a script in python that pings your website and looks for a 200. If you don’t get 200 send out an email to team. You can set a cronjob on multiple servers (except the server hosting your website).

Problem: Deployments on Staging are a mess.
Solution: Write an application in Flask with a minimal UI that allows developer to select a service and the branch to be deployed. Behind the scenes you could use simple git commands to fetch the code and restart the service.
[My colleague wrote one in Sinatra and the developers loved it!]