M
M
Max2019-04-11 04:02:04
linux
Max, 2019-04-11 04:02:04

How to display a table with accesses from logs to multiple sites by IP / Useragent?

Good day!
There are several dozen domains, I need to periodically check how many hits were made by certain user agents to the site content, in particular GoogleBot-Image / GoogleBot-News / YandexBot , as well as ResponseCode.
Now for a specific domain I do this:

cat domain.net.log | grep -i googlebot-image | awk '{print $9}' | sort | uniq -c | sort -nr
    377 200
     25 301

I can't figure out how to get a list of all log files from the /var/log/apache2/domains folder that match the conditions (modified date + file name).
I would like to get the corresponding output on the list of domain masks (for example, I do not set the full name of the domain, but a fragment, like *book*.com ) from a third-party file or directly entered, in this form:
domain_mask | count | response_code
domain1         | 50000| 200
domain1         | 100    | 404
domain2         | 300    | 200
domainN        | N        | n

PS Don't forget to leave your contacts, thank you :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stalker_RED, 2019-04-11
@Stalker_RED

Read about ELK, maybe this is what you are looking for.
Video reviews with examples:
https://www.youtube.com/watch?v=Kqs7UcCJquM
https://www.youtube.com/watch?v=4X0WLg05ASw
https://www.youtube.com/watch?v=Hqn5p67uev4

V
Vladimir Kuts, 2019-04-11
@fox_12

Well something like this:
If there are several domains, then first perform a search by the domain mask, display unique entries in a text file, and wrap the above script line in a loop through the domain.
Then instead of <domain> there will be just a variable from the cycle

while read domain; do
    find ./ -type f -name "${domain}*" -mtime <время последнего изменения файла (в днях)> -exec grep googlebot-image {} \; | awk '{print $9}' | sort | uniq -c | sort -nr | awk '{print "${domain}", $1, $2 }'
done <domains_list.txt

Z.Y. There is no console at hand to check

M
Max, 2019-04-11
@wtfowned

I found another output option, also without displaying the name of the log / domain file:
{ command1 ; command2 ; command3 } > output.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question