linux shell脚本之监控脚本
#!
#case语句的监控脚本
clear
echo -e "\033[42m---------------------------\033[0m"
echo -e "#\e[32m 1.查看网卡信息\e[0m #"
echo -e "#\e[32m 2.查看内存剩余容量信息\e[0m #"
echo -e "#\e[32m 3.查看磁盘剩余容量信息\e[0m #"
echo -e "#\e[32m 4.查看cpu负载信息\e[0m #"
echo -e "#\e[32m 5.查看当前用户数量信息\e[0m #"
echo -e "#\e[32m 6.输入数字6退出\e[0m #"
echo -e "\033[42m---------------------------\033[0m"
echo
while :
do
echo -en "\e[32m 请用户输入你所需要查看的信息序号: \e[0m "
read a
case $a in
1)
ip=`ifconfig ens33 | grep " inet " | tr -s " " | cut -d" " -f3`
echo " 当前网卡ip为: $ip ";;
2)
neicun=` head -3 /proc/meminfo | tail -1 | tr -s " " | cut -d" " -f2 `
echo "当前内存剩余容量为: $neicun";;
3)
disk=` df -h / | tail -1 | tr -s " " | cut -d" " -f4`
echo "当前磁盘剩余容量为: $disk ";;
4)
fuzai=` cat /proc/loadavg | cut -d" " -f3 `
echo "当前cpu负载为: $fuzai";;
5)
user=`ps aux | wc -l `
echo "当前用户数量为: $user ";;
6)
exit;;
*)
echo "请重新输入1-5 "
esac
done