I wrote a script to give me an overview about my internet-volume-usage.
dependencies: cat, grep, sed, tr, echo, bc, revCode:!/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/^\.//'
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.
Intel Core i9-13900KF 3.0 GHz 24-Core Processor (BX8071513900KF)
$325.00
AMD Ryzen 9 7900X3D Gaming Processor - 12 Core And 24 Threads - 5.60 GHz Max Boo
$349.99
Intel Core i7-4790K 4GHz FCLGA1150 Quad-Core Processor (BX80646I74790K)
$65.00
Intel - Core i7-14700K 14th Gen 20-Core 28-Thread - 4.3GHz (5.6GHz Turbo) Soc...
$381.99
AMD Ryzen 7 5700X3D 8-Core 16-Thread 4.1GHz Socket AM4 CPU Processor OEM Tray
$189.00
Intel - Core i9-14900K 14th Gen 24-Core 32-Thread - 4.4GHz (6.0GHz Turbo) Soc...
$548.99
Intel Core i7-3770 3.40GHz Quad Core Socket LGA1155 Desktop CPU SR0PK ***
$29.99
Intel Core i7-3770 3.40GHz SR0PK Processor
$30.00
** Intel i3 10100F CPU Processor - USED **
$47.99
Intel Core i7-13700KF 16-Core 3.4GHz Processor
$267.75