How to measure Internet usage for current session only?

Booting, installing, newbie
Post Reply
Message
Author
Bushbuck
Posts: 179
Joined: Sat 26 Jan 2013, 01:33

How to measure Internet usage for current session only?

#1 Post by Bushbuck »

Does anyone know which file these figures are stored in?

After I log out (from a fixed connection in Tahr64 6.0.5), and log back in again, I see a cumulative number.

It's useful for the per-month number to be cumulative, but I'd like the per-session to start from zero.
Xenial Puppy 64, Gigabyte motherboard, Intel i7 4770.

User avatar
OscarTalks
Posts: 2196
Joined: Mon 06 Feb 2012, 00:58
Location: London, England

#2 Post by OscarTalks »

Try looking in /var/local/sns
Oscar in England
Image

Bushbuck
Posts: 179
Joined: Sat 26 Jan 2013, 01:33

#3 Post by Bushbuck »

Thanks, OscarTalks.

I edited those, but it didn't update the UI. Maybe it's cached somewhere. Do you know what the display program in the status bar is called?
Xenial Puppy 64, Gigabyte motherboard, Intel i7 4770.

User avatar
OscarTalks
Posts: 2196
Joined: Mon 06 Feb 2012, 00:58
Location: London, England

#4 Post by OscarTalks »

The applet is called netmon_wce in recent Woof CE Puppies
In earlier puppies it was called network_tray
You probably have to restart something or maybe even reboot to see the numbers change if you edit the files. Someone else may know if the data is stored in some other location.
Oscar in England
Image

User avatar
drunkjedi
Posts: 882
Joined: Mon 25 May 2015, 02:50

#5 Post by drunkjedi »

Maybe you could try vnstat command.
A year ago when I was on tight data limit, I used it in Fatdog to monitor my data usage.
It's a small command, in Fatdog I think it's already present, in your puppy I don't know, run vnstat in terminal to see if it is.
If not, install it from PPM.
After installing, run this command to see what interfaces are available.

Code: Select all

vnstat --iflist
on my computer it returns this;
Available interfaces: eth0 eth1 lo

Since I use eth0; in order to setup the database, I used this command:

Code: Select all

 vnstat -u -i eth0
After vnstat has been running for awhile then it will be able to show your data count.

Query the network traffic:

Code: Select all

vnstat -q
Viewing live network traffic usage:

Code: Select all

vnstat -l
To find more options, use:

Code: Select all

vnstat --help

Bushbuck
Posts: 179
Joined: Sat 26 Jan 2013, 01:33

#6 Post by Bushbuck »

Ah, I wondered what netmon_wce was, OscarTalks.

I will try vnstat, drunkjedi.

Thanks.
Xenial Puppy 64, Gigabyte motherboard, Intel i7 4770.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#7 Post by Mike Walsh »

@Bushbuck:-

If you want a GUI solution for keeping tabs on your internet usage (for whatever reason), have a look here:-

http://www.murga-linux.com/puppy/viewtopic.php?t=99025

BitMeterOS gives you a GUI which is accessible via a tab in your browser.....which is what runs up most of your data usage in the normal course of things.

You get a running total by the month, and a daily usage readout, too.


Image


Mike. :wink:

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#8 Post by jafadmin »

Here is a script that will collect the numbers for your current boot session:

Code: Select all

#!/bin/bash
# 	A script to get session network bytes from the
#	  linked NIC
#
MyName=$(echo $0 | rev | cut -d '/' -f1 | rev)

## Turn up the nics
NICList=$(ifconfig -a | grep -i ethernet | cut -b 1-6 | tr -d ' ')

for NicDEV in $NICList; do
	ifconfig $NicDEV up 2>&1
done
sleep 5  # allow nics to settle

# get the "linked" nic
NICINFO=$(ifconfig -a | grep -B2 -i "broadcast running" )
NIC=$(echo $NICINFO | grep -i "ethernet" | cut -d ' ' -f1)

RXBytes=$(cat /sys/class/net/$NIC/statistics/rx_bytes)
RXPackets=$(cat /sys/class/net/$NIC/statistics/rx_packets)
TXBytes=$(cat /sys/class/net/$NIC/statistics/tx_bytes)
TXPackets=$(cat /sys/class/net/$NIC/statistics/tx_packets)

TotalBytes=$(( RXBytes + TXBytes ))
TotalPackets=$(( RXPackets + TXPackets ))

# Display the results ..
echo
echo "    RX bytes = "$RXBytes
echo "    TX bytes = "$TXBytes
echo "    Total bytes = "$TotalBytes
echo
echo "    RX packets = "$RXPackets
echo "    TX packets = "$TXPackets
echo "    Total packets = "$TotalPackets
echo
# Done
This just collects the info. Incorporate the techniques into whatever kind of app you want to create ..

