tx/rx accumulated monthly
August 14, 2010 —
BarryK
There is demand for this, and every now and again the topic comes up on the forum. I also have a monthly transfer limit, beyond which my rate is cut to dialup speed. Some other people have to pay for extra download.
So, I have implemented transmit and receive cumulative totals for the calendar month. These values are in MB and appear on mouse-over the network tray icon.
I have kept download and upload totals separate, as some people are only limited to a certain amount of download per month, unlimited upload.
Also, in my case, there is a lot of upload from my laptop to the router, which does not go out on the Internet -- this seems to be a peculiarity of the 'ath5k' kernel wireless driver.
The network_tray PET has been updated to version 2.4.2:
http://distro.ibiblio.org/pub/linux/distributions/quirky/pet_packages-quirky/network_tray-2.4.2.pet
And the source:
http://bkhome.org/sources/alphabetical/n/network_tray-2.4.2.tar.gz
However, network_tray does not work on its own. I have also edited /etc/rc.d/rc.sysinit and /etc/rc.d/rc.shutdown in Woof.
Comments
Monthly acc for dialupUsername: BarryK
Note that I have only tested this with SNS. It should work ok for any network that stays "up" until Puppy shutdown. Dialup is a problem, as it might be disconnected before shutdown. The log files are: /var/local/sns/rx_bytes_month /var/local/sns/tx_bytes_month If there is an active network at shutdown, /etc/rc.d/rc.shutdown will read /sys/class/net/$INTERFACE/statistics/rx_bytes (and tx_bytes) and add those values to rx_bytes_month and tx_bytes_month. At bootup, rx.sysinit will reset rx_bytes_month and tx_bytes_month to zero at the start of a month. So, what we need in 'pupdial' is perform the same operation as rc.shutdown does, just before disconnecting. The code can be conditional, test for existence of rx_bytes_month or tx_bytes_month, so will not perform the operation on older puppies. Rerwin is the guy who maintains pupdial, I'll contact him about this. In fact, any network code that has a disconnect feature can incorporate this code into it. Something like this: [code]if [ -f /var/local/sns/rx_bytes_month ];then if [ -d /sys/class/net/${ACTIVE_INTERFACE}/statistics ];then RX_BYTES="`cat /sys/class/net/${ACTIVE_INTERFACE}/statistics/rx_bytes`" TX_BYTES="`cat /sys/class/net/${ACTIVE_INTERFACE}/statistics/tx_bytes`" RX_BYTES_MONTH=`cat /var/local/sns/rx_bytes_month` RX_BYTES_MONTH=`expr $RX_BYTES_MONTH + $RX_BYTES` echo -n "$RX_BYTES_MONTH" > /var/local/sns/rx_bytes_month TX_BYTES_MONTH=`cat /var/local/sns/tx_bytes_month` TX_BYTES_MONTH=`expr $TX_BYTES_MONTH + $TX_BYTES` echo -n "$TX_BYTES_MONTH" > /var/local/sns/tx_bytes_month fi fi [/code]
network_tray
Username: 01micko
"Hi Barry This is fantastic! People have been asking for this in the Pwidgets (a special widget to measure upload/download) thread for a long time, especially for the pre-paid 3G modems which work well in Puppy thanks to rerwin. I'm sure zigbert will be most interested when he gets the time. I'm blowed if I know where he gets any time, he does so many different things. http://sigmundberglund.com (sorry for off topic link). Cheers
Monthly log backport
Username: BarryK
"Um, when I upload Woof, anyone can grab it and get rc.sysinit and rc.shutdown out of it and extract the relevant code and backport it to any older Puppy.
Network disconnect
Username: BarryK
"A qualifier to above posts. Any network code that disconnects the interface can have the code I posted, but it must also bring down the interface, so that the rx_bytes and tx_bytes get removed (and will start from zero if the network is brought up again in the same session). If the network is disconnected but interface left active, I think that the reading of rx_bytes and tx_bytes in rc.shutdown is sufficient.
mod please if possible
Username: scsijon
"Barry, is there the possability to have the package work with a shutdown/restart the network so that when you restart the computer it reads the last tx/rx and reloads the actual to be visable rather than resetting each time? Maybe with a date clearing setting, not just a reset on the "1st of xxxxx" so that those like us on sat have a clear idea on how were going. even something like the ff netuseage addin. regards scsijon
tx/rx acc
Username: BarryK
"tx/rx does accumulate over the month. Not fully implemented though -- currently should work properly with SNS. When I update PupDial, rerwin has implemented support also -- will be in Wary 070. Other tools should accumulate properly if their network interface stays up until shutdown/reboot.
Tags: woof