🚀 Monitor Disk Usage with Python (DevOps Practical Tip) As a DevOps Engineer, keeping an eye on disk usage is critical to avoid unexpected outages in production. Here’s a simple Python script I use to check disk usage of the root filesystem: import subprocess result = subprocess.run(["df", "-h", "/"], capture_output=True, text=True) print(result.stdout) 🔍 What this does: Executes df -h / to fetch disk usage Displays output in a human-readable format 💡 Real-world use case: You can extend this script to trigger alerts when disk usage crosses a threshold (say 80%): for line in result.stdout.split("\n"): if "/" in line: usage_percent = int(line.split()[4].replace("%", "")) if usage_percent > 80: print("⚠️ Alert: Disk usage is above 80%") Output: ubuntu@satheesha:~/python$ python3 check-disk_usage.py Filesystem Size Used Avail Use% Mounted on /dev/sdd 1007G 28G 928G 3% / 🔥 Where this helps: Production server monitoring Preventing downtime due to full disk Automating health checks via cron jobs Integrating with alerting tools (Slack, Email, etc.) Simple scripts like this can save hours of troubleshooting and keep systems stable. #DevOps #Python #Automation #Monitoring #Linux #SRE
Monitor Disk Usage with Python Script
More Relevant Posts
-
🚀 Python for DevOps – Log Monitoring with File Output Today I built a simple automation script to read logs and write alerts to a separate file. 📂 Scenario: Instead of manually checking logs, automate detection of ERROR messages and store them in another file. 💻 Python Code: with open("app.log") as f, open("alerts.log", "w") as out: for line in f: if "ERROR" in line: out.write(line) output: root@satheesha:~# python3 Python 3.12.3 (main, Mar 3 2026, 12:15:18) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> with open("app.log") as f, open("Alert.log", "w") as out: ... for line in f: ... if "ERROR" in line: ... out.write(line) ... 17 >>> exit() root@satheesha:~# cat Alert.log ERROR: Disk full 🔍 What this does: Reads app.log line by line Filters only ERROR logs Writes them into alerts.log 📌 Why this is useful: Helps in faster troubleshooting Reduces manual log scanning Can be integrated with monitoring systems 🔥 Real DevOps Use Cases: Production log monitoring CI/CD pipeline validation Incident detection and alerting 📈 Next Step: Enhance this script to: Handle multiple log levels (ERROR / WARNING / INFO) Send alerts to email or Slack Monitor logs in real-time (like tail -f) #Python #DevOps #Automation #Scripting #Cloud #Learning #100DaysOfCode
To view or add a comment, sign in
-
Day 64 - Troubleshooting a Python App Deployed on K8s Cluster #100DaysOfDevOps 🧑💻 Today’s Day 64 of #100DaysOfDevOps was a hands-on Kubernetes troubleshooting scenario that felt very close to a real production incident. A Python Flask app deployed on the cluster was completely unavailable, and digging into the Pods revealed an "ImagePullBackOff" error. After investigating with "kubectl describe", I traced the issue to an incorrect container image, which prevented the Pod from ever starting. Fixing that immediately brought the Pods back to life. But that wasn’t the only issue, traffic still wasn’t reaching the app. The Service was misconfigured with "targetPort: 8080" instead of Flask’s default port 5000, meaning requests were being routed to the wrong destination. Updating the Service to use the correct targetPort and ensuring the required nodePort: 32345 made the application accessible externally. This task reinforced a key production lesson: small misconfigurations in image names or port mappings can completely break deployments, and systematic debugging (Pods → Logs → Services) is critical for fast recovery. I’ve documented the full breakdown and fix here: https://lnkd.in/eKtVpMdK Each challenge is sharpening my troubleshooting instincts and deepening my Kubernetes expertise. 💪 #DevOps #Kubernetes #CloudEngineering #K8s #SRE #Troubleshooting #LearningInPublic
To view or add a comment, sign in
-
No more rebuilding SSH tunnels every 3 hours — this one-touch Python tool automates OCI Bastion session management across all your projects and environments seamlessly.
To view or add a comment, sign in
-
Easily merge ODS files with Python! With the GroupDocs.Merger Cloud SDK for Python, you can seamlessly combine multiple ODS documents using a simple REST API. This powerful tool saves you time and effort, allowing you to focus on more critical tasks. Unlock the potential of your document management process and streamline your workflow today. https://lnkd.in/djKUiCgd
To view or add a comment, sign in
-
🐍📈 DevOps With Python — With this learning path you'll sample a variety of skills and technologies that any DevOps engineer working with Python should know #python #learnpython
To view or add a comment, sign in
-
🚀 Simple Python Script for DevOps Practice In DevOps, even small scripts can make a big difference in automation and monitoring. Here’s a simple Python script I practiced to simulate basic server details and loop operations 👇 name = "server1" cpu_usage = 75 is_running = True print(f"Name: {name}") print(f"CPU Usage: {cpu_usage}%") print(f"Is Running: {is_running}") print("-" * 30) for i in range(6): print(i) print("-" * 30) for i in range(1, 12, 2): print(i) print("-" * 30) for i in range(10, -1, -1): print(i) print("-" * 30) Output: ubuntu@satheesha:~/python$ python3 variable-for_loop.py Name: server1 CPU Usage: 75% Is Running: True ------------------------------ 0 ------------------------------ 1 ------------------------------ 2 ------------------------------ 3 ------------------------------ 4 ------------------------------ 5 ------------------------------ 1 ------------------------------ 3 ------------------------------ 5 ------------------------------ 7 ------------------------------ 9 ------------------------------ 11 ------------------------------ 10 ------------------------------ 9 ------------------------------ 8 ------------------------------ 7 ------------------------------ 6 ------------------------------ 5 ------------------------------ 4 ------------------------------ 3 ------------------------------ 2 ------------------------------ 1 ------------------------------ 0 ------------------------------ 🔹 Key concepts used: ✔ Variables & data types ✔ f-strings for clean output ✔ Loops with range() ✔ Reverse iteration 💡 These basics are very useful for: Automation scripts Monitoring tasks Log analysis Learning step by step and practicing regularly helps build strong DevOps scripting skills. #DevOps #Python #Automation #Scripting #Learning #AWS #Kubernetes #Jenkins
To view or add a comment, sign in
-
🐍 Python in real systems is more than just coding In production environments, Python is used for APIs, automation, data pipelines, and cloud integrations—but the real challenge is not writing code, it’s building systems that are scalable, observable, and easy to maintain. Good engineering is less about complexity and more about clarity, reliability, and design that holds up in production. #Python #SoftwareEngineering #Backend #SystemDesign #CloudComputing
To view or add a comment, sign in
-
🚀 pywho — a debugging painkiller for Python developers (30+ GitHub stars in 1 month 🔥) 💡 What is pywho? A zero-dependency Python CLI that explains your environment, traces imports, and detects module shadowing. No guessing. No scattered checks. Just clear answers. ⚠️ Pain point: Debugging Python issues usually means checking: • Interpreter • Virtualenv • sys.path • pip • Import resolution 👉 All separately → slow, repetitive, and perfect for “works on my machine” problems 📊 Existing tools: • Python built-in site/path inspection • pip debug • Manual import checks 👉 Useful individually, but each shows only part of the picture 🛠️ What pywho does: One CLI that gives you: ✅ Interpreter details ✅ Virtualenv detection ✅ Import tracing ✅ Import resolution insights ✅ Module shadow scanning ✅ JSON output for CI/sharing ➡️ One place, not five ➡️ Zero dependency ➡️ Cross-platform ➡️ Built for real debugging workflows 👨💻 For all Python developers 🔗 GitHub: https://lnkd.in/dMvz9PYM 🔗 PyPI: https://lnkd.in/dM72_8rs 🔗 Docs: https://lnkd.in/dCvUBAeu ♻️ Resharing to support the Python community 🤝 💬 What’s the most confusing Python environment issue you’ve debugged? #Python #PythonDeveloper #PythonDev #PyPI #PythonTools #DebuggingTools #DeveloperTools #DevTools #CLItools #CommandLine #SoftwareEngineering #BackendDevelopment #DevOps #OpenSource #OpenSourceProject #Programming #CodingLife #BuildInPublic #TechInnovation #ProductivityTools #Automation #CI_CD #TestingTools #PythonTips #CodeQuality #SoftwareDevelopment #DevelopersLife #TechCommunity #GitHubProjects
To view or add a comment, sign in
-
-
🚀 pywho — a debugging painkiller for Python developers (~45 stars ⭐ on GitHub 🔥) 💡 What is pywho? A zero-dependency Python CLI that explains your environment, traces imports, and detects module shadowing. No guessing. No scattered checks. Just clear answers. ⚠️ Pain point: Debugging Python issues usually means checking: • Interpreter • Virtualenv • sys.path • pip • Import resolution 👉 All separately → slow, repetitive, and perfect for “works on my machine” problems 📊 Existing tools: • Python built-in site/path inspection • pip debug • Manual import checks 👉 Useful individually, but each shows only part of the picture 🛠️ What pywho does: One CLI that gives you: ✅ Interpreter details ✅ Virtualenv detection ✅ Import tracing ✅ Import resolution insights ✅ Module shadow scanning ✅ JSON output for CI/sharing ➡️ One place, not five ➡️ Zero dependency ➡️ Cross-platform ➡️ Built for real debugging workflows 👨💻 For all Python developers 🔗 GitHub: https://lnkd.in/dMvz9PYM 🔗 PyPI: https://lnkd.in/dM72_8rs 🔗 Docs: https://lnkd.in/dCvUBAeu ♻️ Resharing to support the Python community 🤝 💬 What’s the most confusing Python environment issue you’ve debugged? #Python #PythonDeveloper #PythonDev #PyPI #PythonTools #DebuggingTools #DeveloperTools #DevTools #CLItools #CommandLine #SoftwareEngineering #BackendDevelopment #DevOps #OpenSource #OpenSourceProject #Programming #CodingLife #BuildInPublic #TechInnovation #ProductivityTools #Automation #CI_CD #TestingTools #PythonTips #CodeQuality #SoftwareDevelopment #DevelopersLife #TechCommunity #GitHubProjects
To view or add a comment, sign in
-
-
# 7. Python: A Powerful Language for Modern Development Python is one of the most versatile and widely used programming languages in the world. Known for its simplicity and readability, Python is used across multiple domains including web development, automation, data science, machine learning, and DevOps. One of the reasons for Python’s popularity is its **clean and intuitive syntax**, which makes it easy for beginners to learn while still being powerful enough for complex applications. Python supports multiple programming paradigms, including: • Object-oriented programming • Functional programming • Procedural programming This flexibility allows developers to build a wide variety of applications efficiently. Python also has a vast ecosystem of **libraries and frameworks**. For example: • Django and Flask for web development • Pandas and NumPy for data analysis • TensorFlow and PyTorch for machine learning • Selenium for automation testing In the DevOps world, Python is often used to automate repetitive tasks such as infrastructure management, monitoring, and deployment. Many popular tools like **Ansible and AWS CLI** are built using Python, highlighting its importance in cloud and automation environments. Python’s cross-platform compatibility allows applications to run on Windows, Linux, and macOS without major modifications. This portability makes it a preferred language for developers worldwide. Companies value Python developers because they can build scalable applications, automate workflows, and work with modern technologies such as artificial intelligence and cloud computing. Learning Python is a great investment for anyone entering the technology field. Its versatility, strong community support, and wide range of applications make Python one of the most valuable programming languages today. #Python #Programming #Automation #DevOps #SoftwareDevelopment #Coding
To view or add a comment, sign in
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