Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Nginx Log Analyzer

A simple and fast Bash script for interactive analysis of Nginx web server logs (access.log). The script automates text data parsing using standard Linux utilities (awk, grep, sort, uniq), making it an excellent lightweight tool for system administration and basic security auditing (such as detecting anomalous traffic).

πŸš€ Features

  • Top 5 IP Addresses: Allows you to quickly identify the most active addresses (useful for detecting potential brute-force attacks or scrapers).
  • Top 5 Routes: Shows the most popular GET requests on the server.
  • Top 5 Response States: Quick monitoring of server health (e.g., tracking spikes in 404 or 500 errors).
  • Top 5 User Agents: Analysis of clients, browsers, and bots accessing the resource.
  • Reliability: The script uses set -euo pipefail to protect against hidden errors, undefined variables, and pipeline failures.
  • Interactive Menu: A user-friendly CLI interface based on the select construct.

πŸ›  Requirements

The script uses only standard POSIX utilities that are already pre-installed in most Linux distributions:

  • bash
  • awk
  • grep
  • sort, uniq, head

πŸ“₯ Installation and Setup

  1. Clone the repository or download the script:
git clone https://github.com/your-username/nginx-log-analyzer.git
cd nginx-log-analyzer
  1. Make the file executable:
chmod +x analyzer.sh
  1. Run the script:
./analyzer.sh

πŸ’» Usage

Upon launch, the script will prompt you to choose a data source:

  1. Enter the path to your own Nginx log file.
  2. Use the default test file (nginx-access.log.txt) if it is located in the same directory.

After loading the file, an interactive menu will open:

Select 1 if you want to enter your own file and 2 if you want to test the program on a test log: 1
Enter the path: /var/log/nginx/access.log
1) Top 5 ip
2) Top 5 routes
3) Top 5 response states
4) Top 5 user agents
5) Exit
-----------------------------------------------------
Select the required functionality (1-5):

Enter the number of the desired function and press Enter to get the formatted result. To exit the program, select option 5.

About

Mini NGINX log analyzer. Displays the top 5 IP, routes, status codes, and browsers

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages