-
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

SK Hynix 1TB PC801 M.2 NVMe PCIe Gen4x4 2280 SSD
$100.00

Samsung 2.5" 870 EVO SSD SATA III 250GB 500GB 1TB Internet Solid State Drive Lot
$60.00

External SSD 1TB 2TB 4TB Portable Hard Drive USB 3.0 Type-C High Speed PC Mac
$19.99

Dell Latitude 14" Laptop Computer Intel i5 Up To 32GB RAM 1TB SSD Windows 11 Pro
$545.25

1TB Kingston DataTraveler Max DTMAX/1TB USB Type-C Flash Drive
$86.95

SAMSUNG T7 Portable SSD 1TB Indigo Blue USB 3.2 Gen2 External MU-PC1T0H/AM
$159.99

Crucial MX500 1TB 2.5" SATA III Internal SSD CT1000MX500SSD1
$99.99

Acer Predator Helios Neo 16S AI 16" i9 275HX 2S RTX 5070 Ti 32GB 1TB SSD Refurb
$1746.47

Dell Latitude 14" Laptop Computer Intel i7 Up To 32GB RAM 1TB SSD Windows 11 Pro
$330.73

Seagate Desktop 1TB/1000GB SATA 3.5" HDD Hard Drive
$29.99