#!/bin/bash
if [ -z "$1" ]
then
echo "No hostname given."
exit 3
fi
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
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
~
~本文转自 luoguo 51CTO博客,原文链接:http://blog.51cto.com/luoguoling/964573