ネットワークがちょくちょく落ちてるので。 [不具合・問題・解決方法?とか]
#! /bin/bash
ETH1=`/sbin/ifconfig -s|grep eth0|cut -c-4`
if [ -z "$ETH1" ]; then
/usr/bin/logger "Interface eth0 has gone."
/etc/init.d/networking restart
/usr/bin/logger "Restarting network..."
ETH2=`/sbin/ifconfig -s|grep eth0|cut -c-4`
if [ $ETH2 != "eth0" ]; then
/usr/bin/logger "Failed to recover eth0."
elif [ $ETH2 = "eth0" ]; then
/usr/bin/logger "Recovered eth0!"
fi
elif [ $ETH1 = "eth0" ]; then
PING1=`/usr/bin/fping 192.168.1.1|grep alive`
if [ -n "$PING1" ]; then
/usr/bin/logger "eth0 is alive."
elif [ -z "$PING1" ]; then
/usr/bin/logger "eth0 is alive but unreachable to router."
/etc/init.d/networking restart
/usr/bin/logger "Restarting network..."
PING2=`/usr/bin/fping 192.168.1.1|grep alive`
if [ -n "$PING2" ]; then
/usr/bin/logger "Recovered network!"
elif [ -z "$PING2" ]; then
/usr/bin/logger "eth0 is alive but something wrong with network."
fi
fi
fi
exit 0
ま、てきとうにこんな感じのスクリプトで。
# echo >> "0-59/5 * * * * root cd / && run-parts /etc/cron.5minitesly"
# mkdir /etc/cron.5minitesly
して、/etc/cron.5minitesly にスクリプトを置いておく。
あと、chomod u+xも忘れずに。
これで5分以上ネットワークは落ちなくなったのですが、
サーバ自体がいつの間にか落ちていることも。。。
Zabbixサーバなのに。。