In this Python Programming Tutorial, we’re going to be looking at a real-world example of writing a script to monitor a website. If the website doesn’t return a successful response for any reason then we will send an email and reboot the web server. Let’s get started…
The code from this video (with added logging) can be found at:
http://bit.ly/monitor-script
Google Account Settings:
https://myaccount.google.com/lesssecureapps
https://myaccount.google.com/apppasswords
Requests Video – https://youtu.be/tb8gHvYlCFs
Environment Variables (Windows) – https://youtu.be/IolxqkL7cD8
Environment Variables (Mac and Linux) – https://youtu.be/5iWhQWVXosU
Try/Except Video – https://youtu.be/NIWwJbo-9_8
F-String Video – https://youtu.be/nghuHvKLhJA
Crontab Video – https://youtu.be/QZJ1drMQz1A
✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms
✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join
✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey’s Public Amazon Wishlist
http://a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website – http://coreyms.com/
My Second Channel – https://www.youtube.com/c/coreymschafer
Facebook – https://www.facebook.com/CoreyMSchafer
Twitter – https://twitter.com/CoreyMSchafer
Instagram – https://www.instagram.com/coreymschafer/
#Python
I put the code to this script in the description section of the video. For anyone who would like to see what some basic logging would look like for this script, I added some logging code to the script and commented it out for reference. I hope you all find these real-world examples helpful!
I have a half finished app on my GitHub a bit like this, it monitors a list of sites with requests and sends and email for any that are down and it runs every min on AWS Lambda. I have another part that uses paramiko which will then ssh into the server of any site that is down to debug the issues. I didn't get any further than that the plan was/is for paramiko to run commands such as check the status of apache, RAM, disk space, mysql etc etc and run re-boot commands accordingly for any that are failing or send further alerts.
One of the best tutorial in the entire universe!
I think that I will never unsubscribe your channel because You have a monster power sir, you can do great python programming and also CLI master on Linux. If I can make a request then I hope next time you make video about get how many user connecting to a network and then adjust the equal bandwidth for every hosts using iptables by using python power. Thank you.
Love your mini projects. These are awesome please keep posting
Awesome tutorial! It helped me to become familiar with virtualenv development. Also I realized how to work with API of my VPS provider. Did my own server monitoring script with your guidance. https://github.com/movalex/servermon. Also realized I had to add local variables initialization to cron to get it to work. Looking forward to bring it further. Thanks!
Hey Corey, when will the Flask Heroku deployment video come? I am not very smart and I can't figure it out myself and with other videos. I learned Flask through your series, and I think I will be able to deploy my site if this deployment video comes. Thanks!
Nice stuff! I have a lot of catching up to do =)
r.ok is a built in method that returns True if status is 200
Hey Corey, since you're uploading general python episodes regurarly now, how about a guide to asyncio in python 3.7?
Also, I'm getting my first IT-payment this month thanks to You and You're gettng patronized!
You have the best python tutorials Corey,
Thank you so much for the efforts you put into these videos.
Keep it up
Thank you! Why didn’t you just put your script in an infinite loop and sleep for 10 mins each time around (with some more try blocks in case of sending email fails or the restart fails)?
try: except: else: ????
Hello ,
Why you are using the node server? Does Django server is not good?
amazing videos, please keep it up. Best i've seen on YT so far
I particularly appreciated that you indicated why and how you gradually improved your script. Too many times, I find those complicated scripts on github and I wonder what were the steps to get to the final version.