-
Senior Member
registered user
dsl volume overview
I wrote a script to give me an overview about my internet-volume-usage.
Code:
!/bin/bash
#
# Usage : $0 Jun
#
# (c) Stefan Wagner 2004 - feel free to use, update or delete
#
function usage ()
{
echo Usage : $0 MONTH
echo Example : $0 Jun
}
function msgexit ()
{
echo $1
exit $2
}
if [ $# -ne 1 ] ; then
usage
exit 2
fi
#
file=/var/log/pppstatus/pppstatus.ppp0.$1-2004.log
#
[ -f $file ] || msgexit "file not found: $file" 1
bytes=$(cat $file | grep 'RX Bytes:' | sed 's/.*RX Bytes: //g' | sed 's/RX Err.*//g')
# echo "by:" $bytes
equation=$(echo $bytes | tr ' ' '+' | sed 's/ *+/+/g;s/+$//g')
# echo "eq:" $equation
echo -n "sum="
zahl=$( echo "$equation" | bc)
echo $zahl | rev | sed 's/\([0-9]\{3\}\)/\1./g' | rev | sed 's/^\.//'
dependencies: cat, grep, sed, tr, echo, bc, rev
problems:
- My account isn't measured by calendarian months, but from 20.x to 19.x+1
- In year 2005, 06, 07 ... you have to update the script.
- It evaluates only the downstream, not upstream
- no errorhandling
- Information isn't valid, if account is used from several computers/ installations.
- For US-Numberformat you have to replace '.' in the last line by ','.
goals: Gives a rough overview about monthly traffic, is easy to adopted for comming years, easy in usage and formats it's output in good readable way (Summe=1.345.367.245).
How it works: The logfile is searched for the 'RX: ....' - pattern, everything around is stripped off.
The numbers are transformed to an equation, which is passed to bc, (the commandline calculator) and the result formatted for better human readability.
Feedback is welcome.
Similar Threads
-
By will103 in forum Hdd Install / Debian / Apt
Replies: 6
Last Post: 02-01-2005, 10:36 PM
-
By pulsar in forum The Lounge
Replies: 0
Last Post: 11-16-2004, 10:30 PM
-
By punk000 in forum General Support
Replies: 4
Last Post: 02-21-2003, 03:03 AM
-
By Van Zan in forum The Lounge
Replies: 5
Last Post: 02-04-2003, 05:06 AM
-
By senorian in forum The Lounge
Replies: 6
Last Post: 01-22-2003, 04:05 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

16GB KIT (2x8GB) DDR3 Gamer Desktop RAM PC3 MIXED BRANDS VIPER VENGEANCE FURY
$10.00

Netac DDR4 32GB 16GB DDR4 3200MHz UDIMM C16 Desktop Internal Memory RAM Kit
$99.99

MTC8C1084S1SC56BD1 Micron 16GB DDR5 1Rx8 PC5-5600B 5600Mhz SO-DIMM Memory
$149.99

A-Tech 8GB DDR3 1600 PC3-12800 Laptop SODIMM 204-Pin Memory RAM PC3L DDR3L 1x 8G
$21.68

MTC8C1084S1SC56BD1-NF Micron 16GB DDR5 1Rx8 PC5-5600B 5600Mhz SO-DIMM Memory
$149.99

Major Brand 16GB (2x8GB) PC3-12800U DDR3-1600MHz DDR3-12800 DESKTOP RAM NON-ECC
$29.99

Crucial Laptop Ram 32GB (2x16GB) RAM DDR4 3200MHz CT16G4SFRA32A
$119.99

Samsung 32GB DDR4-2666V-2Rx4-RB2-12 RAM M393A4K40CB2-CTD6Q
$169.00

Dell Optiplex 7040 MT, i7-6700 3.40GHz, 16GB DDR4 RAM, NO HDD/OS #95
$65.00

Crucial DDR3L 16GB 2 x 8GB 1600 MHz PC3L-12800 Laptop RAM Sodimm Memory 1.35V
$41.00