Sehubungan perangkat ZTE F660 tidak dapat dipantau menggunakan SNMP seperti perangkat sebelumnya (ZTE-ZXV10W300), maka saya mencoba memataunya menggunakan bash script.
Hasilnya saya tampilkan menggunakan Cacti.
Berikut ini data Cacti yang saya gunakan :
Cacti Version : 0.8.8a
Cacti OS : unix (Linux version 2.6.18-164.el5)
SNMP Version : NET-SNMP version: 5.3.2.2
RRDTool Version : RRDTool 1.4.x
Urutan pembuatannya sbb :
1. Tempatkan script di bawah pada folder '<path_cacti>/scripts/wjspeed.sh'
Pastikan ownernya dan attribut file tsb dapat dieksekusi (chmod 555/755)
#!/bin/bash
#
export WJ_FILETMP=/tmp/wjspeed.tmp
export WJ_FILELOG=/tmp/wjspeed.log
export WJ_TARGET=192.168.1.1
export WJ_USER=root
export WJ_PASS=Zte521
export WJ_INTR=ppp0
echo -n "`date`" > $WJ_FILETMP
# Start the expect script
(expect -c "
set timeout 10
# Start the session with the input variable and the rest of the hostname
spawn telnet $WJ_TARGET
expect \"*ogin:\"
send \"$WJ_USER\r\"
expect \"*assword:\"
send \"$WJ_PASS\r\"
expect \"*#\"
send \"ifconfig $WJ_INTR | grep bytes\r\"
expect \"*#\"
send \"exit\r\"
#
# stop the expect script once the telnet session is closed
exit
") | grep RX | sed -e 's/^ //g' | sed -e 's/:/=/g' >> $WJ_FILETMP
if [ "`grep RX $WJ_FILETMP`" ]
then
head -1 $WJ_FILELOG >> $WJ_FILETMP
cat $WJ_FILETMP > $WJ_FILELOG
fi
#echo " RX bytes=0 (0 MiB) TX bytes=0 (0 MiB)" >> $WJ_FILETMP
if [ "`wc -l $WJ_FILELOG | cut -d' ' -f1`" = "2" ]
then
R2=`head -1 $WJ_FILELOG | cut -d'=' -f2 | awk '{print $1}'`
T2=`head -1 $WJ_FILELOG | cut -d'=' -f3 | awk '{print $1}'`
R1=`tail -1 $WJ_FILELOG | cut -d'=' -f2 | awk '{print $1}'`
T1=`tail -1 $WJ_FILELOG | cut -d'=' -f3 | awk '{print $1}'`
TBPS=`expr $T2 - $T1` ; TBPS=`expr $TBPS / 300`
RBPS=`expr $R2 - $R1` ; RBPS=`expr $RBPS / 300`
#After restart R2&T2 will be 0, R1&T1 will still using old counter
[ "$TBPS" -ge "1250000" ] && TBPS=0
[ "$RBPS" -ge "1250000" ] && RBPS=0
echo "tx:$TBPS rx:$RBPS"
else
echo "tx:0 rx:0"
fi
2. Buat 'Data Input Methods'
3. Buat 'Data Templates'
4. Buat 'Graph Templates'
5. Buat 'Graph Management'
Selamat Mencoba
No comments:
Post a Comment