Week 14 practice
Python Practice
Assignment
This assignment will hone your skills as a Python script writer.
Tasks
Create the following script using python:
- You script should login to several hosts and check to make sure that services are on. If services are not on, an email alert should be sent to you.
- This should be ran as a cron job every hour.
You should begin with a hosts file that has the following format:
host1:process_to_check host2:process_to_check host3:process_to_check host4:process_to_check
Maybe something like:
1.1.1.1:mysql
1.1.1.2:apache2
1.1.1.3:bind9
1.1.1.4:bind9
- Make sure you can write an appropriate shell command to see if a process is running (i.e.
system apache2 status
, then grep what you want from there) - The script should be run like this:
./process_monitor.py hostlist
If you get stuck, a potential solution is here
Last Updated 02/07/2025