traffic counter interface added
This commit is contained in:
parent
76b5c49e54
commit
ca0198b167
4 changed files with 33 additions and 11 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Version 0.2.1
|
||||||
|
* traffic counter added
|
||||||
|
--- 18. May 02005 - Lars Kruse ---
|
||||||
|
|
||||||
Version 0.2
|
Version 0.2
|
||||||
* counter for returned packets added
|
* counter for returned packets added
|
||||||
* enhanced installation and removal
|
* enhanced installation and removal
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Package: web-splash
|
Package: web-splash
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Version: 0.2
|
Version: 0.2.1
|
||||||
Architecture: mipsel
|
Architecture: mipsel
|
||||||
Maintainer: Lars Kruse <devel@sumpfralle.de>
|
Maintainer: Lars Kruse <devel@sumpfralle.de>
|
||||||
Section: net
|
Section: net
|
||||||
|
|
|
@ -77,15 +77,14 @@ init_chains()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
get_IPs()
|
get_IP_list()
|
||||||
# prints out all active forwards line by line
|
# prints out all active forwarding IPs
|
||||||
# every line consists of: "Number of Packets" and "IP"
|
|
||||||
{
|
{
|
||||||
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
|
# get all active forward chains
|
||||||
# remove the first two lines
|
# remove the first two lines
|
||||||
# remove multiple spaces
|
# 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
|
local IP
|
||||||
get_IPs | while read NUM IP
|
get_IPs | while read IP
|
||||||
do [ "$NUM" = "0" ] && unregister_IP "$IP"
|
do [ `get_IP_traffic $IP` -gt 0 ] && unregister_IP "$IP"
|
||||||
done
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -33,7 +33,16 @@ case "$ACTION" in
|
||||||
register_IP "$2"
|
register_IP "$2"
|
||||||
;;
|
;;
|
||||||
update )
|
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}"
|
echo "Syntax: $0 {start|stop|restart}"
|
||||||
|
|
Loading…
Reference in a new issue