Everything is a contribution

走过Java的点点滴滴,与大家共勉~
随笔 - 21, 文章 - 0, 评论 - 10, 引用 - 0
数据加载中……

实现简单ping检测的Shell

最近有这样一个需求,需要知道目标机器是否是live状态,通过脚本发送ping其实是一个最原始的办法,一般情况不推荐使用,以下是实现思路。

#!/bin/bash
# use the script to confirm the hosts are alive or not
VIDEO_1=192.168.99.3
VIDEO_2=192.168.99.4
VIDEO_3=192.168.99.5

for LOOP in $VIDEO_1 $VIDEO_2 $VIDEO_3
do
  if ! ping -c 3 $LOOP > /dev/null 2>&1; then
    echo "Warning:The host $LOOP seems down" >> error.log
  fi
done

if [ -f error.log ]; then
  mail -s "Warning:Host Down" xiajx@hotmail.com < error.log
  rm -f error.log
fi



posted on 2007-11-26 10:49 Kevin Xia 阅读(349) 评论(0)  编辑  收藏 所属分类: 开源技术


只有注册用户登录后才能发表评论。


网站导航: