Problem/Motivation
The bash one liner examples under "Logging of rate limited requests" is yet another example of the exemplary documentation of this amazing module: https://git.drupalcode.org/project/crawler_rate_limit#logging-of-rate-li...
You can pull out and compare any data points, or adjust the examples to get the desired data.
There does seem to be missing a space between the "Hour" and "Total" columns, for the "Print total" example for a given date (I have log-files by date, so this gets today's log):
Now:
# for i in $(seq -f "%02g" 0 23); do printf "%02d" ${i#0}; grep "/2026:$i:" /var/log/apache2/access.log | awk '{if ($9 == 429) {limited++} else {served++}} END { printf("%5d %5d %5d\n", NR, served, limited) }'; done
0015980 14795 1185
0115084 14441 643
0218369 16673 1696
[...]
Use " %5d %5d %5d\n" instead?
# for i in $(seq -f "%02g" 0 23); do printf "%02d" ${i#0}; grep "/2026:$i:" /var/log/apache2/access.log | awk '{if ($9 == 429) {limited++} else {served++}} END { printf(" %5d %5d %5d\n", NR, served, limited) }'; done
00 15980 14795 1185
01 15084 14441 643
02 18369 16673 1696
[...]Could this also be useful for the "each minute in a given hour" example?
Steps to reproduce
Proposed resolution
We could add a space before the Total number column?
Also, we could add this tip?
For dates stored in individual log-files, instead of
grep'ping for a date, you might usecat access.logfor today,cat access.log.1for yesterday, andzcat access.log.2.gzfor two days ago.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork crawler_rate_limit-3584920
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
ressaComment #6
vaish commentedThanks @ressa. I updated remaining one-liners that had the same issue and increased number of digits per column to accommodate larger numbers. Your tip about log files per date, I converted into set of additional examples in order to make the usage more clear.
Comment #8
ressaThanks @vaish, it looks great!
Comment #9
ressaI wanted to add a percent column, and ended up with this, after many experiments:
for i in $(seq -f "%02g" 0 59); do printf "%02d" ${i#0}; grep "/2026:11:$i:" /var/log/apache2/access.log | awk '{if ($9 == 429) {limited++} else {served++} ; limited != 0 ? percent = ((limited/NR)*100) : percent = 0} END { printf("%5d %5d %5d %5d%\n", NR, served, limited, percent) }'; done... so this is what I added:
; limited != 0 ? percent = ((limited/NR)*100) : percent = 0... and
%6d%... and
, percent. The result:It could get added to the last two extended examples like this:
Mentioning the option and show the bits below the two extended is another option, but maybe too cryptic for most users?
Comment #10
vaish commentedThis issue is already closed. Could you please open the new one? I may consider adding percent column to one of the examples. Btw, your code for calculation of percent should be moved to the END block. Currently, it's located in the block which is being executed for each line of the log file. Because of that percent is being unnecessarily recalculated on each iteration instead of once at the end.
Comment #11
ressaThanks for the feedback, that placement makes a lot of sense and fixed a strange behaviour as well, and I created a new issue.