traffic counter interface added

This commit is contained in:
lars 2005-05-18 17:53:05 +00:00
parent 76b5c49e54
commit ca0198b167
4 changed files with 33 additions and 11 deletions

View file

@ -1,3 +1,7 @@
Version 0.2.1
* traffic counter added
--- 18. May 02005 - Lars Kruse ---
Version 0.2
* counter for returned packets added
* enhanced installation and removal

View file

@ -1,6 +1,6 @@
Package: web-splash
Priority: optional
Version: 0.2
Version: 0.2.1
Architecture: mipsel
Maintainer: Lars Kruse <devel@sumpfralle.de>
Section: net

View file

@ -77,15 +77,14 @@ init_chains()
}
get_IPs()
# prints out all active forwards line by line
# every line consists of: "Number of Packets" and "IP"
get_IP_list()
# prints out all active forwarding IPs
{
iptables -t nat -L "$CHAIN_FORWARD_CHECK" -vnx | sed "1,2d; s/ */ /g" | cut -d " " -f 2,9
$IPT -t nat -L "$CHAIN_FORWARD_CHECK" -vnx | sed "1,2d; s/ */ /g" | cut -d " " -f 9
# get all active forward chains
# remove the first two lines
# remove multiple spaces
# take only the number of packets and the IP
# take only the IP
}
@ -103,12 +102,22 @@ unregister_IP()
}
refresh_IP_list()
update_IP_list()
# remove inactive IPs from the forwarding list
{
local NUM
local IP
get_IPs | while read NUM IP
do [ "$NUM" = "0" ] && unregister_IP "$IP"
get_IPs | while read IP
do [ `get_IP_traffic $IP` -gt 0 ] && unregister_IP "$IP"
done
}
get_IP_traffic()
{
local IP="$1"
local out_traffic="`$IPT -t nat -L \"$CHAIN_FORWARD_CHECK\" -vnx | sed '1,2d; s/ */ /g' | cut -d ' ' -f 3,9 | grep \" $IP$\" | cut -d ' ' -f 1`"
local in_traffic="`$IPT -L \"$CHAIN_RETURN\" -vnx | sed '1,2d; s/ */ /g' | cut -d ' ' -f 3,9 | grep \" $IP$\" | cut -d ' ' -f 1`"
if [ -n "$in_traffic" -a -n "$out_traffic" ]
then echo $((in_traffic+out_traffic))
else echo 0
fi
}

View file

@ -33,7 +33,16 @@ case "$ACTION" in
register_IP "$2"
;;
update )
refresh_IP_list
update_IP_list
;;
traffic )
if [ $# -eq 1 ]
then get_IP_list | while read IP
do echo "$IP `get_IP_traffic $IP`"
done
else IP="$2"
echo "$IP `get_IP_traffic $IP`"
fi
;;
* )
echo "Syntax: $0 {start|stop|restart}"