Coder Social home page Coder Social logo

logstats's Introduction

Logstats

Requirements

  • Python 3.7.3 (tested)

Instructions

Write a simple program to monitor a given HTTP access log file and provide alerting and monitoring.

The program will consume an actively written-to w3c-formatted HTTP access log. It should default to reading /var/log/access.log and be overridable. Display stats every 10s about the traffic during those 10s: the sections of the web site with the most hits, as well as interesting summary statistics on the traffic as a whole. A section is defined as being what's before the second / in the path. For example, the section for http://my.site.com/pages/create is http://my.site.com/pages. Make sure a user can keep the app running and monitor the log file continuously. Whenever total traffic for the past 2 minutes exceeds a certain number on average, add a message saying that: "High traffic generated an alert - hits = {value}, triggered at {time}". The default threshold should be 10 requests per second and should be overridable. Whenever the total traffic drops again below that value on average for the past 2 minutes, print or displays another message detailing when the alert recovered.

Help

python main.py -h
usage: main.py [-h] [--file FILE] [--interval INTERVAL] [--threshold THRESHOLD]

Analyse HTTP logs

optional arguments:
  -h, --help                            show this help message and exit
  --file FILE, -f FILE                  access log file
  --interval INTERVAL, -i INTERVAL      interval in seconds to display stats
  --threshold THRESHOLD, -t THRESHOLD   threshold for high traffic warning (nb of requests /second)

TODO

[] Add tests :) [] Regex for the log parsing [] Add a log generator to ease test and debug

logstats's People

Contributors

landier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.