Git Product home page Git Product logo

openvpn-stats's Introduction

OpenVPN-Stats

Python script to display traffic statistics for OpenVPN server.

This script uses web.py module. You can get it from here http://webpy.org/

After running openvpn_display_html.py it will create a webserver on port:8075 to display the statistics. You can change this port by modifying the last line of the script.

Here is how the statistics look:

------- Total --------
Common Name               Real Address         Download        Upload               Last Online
user1                     82.112.169.26       928.03 KB     715.20 KB  Mon Oct  3 11:49:48 2016
user2                     82.112.169.26       783.10 MB     142.89 MB  Tue Feb 14 13:05:21 2017
user3                     85.118.77.146         4.29 GB       2.93 GB  Tue Feb 14 13:04:05 2017
hjelev                    85.118.92.81         41.63 GB      10.30 GB  Wed Jan 25 15:23:01 2017
UNDEF                     85.118.81.119        55.95 KB      19.26 KB  Tue Feb 14 15:06:18 2017
user4                     46.47.84.49           8.06 GB     806.24 MB  Mon Feb 13 00:49:54 2017
------- Current --------
Common Name               Real Address         Download        Upload           Connected Since
hjelev                    85.118.92.81          1.61 MB      10.30 MB  Wed Jan 25 15:23:01 2017
user4                     46.47.84.49         221.06 MB     806.24 MB  Mon Feb 13 00:49:54 2017

How to run the script on system restart?

Add this to your crontab:

  #this will start the webserver displaing the statistics
  @reboot sudo /usr/bin/python /home/pi/scripts/ovpnstats/openvpn_display_html.py

  #this will fetch and agregate stats each minute
  */1 * * * * sudo /usr/bin/python /home/pi/scripts/ovpnstats/openvpn_stats.py /dev/null 2>&1

How to restart the statistics?

Just delete the content of your "db" folder, all files will be recreated once users connect to the vpn.

OpenVPN-Stats is based on https://sigterm.sh/2009/07/16/simple-openvpn-server-statistics/, it adds aggregation of the data and a convenient way to display it online.

openvpn-stats's People

Contributors

hjelev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.