GithubHelp home page GithubHelp logo

thomastjdev / asus_graph_c3js Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 12 KB

Flask script for monitoring ASUS routers logs. Parse ASUS router network logs to HTML format and visualize the data with C3js.

License: MIT License

Python 78.75% HTML 21.25%

asus_graph_c3js's Introduction

Convert logs to C3js format

Formatting ASUS router logs to C3js format. The purpose is to visualize the logs online in charts. The base code is defined for ASUS RTN66u.

License

ThomasTJ - MIT

Requirements

  • MaxMind GeoIP (pip/yaourt)

  • GeoLiteCity.dat (see below for details)

  • RainbowLoggingHandler (pip/yaourt)

  • APScheduler (pip/yaourt)

  • Setup rsyslog. Description in the file "SETUP_rsyslog.md"

parse_asus_syslog_to_sqlite.py

This script takes the raw ASUS syslog and parses it to a sqlite3 database.

Go to your routers settings and activate syslog forwarding. Setup syslog on your pc (tested on pc and RPi v3).

Change the location in the file to the logfile or move the logfile to the folder logs. (There is a test-logfile in logs)

Run the script: python parse_asus_to_sqlite.py

This will create a database (db) in the folder data and create 2 tables. 1 for connections and 1 for DHCP information.

The logfile is parsed line by line and the lines date is checked against the latest date in the db. This solution is instead of tailing the logfile. Please go through the file and check if the suggested ports suits you. In the script, there's included some sample ports to ignore - e.g. 1194 is totally ignored.

The data is found by regex and inbound connections (from other IP's) are runned through geoip to get their locations. You'll need GeoIP (yaourt -S GeoIP) and MaxMinds GeoIP city database. Download the GeoIP database and place it here: /usr/local/share/GeoIP/GeoLiteCity.dat

For logging add 'import logging' and uncomment lines.

parse_asus_sqlite_to_C3js.py

This script parses the sqlite data to C3js format.

Please note that due to testing, some of date are returned in list format, so these needs to be formattet where you use them. At the moment the formatting is done in the app.py.

Configure your ports in the functions.

app.py

This is the script for running the flask webserver.

Using

Start the webserver: python app.py

Access the webserver: 0.0.0.0:5002/charts

Start the cron for checking logs: python parse_asus_syslog_to_sqlite.py

asus_graph_c3js's People

Contributors

thomastjdev avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.