jfrog / artifactory-scripts

Scripts for Artifactory (Usually, for REST API), community driven.
Apache License 2.0
150 stars 162 forks source link

Script requestToUsage.sh skips lines ending with zero, leading to wrong calculations #51

Open vizzard opened 3 years ago

vizzard commented 3 years ago

https://github.com/jfrog/artifactory-scripts/blob/732dc1cc047506137cb87981781845e58497e318/requestToUsage/requestToUsage.sh#L10

I assume the intention was to skip lines with zero transfer bytes when log format was keeping that data at the end of log line. Even then, this would remove valid lines if byte number will just end with 0 but would be greater than 0, like 1234567890.

Log format changed since then and now request.log entry has user agent at the end. That field may still end with 0. Examples: curl/7.29.0, Artifactory/7.12.6 71206900.

Easiest workaround is to replace awk command with: cat $FILE > $OUTPUT It will copy all the lines from request.log into CSV file without cutting anything and script remains functional.