#!/bin/bash#輸入不同字符完成不同巡檢內(nèi)容#打印提示符HINT(){ read -p "請(qǐng)按回車?yán)^續(xù):"}#查看CPU信息CPU_INFO(){ echo echo -e "\033[4;31mPrint the CPU info:\033[0m" cat /proc/cpuinfo | awk 'BEGIN {FS=":"} /model name/{print "CPU Model:" $2 }' cat /proc/cpuinfo | awk 'BEGIN {FS=":"} /cpu MHz/{print "CPU Speed:" $2"MHz"}' grep -Eq 'svm|vmx' /proc/cpuinfo && echo "Virtualization: Support" || echo "Virtualization: No Support" echo}#查看系統(tǒng)負(fù)載LOAD_INFO(){ echo -e "\033[4;31mPrint the system load:\033[0m" uptime | awk 'BEGIN{FS=":"} {print $5}' | awk 'BEGIN{FS=","}\ {print "Last 1 minutes system load:"$1"\n""Last 5 minutes system load:"$2"\n" "Last 15 minutes system load:"$3}'echo}#查看內(nèi)存與交換分區(qū)信息MEM_INFO(){ echo echo -e "\033[4;31mPrint the Memory and Swap info:\033[0m" free | grep Mem | awk '{print "Mem free: "$5" Bytes"}' free | grep Swap | awk '{print "Swap free: "$4" Bytes"}' echo}#查看磁盤掛載信息DISK_INFO(){ echo echo -e "\033[4;31mPrint system disk space usage:\033[0m" df -h echo}while truedo clear echo "------------------------------------------------------" echo "1. 查看CPU信息" echo "2. 查看系統(tǒng)負(fù)載" echo "3. 查看內(nèi)存與交換分區(qū)信息" echo "4. 查看磁盤掛載信息" echo "5. 退出系統(tǒng)" echo "-------------------------------------------------------" read -p "請(qǐng)選擇1-4選項(xiàng):" U_SELECT #通過調(diào)用函數(shù)名稱調(diào)用函數(shù) case $U_SELECT in 1) CPU_INFO HINT ;; 2) LOAD_INFO HINT ;; 3) MEM_INFO HINT ;; 4) DISK_INFO HINT ;; 5) exit ;; *) read -p "請(qǐng)選擇1-4選項(xiàng),輸入回車?yán)^續(xù):" ;; esacdone
聯(lián)系客服