diff --git a/requestToUsage/README.md b/requestToUsage/README.md index fdf9400..885f09d 100644 --- a/requestToUsage/README.md +++ b/requestToUsage/README.md @@ -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. diff --git a/requestToUsage/requestToUsage.sh b/requestToUsage/requestToUsage.sh index 1282a55..e7b29fa 100755 --- a/requestToUsage/requestToUsage.sh +++ b/requestToUsage/requestToUsage.sh @@ -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 diff --git a/requestToUsage/requestToUsage6x.sh b/requestToUsage/requestToUsage6x.sh new file mode 100755 index 0000000..d96947e --- /dev/null +++ b/requestToUsage/requestToUsage6x.sh @@ -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 \ No newline at end of file