Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions requestToUsage/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#requestToUsage.sh
This script is used with the syntax:
```request.sh request.log```
```requestToUsage.sh request.log```
(replace request.log with the name of your request log file)

It outputs a file request.csv which you can open in excel.
The furthest right field is your overall usage in gigabytes over the period of the request log. You need to figure out the difference in the dates and turn it into a 30-day figure to get a monthly usage figure.

TODO: Automate date difference calculation to monthly statistic
The script output the total Downloads and Uploads size respectively.
25 changes: 2 additions & 23 deletions requestToUsage/requestToUsage.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
#!/bin/bash
FILE=$1
if [ ! -f $FILE ]; then
echo "Correct usage is: requestToUsage.sh request.log [optional prefix string]"
echo "Correct usage is: requestToUsage.sh request.log"
fi
PREFIX=$2

OUTPUT=${PREFIX:+${PREFIX}-}$(head -c 8 $FILE).csv

awk '!/0$/' $FILE > $OUTPUT
if sed --version
then sed "s/[|]/,/g" $OUTPUT -i
else
echo "Please ignore the above error message from sed, switching to gsed."
gsed "s/[|]/,/g" $OUTPUT -i
fi
echo "Successfully outputted to $OUTPUT"
if date --version
then echo 'date'
else
echo "Please ignore the above error message from date, switching to gdate."
echo 'gdate'
fi

echo "0,0,0,0,0,0,0,0,=SUM(I:I)/(1024^3),0,0" >> $OUTPUT
echo "Added calculation line."
echo "Open $OUTPUT in excel or a similar spreadsheet program"
awk 'BEGIN { FS = "|" } ; NR > 1 { downloadSum += $9; if ($8 != -1) {uploadSum +=$8} } END { print ("Download sum: " downloadSum ", Upload sum: " uploadSum " bytes.") }' $FILE
6 changes: 6 additions & 0 deletions requestToUsage/requestToUsage6x.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
FILE=$1
if [ ! -f $FILE ]; then
echo "Correct usage is: requestToUsage.sh request.log"
fi
awk 'BEGIN { FS = "|" } ; NR > 1 { if ($10 != -1) {totalSum += $10} } END { print ("Total sum: " totalSum " bytes.") }' $FILE