Skip to content
View Affan2310's full-sized avatar

Block or report Affan2310

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Maximum 250 characters. Please don’t include any personal information such as legal names or email addresses. Markdown is supported. This note will only be visible to you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Affan2310/README.md

MasterHead

Hi 👋, I'm Mohammed Affan

Bridging DevOps and the Cloud for Efficiency

Coding

💫 About Me:

🔭 I'm currently working on Hands-on with DevOps tools and shaping cloud solutions on Azure and AWS.

🌱 I'm currently learning Steadily mastering DevOps tools while diving deep into [...]

🌐 Socials:

Instagram LinkedIn

💻 Tech Stack:

C C++ Python Bash AWS Azure Docker Kubernetes

📊 GitHub Stats:



🏆 GitHub Trophies


🖥️ Projects

VM Health Check Script 📊

A comprehensive shell script for monitoring and analyzing the health of Ubuntu virtual machines based on CPU, memory, and disk space utilization.

Quick Overview

  • Purpose: Monitor VM health with CPU, Memory, and Disk metrics
  • Threshold: 70% utilization
  • Status: Healthy (≤70%) or Unhealthy (>70%)
  • Target OS: Ubuntu 16.04 LTS and later

Features ✨

  • ✅ Real-time CPU, Memory, and Disk monitoring
  • ✅ Configurable health thresholds (default: 70%)
  • ✅ Color-coded output for easy interpretation
  • explain argument for detailed metrics and recommendations
  • ✅ Exit code support for automation (0=healthy, 1=unhealthy)
  • ✅ Cron-friendly for scheduled monitoring
  • ✅ Comprehensive error handling with fallback methods

Quick Start 🚀

Installation:

# Clone the repository
git clone https://github.com/Affan2310/Affan2310.git
cd Affan2310

# Make script executable
chmod +x vm_health_check.sh

# Run the script
./vm_health_check.sh

Basic Usage:

# Quick health check
./vm_health_check.sh

# Detailed health check with recommendations
./vm_health_check.sh explain

Output Examples 📸

Healthy VM:

✓ VM Health Status: Healthy

Unhealthy VM with Explain:

✗ VM Health Status: Unhealthy

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
VM Health Check Details (Threshold: 70%)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

CPU Utilization:    45% (NORMAL)
Memory Utilization: 82% (CRITICAL - Above threshold)
Disk Utilization:   91% (CRITICAL - Above threshold)

Recommended Actions:
  • Memory: Review memory-consuming applications...
  • Disk: Clean up unnecessary files...

Scheduling with Cron 🕐

# Edit crontab
crontab -e

# Run every hour
0 * * * * /path/to/vm_health_check.sh >> /var/log/vm-health.log 2>&1

# Run every 30 minutes with detailed output
*/30 * * * * /path/to/vm_health_check.sh explain >> /var/log/vm-health.log 2>&1

Key Metrics Monitored 📈

Metric Method Threshold Healthy Unhealthy
CPU Usage top -bn1 ≤70%
Memory Usage /proc/meminfo ≤70%
Disk Usage df -h / ≤70%

Health Status Logic 🔍

IF (CPU > 70%) OR (Memory > 70%) OR (Disk > 70%)
    THEN Status = "Unhealthy" ⚠️
ELSE
    Status = "Healthy" ✓
ENDIF

Troubleshooting Issues 🔧

Permission Denied:

chmod +x vm_health_check.sh

Command Not Found (e.g., top):

sudo apt update && sudo apt install -y procps

Memory/Disk Issues:

free -h              # Check memory
df -h                # Check disk space
du -sh /*            # Find large directories

Integration Examples 🔗

Email Alert on Unhealthy VM:

#!/bin/bash
if ! ./vm_health_check.sh; then
    echo "VM is unhealthy!" | mail -s "Alert" [email protected]
fi

Check Exit Code:

./vm_health_check.sh
if [ $? -eq 0 ]; then
    echo "VM is healthy"
else
    echo "VM needs attention"
fi

Performance 🚀

  • Execution Time: ~1-1.3 seconds
  • CPU Usage: <2%
  • Memory Usage: ~5-10 MB
  • Recommended Frequency: Every 5-60 minutes

Full Documentation 📖

For comprehensive documentation, including:

  • Detailed setup and installation
  • All command-line arguments
  • Complete output examples
  • Advanced troubleshooting
  • Best practices for monitoring
  • Integration with monitoring systems
  • Performance tracking
  • And much more...

👉 See VM_HEALTH_CHECK_README.md


✍️ Random Dev Quote


Popular repositories Loading

  1. NS_PROJECT NS_PROJECT Public

    HTML

  2. NS.assignment NS.assignment Public

    Java

  3. LMP-DSA-Revision- LMP-DSA-Revision- Public

    Forked from AbhishekChauhan9036/LMP-DSA-Revision-

    LMP-DSA-Revision

    C++

  4. 30-Days-Of-JavaScript 30-Days-Of-JavaScript Public

    Forked from Asabeneh/30-Days-Of-JavaScript

    30 days of JavaScript programming challenge is a step-by-step guide to learn JavaScript programming language in 30 days. This challenge may take more than 100 days, please just follow your own pace.

    JavaScript

  5. Newon_School Newon_School Public

    Forked from Ramkewalchauhan12/Newon_School

    Java

  6. Graviton-Batch Graviton-Batch Public

    Forked from harshwardhanedu/Graviton-Batch

    Java