#!/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处理,取不到值处理。
阅读(1212) | 评论(0) | 转发(0) |