Python DevOps Automation: System Health Monitor with psutil

Headline: From Manual Checks to Automation: My Day 1 of Python for DevOps! 🐍💻 I’m excited to share that I’ve officially kicked off my #PythonForDevOps journey with #TrainWithShubham! Today’s mission was all about moving beyond the basics and writing a real-world utility: a System Health Monitor. 📊 What the script does: ✅ Takes user-defined thresholds for CPU, Memory, and Disk usage. ✅ Fetches real-time system metrics using the psutil library. ✅ Compares them and alerts if the system is under stress. Key Takeaways: The Power of Libraries: Using psutil showed me how easily Python can "talk" to the underlying OS. Logic over Syntax: Understanding if/else and functions is the secret sauce to building reliable automation. DevOps Mindset: It’s not just about code; it’s about ensuring system reliability and proactive monitoring. Feeling great about this submission and ready to dive deeper into the world of automation! Special thanks to Shubham Londhe for the guidance. 🚀 #PythonForDevOps #TrainWithShubham #DevOpsKaJosh #Automation #Python #LearningInPublic #CloudEngineering Sample code: import psutil def check_system_health():     cpu_threshodld = input("Enter CPU usage threshold (in percentage): ")     print("current cpu threshold is : ", cpu_threshodld)     current_cpu = psutil.cpu_percent(interval=1)     print("Current CPU %: ", current_cpu)     if current_cpu > int(cpu_threshodld):         print("CPU usage is above the threshold! sending email aert....")     else:         print("cpu is in normal state") check_system_health() you can follow the updates here: https://lnkd.in/gctzNhJE Happy learning!! 😊

All the best for your journey 👍

Like
Reply

To view or add a comment, sign in

Explore content categories