检测网络脚本

 
#!/bin/bash
if [ -z "$1" ]
then
  echo "No hostname given."
  exit 3
fi
hostname=$1
state=$(/usr/bin/ssh -i /var/lib/nagios3/.ssh/id_rsa root@$hostname "ping -c 1 8.8.8.8|grep loss|sed 's/\([0-9]*\)%.*/\1/g;s/.*, *//g'")
if [ $state -eq 100 ]
then
  echo "CRITICAL - Network is Unreachable. $state"
  exit 1
elif [ $state -eq 0 ]
then
  echo "OK - Network is OK."
  exit 0
else
  echo "UNKOWN - Network is UNKNOW."
  exit 3
fi
exit 3
~
~本文转自 luoguo 51CTO博客,原文链接:http://blog.51cto.com/luoguoling/964573


上一篇:推荐十大优化页面加载速度的方法


下一篇:依赖注入框架Autofac的简单使用