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.
Dell PowerEdge R640 Server | 2x Gold 6132 28 Cores | H730p | Choose RAM / DRIVES
$2630.00
DELL PowerEdge R730 Server 2x E5-2690v3 2.6GHz =24 Cores 32GB H730 4xRJ45
$274.00
Dell PowerEdge R720XD Xeon E5-2680 V2 2.8GHz 20 Cores 256GB RAM 12x4TB
$510.00
Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD
$389.99
Dell PowerEdge R730, 2 sinks, SystemBoard, 8 trays,H330,Idrac 8 exp, 2x750w Psu
$135.00
Dell Poweredge R730xd 2.5in 2x E5-2690 v3 2.6ghz 24-Cores 64gb H730 2x 750w
$189.99
Dell PowerEdge R720 Server - 2x8c CPU,256Gb RAM, 128Gb SSD/3x600Gb SAS, Proxmox
$340.00
DELL PowerEdge R730 16SFF Server 2x E5-2690v4 =28 Cores No RAM/ HDD H730 4xRJ45
$232.97
Dell R630 8 Port SFF Server 2x E5-2680v4 28C H730P 128GB 2x Trays RJ-45 ENT
$345.00
DELL PowerEdge R630 8SFF Server 2x E5-2690v4 2.6GHz =28 Cores 256GB H730 4xRJ45
$600.00