Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Lab 1. Log Analyzer

This repository contains my first laboratory work for the Programming Fundamentals course in C++.

The lab was completed during my first semester of the Software Engineering program at ITMO University. The project represents my early practical experience with C++ and basic programming concepts.

Below is the original laboratory assignment statement translated into English.

Check out my other C++ labs:


🇬🇧 English | 🇷🇺 Русский

Task

Implement a utility that analyzes an access.log.

Based on this log, the utility must be able to:

  1. Output requests that ended with an error status code (5XX).

  2. Find the time interval during which the number of requests to the server was maximal.

Program Arguments

The utility must support the following command-line arguments/options:

Short argument Long argument Default value Description
-o path --output=path Path to the file where requests with errors will be written. If the file is not specified, analysis of error requests is not performed.
-p --print Duplicate the output of error requests to stdout (standard output stream / terminal).
-s n --stats=n 10 Output the n most frequent requests that ended with a 5XX status code, in descending order of frequency.
-w t --window=t 0 Find and output the time interval/window of length t seconds during which the number of requests was maximal. If t is equal to 0, the calculation is not performed.
-f --from=time The smallest time in the log Time in timestamp format, starting from which the data analysis is performed.
--to=time The largest time in the log Time in timestamp format, up to which the data analysis is performed, inclusive.

The filename and options are passed to the program as command-line arguments in the following format:

AnalyzeLog [OPTIONS] logs_filename

Log File Format

As an example log file, it is suggested to use the NASA server logs.

The logs are a text file where each line contains a server access event in the following format:

<remote_addr> - - [<local_time>] "<request>" <status> <bytes_send>
Value Description
remote_addr The address from which the request was sent.
local_time The time when the request was received.
request The request URL.
status The server response status code.
bytes_send The number of bytes sent in the response.

Examples of lines from the log file:

198.112.92.15 - - [03/Jul/2024:10:50:02 -0400] "GET /shuttle/countdown/HTTP/1.0" 200 3985
198.112.92.15 - - [03/Jul/2024:10:50:04 -0400] "GET /shuttle/nosuchpath/HTTP/1.0" 404 144

Examples of Running the Program

AnalyzeLog access.log --output=result.txt
AnalyzeLog access.log --output=result.txt --print --stats 5
AnalyzeLog --stats=2 --window=60 --from=805821284 --to=807117284 access.log
AnalyzeLog -s 2 access.log
AnalyzeLog -w 10 access.log
AnalyzeLog access.log -w 10

Recommendations

  • It is worth considering that the file size may be quite large and may significantly exceed the amount of available RAM. Therefore, memory consumption should not depend on the size of the file.

  • It is worth thinking about how the program can be divided into logical functions.

  • Do not forget about code style.

Additional Information

To implement the utility, you will need to use the standard input/output library. Usage example.

An example of how command-line argument parsing can be organized can be found here.

Restrictions

External libraries are forbidden. Only the standard C or C++ library may be used.

Deadlines

  1. 01.10.23 24:00 - 0.8
  2. 08.10.23 24:00 - 0.65
  3. 15.10.23 24:00 - 0.5

About

Log Analyzer written in C++ as one of my labs at ITMO University

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages