🚀 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
Python DevOps Script for Server Monitoring
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
-
Python Naming and Coding Standards Python naming conventions and coding standards are essential skills for developers who want to write professional, readable code that other programmers can easily understand and maintain. Whether you’re a beginner learning your first programming language or an experienced developer switching to Python, following established Python coding standards will make your code cleaner and more collaborative. https://lnkd.in/gESmjYBV Amazon Web Services (AWS) #AWS, #AWSCloud, #AmazonWebServices, #CloudComputing, #CloudConsulting, #CloudMigration, #CloudStrategy, #CloudSecurity, #businesscompassllc, #ITStrategy, #ITConsulting, #viral, #goviral, #viralvideo, #foryoupage, #foryou, #fyp, #digital, #transformation, #genai, #al, #aiml, #generativeai, #chatgpt, #openai, #deepseek, #claude, #anthropic, #trinium, #databricks, #snowflake, #wordpress, #drupal, #joomla, #tomcat, #apache, #php, #database, #server, #oracle, #mysql, #postgres, #datawarehouse, #windows, #linux, #docker, #Kubernetes, #server, #database, #container, #CICD, #migration, #cloud, #firewall, #datapipeline, #backup, #recovery, #cloudcost, #log, #powerbi, #qlik, #tableau, #ec2, #rds, #s3, #quicksight, #cloudfront, #redshift, #FM, #RAG
To view or add a comment, sign in
-
Understanding Tuples and Sets in Python is a small step that makes a big difference in DevOps 🚀 Tuple = immutable (safe & fast) List = mutable (flexible) Set = no duplicates (optimized loops & clean data) In real DevOps workflows, using sets can reduce unnecessary iterations and improve script performance. If you're working with automation or CI/CD, these basics matter more than you think. Blog Link: https://lnkd.in/d8_md7WK , https://lnkd.in/dKm-mpnG #Python #DevOps #Automation #DataStructures #CICD
To view or add a comment, sign in
-
🚀 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
To view or add a comment, sign in
-
🚀 Python for DevOps – Real-Time Error Monitoring Practiced building a simple real-time log monitoring script using Python to detect errors instantly. 📂 Use Case: In production, logs are continuously generated. We need a way to detect errors in real time instead of manually checking files. 💻 Python Script: import time with open("app.log", "r") as f: f.seek(0, 2) # move to end of file while True: line = f.readline() if not line: time.sleep(1) continue if "ERROR" in line: print("Alert:", line.strip()) Output: ubuntu@satheesha:~/python$ python3 real-time_log-montr.py Alert ERROR: Test Wed Apr 22 08:05:25 UTC 2026 Alert ERROR: Test Wed Apr 22 08:05:27 UTC 2026 Alert ERROR: Test Wed Apr 22 08:05:29 UTC 2026 Alert ERROR: Test Wed Apr 22 08:05:31 UTC 2026 🔍 What this does: Reads log file in real time Starts from end (like tail -f) Continuously checks for new entries Prints alert when ERROR is detected 🔥 Why this matters: Helps detect issues instantly Reduces downtime Automates monitoring tasks 💡 Key Learning: Python can be used to build lightweight monitoring tools, similar to real-world DevOps systems. 📈 Next Step: Add timestamps Handle multiple log levels Send alerts (email/Slack) Auto-restart services on failure #Python #DevOps #Automation #Monitoring #Logging #Scripting #Learning #100DaysOfCode
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
-
# 18. Python Python has emerged as one of the most versatile and widely used programming languages in the world, powering everything from web applications to data science and automation. One of Python’s greatest strengths is its simplicity. Its clean and readable syntax makes it accessible to beginners while still being powerful enough for advanced use cases. In the context of IT and security, Python is a go-to language for automation. Tasks such as log analysis, API integration, and data processing can be implemented quickly and efficiently. Python also plays a significant role in DevOps and cloud engineering. It is widely used for scripting, infrastructure automation, and building tools that integrate with cloud platforms like AWS, Azure, and GCP. Another major area where Python shines is data science and machine learning. Libraries like Pandas, NumPy, and TensorFlow enable organizations to extract insights and build intelligent systems. From a cybersecurity perspective, Python is used for building security tools, performing vulnerability assessments, and automating incident response. Its extensive ecosystem of libraries and frameworks makes it highly adaptable. Whether you’re building a web application with Django, automating workflows, or analyzing data, Python provides the tools you need. For professionals in technology, learning Python is not just an option—it’s a strategic investment. It enables innovation, improves productivity, and opens doors to diverse career opportunities. As technology continues to evolve, Python remains at the forefront, driving innovation across industries. #Python #Programming #Automation #DataScience #DevOps #CyberSecurity #Cloud #AI
To view or add a comment, sign in
-
Improving your Python skills is not just about writing code that works. It is about writing code that is efficient, readable, scalable, and production ready. These Python tips and tricks focus on practical improvements that make a real difference: ➜ Writing clean and Pythonic code using best practices ➜ Using list, dict, and set comprehensions effectively ➜ Leveraging built in functions for faster execution ➜ Optimizing loops and reducing time complexity ➜ Understanding memory usage and performance tuning ➜ Mastering functions, lambda expressions, and closures ➜ Applying object oriented design properly ➜ Handling exceptions and debugging efficiently ➜ Working smartly with files and data processing ➜ Using generators and iterators for memory efficiency ➜ Structuring projects with modules and virtual environments ➜ Writing reusable, maintainable, and testable code ➜ Avoiding common mistakes that slow down applications Perfect for developers who want to move from basic scripting to writing professional level Python code. Learn more from w3schools.com 💚 Code smarter. Build faster. Think like a pro. 𝐂𝐨𝐮𝐫𝐬𝐞𝐬 𝐲𝐨𝐮 𝐰𝐢𝐥𝐥 𝐫𝐞𝐠𝐫𝐞𝐭 𝐧𝐨𝐭 𝐭𝐚𝐤𝐢𝐧𝐠 𝐢𝐧 𝟐𝟎𝟐𝟔. 1 Meta Front-End Developer 🔗 imp.i384100.net/g1KEQ5 2. Programming with JavaScript 🔗 imp.i384100.net/XYDqvg 3. Machine Learning Specialization 🔗 imp.i384100.net/XYQ9jy 4. Deep Learning Specialization 🔗 imp.i384100.net/jroLxe 5. IBM Data Science Professional Certificate 🔗 imp.i384100.net/LXbNjj 6. Python for Data Science, AI & Development 🔗 imp.i384100.net/1rq3Km 7. Google Data Analytics 🔗 imp.i384100.net/KjnNrn 8. Google Cybersecurity 🔗 imp.i384100.net/Or5L6G 9. Google Project Management 🔗 imp.i384100.net/OeRLoP 10. Meta Social Media Marketing 🔗 imp.i384100.net/RGyDYv 11. Google Cloud imp.i384100.net/19Pz7D 12. Data Structures and Algorithm imp.i384100.net/VxYdN6 13. IBM Full STACK Developer imp.i384100.net/JKVZ22 14. Full Stack Java Developer imp.i384100.net/o4LJOo 15. Mean Stack Developer imp.i384100.net/BnykPB Happy Learning 🌟 #python #aicourses #aicommunity #linkdin #upskill #career #growth #freecourses #microsoft LinkedIn Learning JavaScript Mastery
To view or add a comment, sign in
-
Multi-Agent A2A with the Agent Development Kit(ADK), AWS Lightsail, and Gemini CLI: Leveraging the Google Agent Development Kit (ADK) and the underlying Gemini LLM to build Multi-Agent Applications with A2A protocol support using the Python programming language. Aren’t There a Billion Python ADK Demos? Yes there are. Python has traditionally been the main coding language for ML and AI tools. The goal of this article is to provide a multi-agent test bed for building, debugging, and deploying multi-agent applications. What you talkin ‘bout Willis? So what is different about this lab compared to all the others out there? This is one of the first deep dives into a Multi-Agent application leveraging the advanced tooling of Gemini CLI. The starting point for the demo was an existing Codelab- which was updated and re-engineered with Gemini CLI. The original Codelab- is here: Building a Multi-Agent System | Google Codelabs What Is Python? Python is an interpreted language that allows for rapid development and testing and has deep libraries for working with ML and AI: Welcome to Python.org Python Version Management One of the downsides of the wide deployment of Python has been managing the language versions across platforms and maintaining a supported version. The pyenv tool enables deploying consistent versions of Python: GitHub - pyenv/pyenv: Simple Python version management As of writing — the mainstream python version is 3.13. To validate your current Python:python --version Python 3.13.13 Amazon Lightsail Amazon Lightsail is an easy-to-use virtual private server (VPS) provider and cloud platform designed by AWS for simpler workloads, offering developers pre-configured compute, storage, and networking for a low, predictable monthly price. It is ideal for hosting small websites, simple web apps, or creating development environments. More information is available on the official site here: Amazon's Simple Cloud Server | Amazon Lightsail And this is the direct URL to the console:https://lnkd.in/eV7DaV8y The Lightsail console will look similar to: Gemini CLI If not pre-installed you can download the Gemini CLI to interact with the source files and provide real-time assistance:npm install -g @google/gemini-cli Testing the Gemini CLI Environment Once you have all the tools and the correct Node.js version in place- you can test the startup of Gemini CLI. You will need to authenticate with a Key or your Google Account:▝▜▄ Gemini CLI v0.33.1 ▝▜▄ ▗▟▀ Logged in with Google /auth ▝▀ Gemini Code Assist Standard /upgrade no sandbox (see /docs) /model Auto (Gemini 3) | 239.8 MB Node Version Management Gemini CLI needs a consistent, up to date version of Node. The nvm command can be used to get a standard Node environment: GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple… #genai #shared #ai
To view or add a comment, sign in
-
Improving your Python skills is not just about writing code that works. It is about writing code that is efficient, readable, scalable, and production ready. These Python tips and tricks focus on practical improvements that make a real difference: ➜ Writing clean and Pythonic code using best practices ➜ Using list, dict, and set comprehensions effectively ➜ Leveraging built in functions for faster execution ➜ Optimizing loops and reducing time complexity ➜ Understanding memory usage and performance tuning ➜ Mastering functions, lambda expressions, and closures ➜ Applying object oriented design properly ➜ Handling exceptions and debugging efficiently ➜ Working smartly with files and data processing ➜ Using generators and iterators for memory efficiency ➜ Structuring projects with modules and virtual environments ➜ Writing reusable, maintainable, and testable code ➜ Avoiding common mistakes that slow down applications Perfect for developers who want to move from basic scripting to writing professional level Python code. Learn more from w3schools.com. 💚 Code smarter. Build faster. Think like a pro. 𝐂𝐨𝐮𝐫𝐬𝐞𝐬 𝐲𝐨𝐮 𝐰𝐢𝐥𝐥 𝐫𝐞𝐠𝐫𝐞𝐭 𝐧𝐨𝐭 𝐭𝐚𝐤𝐢𝐧𝐠 𝐢𝐧 𝟐𝟎𝟐𝟔. 1 Meta Front-End Developer 🔗 imp.i384100.net/g1KEQ5 2. Programming with JavaScript 🔗 imp.i384100.net/XYDqvg 3. Machine Learning Specialization 🔗 imp.i384100.net/XYQ9jy 4. Deep Learning Specialization 🔗 imp.i384100.net/jroLxe 5. IBM Data Science Professional Certificate 🔗 imp.i384100.net/LXbNjj 6. Python for Data Science, AI & Development 🔗 imp.i384100.net/1rq3Km 7. Google Data Analytics 🔗 imp.i384100.net/KjnNrn 8. Google Cybersecurity 🔗 imp.i384100.net/Or5L6G 9. Google Project Management 🔗 imp.i384100.net/OeRLoP 10. Meta Social Media Marketing 🔗 imp.i384100.net/RGyDYv 11. Google Cloud imp.i384100.net/19Pz7D 12. Data Structures and Algorithm imp.i384100.net/VxYdN6 13. IBM Full STACK Developer imp.i384100.net/JKVZ22 14. Full Stack Java Developer imp.i384100.net/o4LJOo 15. Mean Stack Developer imp.i384100.net/BnykPB Happy Learning 🌟 ♻️Repost and share to help others. #python #aicourses #aicommunity #linkdin #upskill #career #growth #freecourses #microsoft LinkedIn Learning
To view or add a comment, sign in
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