-
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
Intel Core i7-7800x CPU processor sr3nh 3.50ghz 6-Core 8.25mb lga-2066 X series
$37.29
Intel - Core i7-12700K Desktop Processor 12 (8P+4E) Cores up to 5.0 GHz Unloc...
$419.99
AMD Ryzen 9 5950X 16-core 32-thread Desktop Processor
$319.99
Intel - Core i9-12900K Desktop Processor 16 (8P+8E) Cores up to 5.2 GHz Unloc...
$619.99
Intel Core i7-6700 3.40 GHz QUAD Core (4 Core) Desktop Processor 8MB LGA 1151
$59.99
Intel Core i7-6700 SR2L2 4.00 GHz LGA 1151 Quad-Core Processor
$58.00
Intel Core i7-14700K Unlocked Desktop Processor
$409.99
Intel Xeon Gold 6126 2.6 GHz LGA 3647 Server CPU Processor SR3B3
$17.99
Intel i7-8700 Coffee Lake 3.2GHz 6-Core Max Turbo 4.6GHz Processor
$49.01
Intel Core i7-13700KF Processor (5.4 GHz, 16 Cores, LGA 1700) Box
$350.00