【shell脚本004】监控服务器存活状态

#!/bin/bash

status=`ping -c5 192.168.0.100 | grep 'packet' | awk -F '%' '{print $1}'|awk '{print $NF}'`

if [ $status==0 ]
then
    echo "server is alive"
    elif [ $status>=0 && $status<=50 ]
    then
        echo "server lose some packet"
else
    echo "server is shutdown"
fi

你可能感兴趣的:(【shell脚本004】监控服务器存活状态)