1. 程式人生 > >用shell寫的基本監控菜單

用shell寫的基本監控菜單

Shell

#!/bin/bash

while :
do
echo "1. 查看CPU

  1. 查看內存
  2. 查看磁盤
  3. 查看IP
  4. 退出"

read -p "請選擇菜單: " item
if [ ${item} -eq 1 ]; then
echo "CPU工作頻率如下:"
cat /proc/cpuinfo | grep MH
read -p "輸入回車繼續"
fi

if [ ${item} -eq 2 ]; then
echo "可用內存如下: "
free | grep +
read -p "輸入回車繼續"
fi

if [ ${item} -eq 3 ]; then

echo "磁盤數據如下: "
df -h | grep boot
read -p "輸入回車繼續"
fi

if [ ${item} -eq 4 ]; then
echo "IP信息如下: "
ifconfig | grep "Bcast"
read -p "輸入回車繼續"

fi
if [ ${item} -eq 5 ]; then
exit 0
fi
done

用shell寫的基本監控菜單