Chinaunix首页 | 论坛 | 博客
  • 博客访问: 282058
  • 博文数量: 37
  • 博客积分: 1296
  • 博客等级: 中尉
  • 技术积分: 481
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-24 17:00
文章分类

全部博文(37)

文章存档

2013年(1)

2011年(21)

2010年(4)

2009年(2)

2007年(9)

我的朋友

分类: Python/Ruby

2011-03-09 20:15:04

#!/bin/sh
# Email: minmig@gmail.com
# Last modified: 2010-08-12
# Filename: speed.sh
# Description: Get bandwidth
 
# Last modfied Minming Xu,on 2011-03-09
# Add other ip
# ============================
 
OID=.1.3.6.1.4.1.2021.8.102.101.1
TMPOUT=/tmp/output
OUTPUT=/home/pplive/web/output
OTHER=/home/pplive/tools/other
 
cp /dev/null $TMPOUT
 
# ip list
(wget -O /tmp/ip) >/dev/null 2>&1 || (echo "IP file donwnload error" ;exit 1)
 
# self check
if [[ `pgrep -f "speed.sh"|wc -l` > 2 ]]; then
echo "shell running"
exit 1
fi
echo $0
 
# snmp get
cat /tmp/ip | sort |uniq | while read IP;do
BITS=`/usr/bin/snmpget -v 2c -c public -Oqv -t 1 $IP $OID 2>&1 |sed 's/\"//g' 2>&1`
if [[ `echo "$BITS"|grep -v "|"` ]] ; then
BITS="0|0"
echo "$IP snmpget error"
fi
echo $IP"|"$BITS >> $TMPOUT
done
 
for i in `cat $OTHER`
do
OTHER_IP=`echo "$i"|awk -F "|" '{print $1} '`
sed -i "/$OTHER_IP/s/$OTHER_IP.*$/$i/" /tmp/output
done
 
cp $TMPOUT $OUTPUT

没什么大东西,里面有些常用的东西和想法。
如:禁止同时执行,特殊ip处理,取不到值处理。
阅读(1137) | 评论(0) | 转发(0) |
0

上一篇:PXE 安装 linux

下一篇:linux 网卡 bonding

给主人留下些什么吧!~~