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.
ATTO R608 8-Port 6Gb/s SAS RAID Controller
$33.99
Dell UCSA-901 0101A6100-000-G SAS PCI-E Raid Controller Card
$37.50
LSI 9305-16i SATA SAS 12Gbs RAID Controller PCIe 3.0 x8 IT-Mode 4* 8643 SATA
$229.99
Dell PowerEdge R730 12Gb/s SAS Mini Mono RAID Controller 2GB Cache 07H4CN 7H4CN
$49.99
Inspur LSI 9300-8i Raid Card 12Gbps HBA HDD Controller High Profile IT MODE
$15.98
LSI MegaRAID 9361-8i 12Gb PCIe 8-Port SAS/SATA RAID 1Gb w/BBU/CacheVault/License
$39.95
ORICO Multi Bay RAID Hard Drive Enclosure USB 3.0/ Type-C For 2.5/3.5'' HDD SSDs
$87.99
Dell PowerEdge RAID Controller HBA330 12Gbs PCIe 3.0 SAS SATA J7TNV Low Profile
$29.00
4 Bay RAID External Hard Drive Enclosure for 2.5/3.5" SATA HDD/SSD
$79.99
G TECHNOLOGY G RAID 0G04228 2-Bay Thunderbolt 2 RAID Array W/Power Supply
$99.99