From a016c0718375dc7abfc2e8e910079cbb3fffbde4 Mon Sep 17 00:00:00 2001 From: Shimi Bandiel Date: Wed, 18 Aug 2021 13:54:19 -0700 Subject: [PATCH 1/3] using only awk, supporting huge files --- requestToUsage/requestToUsage.sh | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) 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 From ac451cbd189005cca3041ae5f9747d3a356c015b Mon Sep 17 00:00:00 2001 From: tarunm Date: Mon, 14 Feb 2022 13:35:33 -0800 Subject: [PATCH 2/3] Calculate the total upload and download size for Artifactory 6.x version --- requestToUsage/requestToUsage6x.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 requestToUsage/requestToUsage6x.sh 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 From 174567e3ef362e9b24610a417104b7ade4b8dc0f Mon Sep 17 00:00:00 2001 From: Shimi Bandiel Date: Tue, 6 Sep 2022 12:08:38 -0700 Subject: [PATCH 3/3] update README --- requestToUsage/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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.