Skip to content

spirrello/python-nginx-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Example of using Python3 to parse an Nginx access log to view the top 10 source IP addresses

Requirements

  • Pre-req is to have an offline copy of the logs to parse. You can tailf /PATH/TO/YOURFILE > yourfile to obtain this.

  • Python3

Example usage

Prints out a sorted list with the top IP addresses and the number of occurrences.

python3 top-ip.py --log access.log

('192.168.22.235', 684)
('192.168.22.57', 115)
('10.159.139.26', 111)
('192.168.20.90', 106)
('192.168.18.55', 102)
('192.168.22.203', 92)
('192.168.23.91', 79)
('192.168.23.86', 70)
('192.168.22.164', 69)
('192.168.18.32', 57)

About

Find top x source IP addresses in Nginx access logs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages