首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

bash shell 检察网络

2012-11-20 
bash shell 检查网络#!/bin/bash# Simple SHELL script for Linux and UNIX system monitoring with# ping

bash shell 检查网络

#!/bin/bash# Simple SHELL script for Linux and UNIX system monitoring with# ping command# -------------------------------------# Copyright (c) 2006 nixCraft project <http://www.cyberciti.biz/fb/># This script is licensed under GNU GPL version 2.0 or above# -------------------------------------# This script is part of nixCraft shell script collection (NSSC)# Visit http://bash.cyberciti.biz/ for more information.# -------------------------------------# Setup email ID below# See URL for more info:# http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html# -------------------------------------?# add ip / hostname separated by white spaceHOSTS="cyberciti.biz theos.in router"?# no ping requestCOUNT=1?# email report whenSUBJECT="Ping failed"EMAILID="me@mydomain.com"for myHost in $HOSTSdo  count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')  if [ $count -eq 0 ]; then    # 100% failed    echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID  fidone
http://bash.cyberciti.biz/monitoring/monitor-windows-linux-server-with-ping-script/

热点排行