Sorry, resend with correct mailaddress.

Also, short fix to my suggestion:
It should be

read pkts bytes rest < <( ... )
and then echo "${bytes}"

On 08.11.2009 21:30:07, Zoff wrote:
> *) have gprs bytes RX/TX counter

> #! /bin/sh
> 
> GPRS_DEVICE='ppp0'
> 
> data_line=`ifconfig $GPRS_DEVICE|grep 'RX bytes' 2> /dev/null`
> data_rx_txt=`echo "$data_line"|awk '{print $3 " " $4}'|tr -d '()'`
> data_rx_bytes=`echo "$data_line"|awk '{print $2}'|cut -d ':' -f 2`
> data_tx_txt=`echo "$data_line"|awk '{print $7 " " $8}'|tr -d '()'`
> data_tx_bytes=`echo "$data_line"|awk '{print $6}'|cut -d ':' -f 2`
> 
> echo "sent: ""$data_tx_txt"" ""rcvd: ""$data_rx_txt"
> # echo "$data_tx_bytes"" ""$data_rx_bytes"

Hello.

IIRC the counter in ifconfig can overflow. As such it would probably be
better to use an iptables rule as counter which should then be checked
at ifdown.
Something like

gprs-ifup.sh:

iptables -A INPUT -i $GPRS_DEVICE -m comment --comment "GPRS TRAFFIC COUNTER IN"
iptables -A OUTPUT -i $GPRS_DEVICE -m comment --comment "GPRS TRAFFIC COUNTER 
OUT"

gprs-ifdown.sh:

tmp="$( mktemp )"
trap 'rm -f ${tmp}' EXIT
iptables -vnxL > "${tmp}"

read pkts rest < <( grep "GPRS TRAFFIC COUNTER OUT" "${tmp}" )
echo "sent: ${pkts}"
read pkts rest < <( grep "GPRS TRAFFIC COUNTER IN" "${tmp}" )
echo "rcvd: ${pkts}"

rm -f "${tmp}"


Kind regards,
     Benjamin
-- 
Benjamin 'blindCoder' Schieder
Registered Linux User #289529: http://counter.li.org
finger blindco...@scavenger.homeip.net | gpg --import
-- 
http://www.rocklinux.org/ The Distribution Build Kit
#######

Bitte beachte, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert
wird.
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
http://piratenpartei.de/navigation/politik/ueberwachung/vorratsdatenspeicherung

#######
#######

Bitte beachte, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert
wird.
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
http://piratenpartei.de/navigation/politik/ueberwachung/vorratsdatenspeicherung

#######
#######

Bitte beachte, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert
wird.
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
http://piratenpartei.de/navigation/politik/ueberwachung/vorratsdatenspeicherung

#######
_______________________________________________
Shr-devel mailing list
Shr-devel@lists.shr-project.org
http://lists.shr-project.org/mailman/listinfo/shr-devel

Reply via email to