Open Luciensday opened 1 month ago
check_cpu_usage() { echo "CPU Usage:"
uptime | awk '{printf "1 min: %-6s 5 min: %-6s 15 min: %-6s\n", $(NF-2), $(NF-1), $NF}' echo ""
}
top_cpu_processes() { echo "Top 5 CPU-consuming processes:" ps aux --sort=-%cpu | awk 'NR==1 || NR<=6 {printf "%-10s %-8s %-8s %-8s %s\n", $1, $2, $3, $4, $11}' echo "" }
check_memory_usage() { echo "Memory Usage:"
free -h | awk 'NR==1 || NR==2 {printf "%-10s %-10s %-10s %-10s\n", $1, $2, $3, $4}' echo ""
top_memory_processes() { echo "Top 5 memory-consuming processes:" ps aux --sort=-%mem | awk 'NR==1 || NR<=6 {printf "%-10s %-8s %-8s %-8s %s\n", $1, $2, $3, $4, $11}' echo "" }
check_disk_usage() { echo "Disk Usage Information:" df -h | awk 'NR==1 || /^\/dev\// {printf "%-20s %-10s
!/bin/bash
Function to check CPU usage
check_cpu_usage() { echo "CPU Usage:"
Display average CPU load over the last 1, 5, and 15 minutes
}
Function to find the top 5 CPU-consuming processes
top_cpu_processes() { echo "Top 5 CPU-consuming processes:" ps aux --sort=-%cpu | awk 'NR==1 || NR<=6 {printf "%-10s %-8s %-8s %-8s %s\n", $1, $2, $3, $4, $11}' echo "" }
Function to check memory usage
check_memory_usage() { echo "Memory Usage:"
Display memory usage using free command
}
Function to find the top 5 memory-consuming processes
top_memory_processes() { echo "Top 5 memory-consuming processes:" ps aux --sort=-%mem | awk 'NR==1 || NR<=6 {printf "%-10s %-8s %-8s %-8s %s\n", $1, $2, $3, $4, $11}' echo "" }
Function to check disk usage
check_disk_usage() { echo "Disk Usage Information:" df -h | awk 'NR==1 || /^\/dev\// {printf "%-20s %-10s