设定PING某一个IP,并且可以设定一个掉包的阀值,如果超过了阀值就给一份MTR出来。
如果支持多用户管理自己的IP就更好了,呃,好吧,好像有点像监控宝了~~~
如果支持多用户管理自己的IP就更好了,呃,好吧,好像有点像监控宝了~~~
|
msg7086Jun 12, 2014
1
错别字提醒:阈值
你这种需求,写个shell脚本扔进cron跑就行了。 |
|
ZhangJun 12, 2014
2
而且是念“yu(四声)”哦!
|
|
estJun 12, 2014
3
我想自己搞个这样的东西,无奈rawsocket需要root,不是很好用。mac下搞了半天setuid没成功。弱爆了。orz
|
|
5
#!/bin/bash
timeout="100" if [ -z "$1" ]; then echo 'Please specify the host' exit fi while true do out=`ping $1 -c 2|tail -1|awk '{print $4}' | cut -d '/' -f 2` if [ "$out" == "" ] || [ "$out" > "$timeout" ]; then echo 'ping test failed, starting mtr...' mtr --report --report-cycles 5 $1 > google_net_report.txt fi echo 'ping test passed' done |
|
a2zJun 12, 2014
6
那啥,注意不要让别人执行,因为参数都没过滤,可以导致命令执行
|
|
a2zJun 12, 2014
7
有个bug,mtr那行后面加个continue,另外似乎对比的是字符串而不是数字,也有点问题,但是大概就是这么一个意思
|
|
RainFlyingJun 12, 2014
9
关键是,按照你的思路,你开始 mtr 的时候可能网络就已经恢复了,
那 mtr 又有什么意义呢? |
|
10
@RainFlying mtr秒级就可以完成,设置阈值3,在很多时侯还是很有意义的。
|