Bushbuck
Posts: 179
Joined: Sat 26 Jan 2013, 01:33

#9 Post by Bushbuck »

Interesting stuff from jafadmin and Mike. I will try them.

I've just got a wired broadband connection (replacing a 3G dongle). I ought to be able to use Xenial Puppy now ( ...or the latest Slacko - decisions eh?)

The old dongle didn't work with either of them.
Xenial Puppy 64, Gigabyte motherboard, Intel i7 4770.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#10 Post by musher0 »

Hello, Bushbuck.

Doesn't your Internet Service Provider provide that kind of information? They should
since they are billing you for it!!! Mine has a page for "Internet consumption".

IHTH.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#11 Post by Mike Walsh »

Hi, Bushbuck.
Bushbuck wrote:Interesting stuff from jafadmin and Mike. I will try them.

I've just got a wired broadband connection (replacing a 3G dongle). I ought to be able to use Xenial Puppy now ( ...or the latest Slacko - decisions eh?)

The old dongle didn't work with either of them.
You should find BitMeterOS will work for you. It worked in just about every Puppy we tried it in.....and that was quite a few.

If you want a stable version, use the older 0.7.6; 0.8.0 is a bit buggy, since the author switched to a newer type of SQL database for that release.....and it didn't work out as well as he would have hoped.

Strangely enough, the .deb packages actually seem to work better than the .pet packages Geoffrey built for it; don't ask me why, I don't know. All I do know is that I've had 0.7.6 up-and-running in one or two of my Pups for over 2 years now (where I haven't re-installed them, that is).....and it's as stable as a rock.

----------------------------------------------------

Two dongles I've found work perfectly with pretty well all Pups are these:-

1 ) The TP-Link WN-725N

http://www.tp-link.com/uk/products/deta ... N725N.html

Uses the r8188eu module; if your Pup doesn't have it built-in, rcrsn51 has a whole bunch of driver .pets for it, here:-

http://www.murga-linux.com/puppy/viewtopic.php?t=107047

2 ) The NetGear WNA-3100M

https://www.netgear.com/support/product/WNA3100M.aspx

Uses the old faithful rtl8192cu driver, which seems to have been in the kernel forever. Again, if not built-in, or working correctly (older kernel variants were known for being a bit 'iffy', apparently), Bill's done a bunch of .pets for it, here:-

http://www.murga-linux.com/puppy/viewtopic.php?t=100675

Hope some of that helps. I can thoroughly recommend either of these, having used both for quite some time now. Neither of them will break the bank, being quite reasonably-priced. Dongles are like anything; you get what you pay for.....I wouldn't recommend some of the el cheapo jobs from the Far East for that very reason. Invariably, they'll only work with Windows, and using ndiswrapper doesn't always produce the results one would wish for!


Mike. :wink:

User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#12 Post by tallboy »

Mine has a page for "Internet consumption".
Mine too.
True freedom is a live Puppy on a multisession CD/DVD.

Bushbuck
Posts: 179
Joined: Sat 26 Jan 2013, 01:33

#13 Post by Bushbuck »

Just noticed that re-booting zeroed the byte counts for both the session and the month.

Thanks for the help.

The script gets the usage numbers for the etho connection. BitMeterOS installed, but didn't seem to do anything when I ran it.

The BT "usage" page says it is unlimited, but doesn't show any usage figures.
Xenial Puppy 64, Gigabyte motherboard, Intel i7 4770.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#14 Post by Mike Walsh »

@Bushbuck:-

Sometimes BitMeter's daemons don't start correctly.....especially the one for the web interface.

To fix this, run in the terminal

Code: Select all

/etc/init.d/bitmeter restart
..... followed by 'Enter', which restarts BitMeter itself, followed by

Code: Select all

/etc/init.d/bitmeterweb restart
.....(and 'Enter'), which will restart the web interface. Then refresh the tab you've got showing BitMeterOS; all things being equal, it should now show an updating running total. It updates once every 10 seconds or so.

Let me know if that helps, please. One way to check whether BitMeter's running is to open /var/lib/bitmeter with ROX; if the daemon is running, you should see the word '(Scanning)' appear briefly every few seconds in the window title-bar.


Mike. :wink:

Bushbuck
Posts: 179
Joined: Sat 26 Jan 2013, 01:33

#15 Post by Bushbuck »

That's interesting.

I'll have a play with that, tomorrow. Off to bed for me (UK) though.
Xenial Puppy 64, Gigabyte motherboard, Intel i7 4770.

Post Reply