Coder Social home page Coder Social logo

homework's Introduction

homework

Homework is a simple command line based monitoring engine.

It allows to listen a log file of w3c common logfile format and display basic traffic stats and alerts.

Displayed stats are the number of hits, of which errors (http status >= 400), the total bytes transfered and the sections the most served. Alerts are displayed if the average hit per second is superior to a given threshold for a given amout of time called window.

A message is also displayed when the average drops again under the threshold.

Most of the parameters are configurable through command line options.

It also comes with a log generator to help testing, further develompents and demos. It generates up to 100MB of log lines, truncates the file and goes again !

build

To build datadog homework you need

  • java 8+
  • maven 3+

To build it please use command:

mvn package

run

To run it please use command:

java -jar homework-jar-with-dependencies.jar

Commons options are:

  • -h to display help
  • -g to run as generator
  • -f to specify the file

examples

Start the generator and generate up to 20 lines per second

java -jar homework-jar-with-dependencies.jar -g -f /tmp/test.log -t 20

Start the monitor and display stats every 5s and alerts if the average hits per second exceeds 10 for 30 consecutive seconds

java -jar homework-jar-with-dependencies.jar -f /tmp/test.log -d 5 -w 30 -t 10

further improvements

First of all, the AlerterTest is cheap, ugly and not reliable as it will fail randomly. The ZDT.now() should be moved to a protected method and mocked in the test. Plus, reading System.err is crap, Alerter (as well as Display) should send messages that could be properly read and checked.

Parsing lines could be delegated to a parser component that would match different formats and dispatch different entries.

Sharing segments between workers the way it has been done may not be the best implementation. Maybe the tailer could dispatch entries on-the-go to workers that would have local collections of their own.

While generating on average 50k lines per seconds, with default parameters, 50% of the CPU is used in LogEntry.of(), 30% in Alerter.run() and 15% in LogSegment.get(), this should be taken into consideration when thinking about improvements.

On larger scale the parsing and the various computings would be done on different instances all communcating through a stream-processing software platform for example.

homework's People

Contributors

pierre-gautier 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.