shell脚本监控CPU、磁盘、内存、网络流量

#!/bin/bash
#show system information
PS3="Your choice is: "
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
        e

猜你喜欢

转载自blog.csdn.net/qq_37651894/article/details/126173435