March 2018
Beginner to intermediate
416 pages
9h 24m
English
In this example, we first find the top 10 IP addresses which made requests to our website based on their request count, as shown in previous example. Then, we further use the system command to run the GeoIP package to print the geographical information of requesting IP address. The GeoIP package is freely available in the debian repository and the EPEL repository for rpm-based operating systems:
$ awk '{ print $1}' apache_logs.txt | sort| uniq -c | sort -rn | head | awk '{ print $2 };{print "================="};system("geoiplookup " $2);{print "================="}'
Or:
$ awk '{freq[$1]++} END {for (x in freq) {print freq[x], x}}' apache_logs.txt | sort -rn | head | awk ...Read now
Unlock full access