#————————————————————脚本功能——————————————————————————————————# #1、查看CPU利用率与负载(top、vmstat、sar) #2、查看磁盘、Inode利用率与I/O负载(df、iostat、iotop、sar、dstat) #3、查看内存利用率(free、vmstat) #4、查看TCP连接状态(netstat、ss) #5、查看CPU与内存占用最高的5个进程(top、ps) #6、查看网络流量(ifconfig、iftop、iptraf) #————————————————————脚本功能——————————————————————————————————# #!/bin/bash # os_check() { if [ -e /etc/redhat-release ]; then REDHAT=`cat /etc/redhat-release |cut -d' ' -f1` else DEBIAN=`cat /etc/issue |cut -d' ' -f1` fi if [ "$REDHAT" == "CentOS" -o "$REDHAT" == "Red" ]; then P_M=yum elif [ "$DEBIAN" == "Ubuntu" -o "$DEBIAN" == "ubutnu" ]; then P_M=apt-get else Operating system does not support. exit 1 fi } if [ $LOGNAME != root ]; then echo "Please use the root account operation." exit 1 fi if ! which vmstat &>/dev/null; then echo "vmstat command not found, now the install." sleep 1 os_check $P_M install procps -y echo "-----------------------------------------------------------------------" fi if ! which iostat &>/dev/null; then echo "iostat command not found, now the install." sleep 1 os_check $P_M install sysstat -y echo "-----------------------------------------------------------------------" fi while true; do select input in cpu_load disk_load disk_use disk_inode mem_use tcp_status cpu_top5 mem_top5 traffic quit; do case $input in cpu_load) #CPU利用率与负载 echo "---------------------------------------" i=1 while [[ $i -le 3 ]]; do echo -e "