Share

The apache server logs the access requests in /var/log/apache2 so we can analyse this log file to find out the last few requests. The following parses the apache2 server logs, and print the requests line by line. It is based on the BASH commands: awk and tail. #!/bin/bash NUMBER_OF_REQUESTS=50 LOG_FILES_PREFIX=/var/log/apache2/access tail -n $NUMBER_OF_REQUESTS $LOG_FILES_PREFIX* | awk -F'”‘ ‘ # Ensure the IP address, request, and user agent fields are present $1 ~ /^+.+.+.+/ && $2 ~ /^(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH)/ && $6 != “” { split($1, part1, ” “) ip = part1 split($2, request, ” “) method = request path = request user_agent Continue Reading »

The post How to Get the Last Requests to Apache2 Server? first appeared on Algorithms, Blockchain and Cloud.

 

 The apache server logs the access requests in /var/log/apache2 so we can analyse this log file to find out the last few requests. The following parses the apache2 server logs, and print the requests line by line. It is based on the BASH commands: awk and tail. #!/bin/bash NUMBER_OF_REQUESTS=50 LOG_FILES_PREFIX=/var/log/apache2/access tail -n $NUMBER_OF_REQUESTS $LOG_FILES_PREFIX* | awk -F'”‘ ‘ # Ensure the IP address, request, and user agent fields are present $1 ~ /^+.+.+.+/ && $2 ~ /^(GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH)/ && $6 != “” { split($1, part1, ” “) ip = part1 split($2, request, ” “) method = request path = request user_agent Continue Reading »
The post How to Get the Last Requests to Apache2 Server? first appeared on Algorithms, Blockchain and Cloud.

Related posts:
Teaching Kids Programming – Split With Minimum Sum (Heap, Priority Queue) Teaching Kids Programming: Videos on Data Structures and Algorithms Given a positive integer num, split…
How to Kill a Process That Opens a TCP/UDP Port? Killing a process that opens a TCP port can be necessary in various situations, such…
The Major Security Flaws of Wirex (WirexApp) Exchange Beware of the Wirex Crypto Phishing Email Scam: I Lost 1000 GBP worth of USDT…
Webhosting Review: Disappointing Fasthosts Web hosting, you break my heart I don’t work for fasthosts and I don’t normally write bad reviews but I have…
Simple NodeJS Example to Show Average Scores in the Steemit-Wechat Group I have shown a simple NodeJS example that calls the SteemIt Wechat API to get…
Teaching Kids Programming – Number of Zero-Filled Subarrays (GroupBy Algorithm + Math Counting) Teaching Kids Programming: Videos on Data Structures and Algorithms Given an integer array nums, return…
Introducing the Pancake Sorting Algorithm Given an array of integers A, We need to sort the array performing a series…
How to Use the Dynamic Link Library in C++ Linux (gcc compiler)? The Dynamic Link Library (DLL) is stored separately from the target application and shared among… Read More Algorithms, Blockchain and Cloud 

By