| Author: |
Admin |
| Dated: |
Thursday, 24 November 2005 @ 10:15 AM CET |
| Viewed: |
1 149 times |
|
Ce petit script permet de remonter la bande passante d'un pix en temps réél.
Le gros soucis est que cette valeur n'existe pas dans la MIB du firewall, il faut donc la calculer.
#!/bin/bash
# Calculate interface rate for Cisco PIX firewall
# copyleft Jerome Tytgat
# Community string of the firewall (certainly not "public")
# the server need to be authorized on the firewall !
commstring="public"
# Interface
# Outside = 1
# inside = 2
# dmz = 3
if [ "$1" == "" ]
then
ifnamenumber="1"
else
ifnamenumber="$1"
fi
# Ip address of the firewall
answer="1.1.1.1"
interface=`snmpget -v 1 -c $commstring $answer IF-MIB::ifDescr.$ifnamenumber | awk '{ print $6 }'`
typeset -i y=0
typeset -i x
typeset -i t
typeset -i u=0
typeset -i aa
typeset -i aaa
typeset -i dd
typeset -i ddd
dt=0
while [ 1 ]; do
xx=`snmpget -v 1 -c $commstring $answer IF-MIB::ifInOctets.$ifnamenumber IF-MIB::ifOutOctets.$ifnamenumber | awk '{ print $4 }'|xargs`
dtt=$(echo "$(date +"%s.%N")-$dt"|bc)
dt=$(date +"%s.%N")
x=${xx% *}
t=${xx#* }
if [ $y == 0 ];then
y=$(( x-x ))
else
y=$(echo "($x-$y)/$dtt"|bc)
fi
if [ $u == 0 ];then
u=$(( t-t ))
else
u=$(echo "($t-$u)/$dtt"|bc)
fi
aa=$(( y/1024 ))
dd=$(( u/1024 ))
aaa=$(( aa*8 ))
ddd=$(( dd*8 ))
echo "Interface $interface : in $aa KB/s, out $dd KB/s - in $aaa Kb/s, out $ddd Kb/s"
y=$x
u=$t
sleep 1
done
|
Trackback URL for this entry: http://www.sioban.net/trackback.php/20051124101522488
No trackback comments for this entry.
|