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!! 😊
Python DevOps Automation: System Health Monitor with psutil
More Relevant Posts
-
“How much Python should a DevOps Engineer know?” 🤔 After working through different DevOps tasks, one thing became clear: It’s not about how much Python you know… It’s about how effectively you can use it in real scenarios. Here’s how I see it 👇 💡 Core Skills (Non-negotiable) ✔ Writing clean scripts ✔ Working with files & logs ✔ Handling errors properly 👉 This is the foundation for automation 💡 Practical DevOps Usage ✔ Calling APIs (cloud / tools) ✔ Parsing JSON & YAML ✔ Automating workflows 👉 This is where Python becomes powerful 💡 Advanced Usage (Context-driven) ✔ Building CLI tools ✔ Writing reusable modules ✔ Optimizing scripts for scale 👉 Needed when you're solving larger problems ⚡ Key Insight: In DevOps, Python is not a goal… 👉 It’s a tool to automate, integrate, and scale systems 🚀 For hands-on practice, I found this repo really useful: Check out Abhishek Veeramalla's work 🫡 : 👉 https://lnkd.in/dTqaK8fQ 🧠 Final Thought: Strong DevOps engineers don’t just “know Python”… They use it to eliminate manual work and improve systems How are you using Python in your DevOps workflow? #DevOps #Python #Automation #Cloud #Learning #Engineering
To view or add a comment, sign in
-
🚀 Python for DevOps – Stop Learning, Start Automating Most people learn Python… But very few use it the right way in DevOps. Here’s the truth 👇 👉 You don’t need deep theory. 👉 You need practical automation skills. 🔹 What to Focus On (DevOps Style) ✔ Variables, loops, conditions ✔ Functions ✔ File handling (logs, configs) ✔ Error handling (try/except) ✔ Key modules: os → system operations subprocess → run shell commands json / yaml → config management 🔧 Real Example: Run Linux Command Using Python import subprocess result = subprocess.run(["df", "-h", "/"], capture_output=True, text=True) lines = result.stdout.strip().split("\n") if len(lines) > 1: parts = lines[1].split() usage = int(parts[4].replace("%", "")) if usage > 80: print(f"🚨 ALERT: Disk usage is {usage}%") else: print(f"✅ OK: Disk usage is {usage}%") else: print("❌ Unexpected output:", result.stdout) Output: ubuntu@satheesha:~/python$ python3 Disk-Usage.py ✅ OK: Disk usage is 3% 💡 What This Shows ✔ You can interact with the OS ✔ You can parse real-time system data ✔ You can build automation scripts ✔ You think like a DevOps Engineer 🎯 How I Explain This in Interviews “I use Python’s subprocess module to execute system commands, parse outputs, and automate monitoring tasks like disk usage alerts.” 🔥 Pro Tip Take it one step further: Send alerts to Slack/Email 📩 Schedule with cron ⏰ Integrate with Jenkins 🔁 💬 If you're learning DevOps, stop just writing scripts… Start solving real problems. #DevOps #Python #Automation #Linux #SRE #Cloud #Jenkins #Learning
To view or add a comment, sign in
-
🚀 Learning Python for DevOps – Hands-on Practice with Code Today I worked on a practical DevOps task: Log File Analysis using Python Started with a sample app.log: ERROR: Disk full WARNING: High CPU usage INFO: Service started INFO: Health check passed 🔍 Step 1: Read log file with open("app.log", "r") as f: data = f.read() print(data) ⚠️ Step 2: Filter only ERROR logs with open("app.log", "r") as f: for line in f: if "ERROR" in line: print(line) 📊 Step 3: Count total errors error_count = 0 with open("app.log") as f: for line in f: if "ERROR" in line: error_count += 1 print("Total Errors:", error_count) 🧠 Step 4: Handle multiple log levels (Real-world scenario) error = 0 warning = 0 info = 0 with open("app.log") as f: for line in f: if "ERROR" in line: error += 1 elif "WARNING" in line: warning += 1 elif "INFO" in line: info += 1 print("ERROR:", error) print("WARNING:", warning) print("INFO:", info) 🚨 Step 5: DevOps-style alert output with open("app.log") as f: for line in f: if "ERROR" in line: print("ALERT:", line.strip()) 💡 Key Learning: Python is a powerful tool in DevOps for log monitoring, automation, and faster troubleshooting. 🔥 Even simple scripts like this can help in: Production monitoring CI/CD pipelines Incident detection 📈 Next Goal: Build a real-time log monitoring script (like tail -f) using Python #Python #DevOps #Automation #Scripting #Learning #Cloud #100DaysOfCode
To view or add a comment, sign in
-
🚀 Python Basics for DevOps Engineers (With Practical Examples) Python is a must-have skill for DevOps. Here are some basic concepts with real-time examples 👇 🔹 1. Variables name = "server1" cpu_usage = 75 is_running = True print(name) print(cpu_usage) 💡 DevOps Example: server = "web-server" status = "running" print(server, status) 🔹 2. Data Types String → "hello" Integer → 10 Boolean → True / False List → ["app1", "app2"] services = ["nginx", "docker", "jenkins"] print(services[0]) # nginx 🔹 3. Conditions (if-else) Used for decision-making in automation cpu = 85 if cpu > 80: print("High CPU usage") else: print("Normal CPU") 💡 DevOps Example: disk = 90 if disk > 80: print("Alert: Disk almost full") else: print("Disk is normal") 🔹 4. Loops Used to repeat tasks (like checking multiple servers) 👉 for loop: servers = ["web1", "web2", "web3"] for s in servers: print(s) 👉 while loop: i = 1 while i <= 5: print(i) i += 1 🔹 5. Functions Reusable code (very important for scripting) def check_cpu(cpu): if cpu > 80: print("Alert: High CPU") else: print("Normal CPU") check_cpu(85) 🔹 6. Real DevOps Example servers = ["web1", "web2", "web3"] def check_status(server): print(f"Checking {server}...") for s in servers: check_status(s) 🔹 7. Mini Practice cpu = 70 if cpu > 80: print("Alert: scale up server") else: print("Server is stable") 💡 Key Takeaway: Python helps automate repetitive tasks like monitoring, alerts, and server management in DevOps. #DevOps #Python #Automation #Scripting #Learning #AWS #Kubernetes
To view or add a comment, sign in
-
DevOps Journey - Week 11 🚀 This week in my DevOps journey, I moved beyond infrastructure and stepped deeper into Python for real-world automation and integration. Here’s what I worked on: 🔹 Built interactive Python programs using loops, conditionals, and error handling 🔹 Learned how to structure data using lists, sets, and dictionaries 🔹 Created modular code using functions and modules 🔹 Implemented object-oriented programming with classes and objects 🔹 Automated spreadsheet processing using openpyxl 🔹 Connected Python to external systems using APIs with Requests (Python library) 🔹 Pulled real data from GitLab using API calls and processed JSON responses One of my favorite parts was building a script that: 👉 Fetches my GitLab projects 👉 Parses API responses 👉 Displays clean, structured output This is where things started to click. DevOps isn’t just about tools like AWS or Kubernetes. It’s also about automation, integration, and problem-solving with code. Every step is making me more confident in building real-world solutions 🚀 #DevOps #Python #Automation #APIs #GitLab #LearningJourney #CloudComputing #TechGrowth
To view or add a comment, sign in
-
#AIOps 🚀 As a continuation of my previous post on my AIOps journey, I’ve now structured a detailed roadmap for Month 1 of my 4-month plan — with a strong focus on hands-on implementation. This phase is all about building a solid foundation by combining: SRE Concepts Python for automation Core DevOps + Observability concepts 💡 One key thing I’m emphasizing: Learning alone is not enough — practical implementation is critical. At the end of Month 1, I’ve included hands-on exercises to validate and apply what I’ve learned. 🔧 Some of the practical areas I’m working on: Writing Python scripts to interact with Prometheus APIs Parsing and analyzing metrics data (CPU, memory) Building simple threshold-based alerting logic Automating routine DevOps tasks using Python Understanding alert fatigue and improving alert quality 🧠 Foundation for ML-based anomaly detection: Z-score > 2 for 3 consecutive samples Detect 5 anomalies within 1 minute After triggering, suppress alerts for 30 seconds to avoid noise Extending beyond CPU → focusing on error rate and latency 📊 This approach is helping me connect the dots between traditional DevOps and AIOps-driven automation. I’ll continue sharing my learnings, challenges, and real use cases as I progress. 🔗 Roadmap & hands-on tasks: https://lnkd.in/gxxxzZ2i #DevOps #SRE #Python #Automation #Observability #AIOps
To view or add a comment, sign in
-
🚀 Containerizing a Python Internet Connectivity Checker with Docker I recently worked on a hands-on DevOps task where I containerized a Python application to check internet connectivity using Docker. This project helped me understand how containerization simplifies application deployment and ensures consistency across environments. 🔧 What I implemented: • Created a Python script to test internet connectivity using HTTP requests • Used the requests library to send and analyze responses from a server • Built a lightweight Docker image using python:3.10-slim • Automated execution so the script runs instantly when the container starts • Verified connectivity directly from within the container 💡 Key Learnings: • Containerization ensures portability and eliminates dependency issues • Docker makes deployment fast, consistent, and reliable • Automation reduces manual effort and improves efficiency • Useful for real-time network monitoring and health checks 🌐 Use Cases: • Network connectivity testing • DevOps monitoring scripts • Microservices health checks • Automated diagnostics #Docker #Python #DevOps #Containerization #Automation #CloudComputing #LearningByDoing #TechProjects #Networking
To view or add a comment, sign in
-
🚀 Just published a Live DevOps Project! Built an AI-Powered Kubernetes Self-Healing System that can automatically detect failures and fix them in real-time ⚡ 🔍 What it does: • Detects pod issues (CrashLoopBackOff) • Uses simple AI logic to analyze problems • Automatically restarts deployments • Shows live status in a Flask dashboard 🧠 Tech: Kubernetes (K3s) | Docker | Python | DevOps Automation This is a real-world hands-on project for anyone learning DevOps, Cloud, or Kubernetes. 🎥 Watch the full video: https://lnkd.in/g85UhPhB Would love your feedback 👇 #Kubernetes #DevOps #CloudComputing #Python #AI #K8s #Automation #LiveProject
AI-Powered Kubernetes Self-Healing System 🔥 | Auto Fix Crashes with Python + K8s
https://www.youtube.com/
To view or add a comment, sign in
-
🚀 Python for DevOps – Log Level Automation Project Today I built a practical DevOps script using Python to analyze logs and separate them based on log levels. 📂 Problem: Manually checking logs is time-consuming. Needed a way to automatically filter and organize logs. 💻 Solution (Python Script): with open("app.log") as f, \ open("error.log", "w") as err, \ open("warning.log", "w") as warn, \ open("info.log", "w") as info: for line in f: if "ERROR" in line: err.write(line) elif "WARNING" in line: warn.write(line) elif "INFO" in line: info.write(line) ####################################### Output: ubuntu@satheesha:~/python$ python3 multiple-log_level.py ubuntu@satheesha:~/python$ ls -ltr error.log warning.log info.log -rw-r--r-- 1 ubuntu ubuntu 18 Apr 21 07:45 warning.log -rw-r--r-- 1 ubuntu ubuntu 44 Apr 21 07:45 info.log -rw-r--r-- 1 ubuntu ubuntu 17 Apr 21 07:45 error.log ubuntu@satheesha:~/python$ cat app.log INFO: Service startes WARNING: High CPU INFO: Service startes ERROR: Disk full ubuntu@satheesha:~/python$ cat error.log ERROR: Disk full ubuntu@satheesha:~/python$ cat warning.log WARNING: High CPU ubuntu@satheesha:~/python$ cat info.log INFO: Service startes INFO: Service startes ######################################### does: Reads app.log Filters logs into: error.log warning.log info.log 📊 Outcome: Faster troubleshooting Organized logs for better monitoring Reduced manual effort 🔥 Real DevOps Use Cases: Production log monitoring CI/CD pipeline validation Incident detection and alerting 💡 Key Learning: Python is a powerful tool for automation in DevOps, especially for handling logs and system data. 📈 Next Step: Enhancing this script to: Count log levels Trigger alerts (email/Slack) Monitor logs in real-time (tail -f style) #Python #DevOps #Automation #Scripting #Cloud #Learning #100DaysOfCode
To view or add a comment, sign in
-
🐍 Want to start Python from scratch? This FREE resource is gold! 📘 Complete Python for Beginners – Notes by Rishabh Mishra If you're planning to learn Python (or strengthen your basics), this book gives a clear and structured foundation. Here’s what it covers 👇 ✅ Python basics – variables, data types, operators ✅ Control flow – if-else, loops, conditions ✅ Functions & arguments (real coding examples) ✅ Core concepts like lists, strings, and type casting ✅ Step-by-step setup + beginner-friendly explanations 💡 Why this is useful: Python is one of the most popular languages used in DevOps, Data Science, AI, and Automation (GeeksforGeeks) And this guide makes it simple to start without confusion. 🔥 As a DevOps Engineer, I’m focusing on improving Python skills for: • Automation • Scripting • Cloud & Infrastructure tasks 💬 Let’s discuss: 👉 Are you learning Python for DevOps, Data Science, or Development? 🔗 My LinkedIn Profile: https://lnkd.in/gpakHghj #Python #DevOps #Programming #Automation #Coding #Beginners #Learning #Tech #SoftwareDevelopment
To view or add a comment, sign in
More from this author
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
All the best for your journey 👍