Code Monkey home page Code Monkey logo

traffic-control's Introduction

Typing SVG

This application can display the speed of internet traffic and calculate the transmitted data by IP addresses, as well as calculate all internet traffic.


Here is the description, we have two Ethernet adapters:

ens18 - this internal interface [ 10.200.0.0/16 ] ens19 - this external interface [ External IP ]

pmacct listen internal interface ens18

traffic_control.py should listen on ens19

In pmacct.sh file change $device=ens19 var to count global traffic.


apt-get install librrd-dev sqlite3 libsqlite3-dev libsqlite3-0 rrdtool python3.X-dev python3 python3-pip pmacct

pip3 install rrdtool

pip3 install flask-debugtoolbar

pip3 install flask

cd /opt/ ; git clone repository

Merge configuration file from catalog

cd /opt/traffic-control/ ; cp -Rp pmacct_config/etc/* to /etc/pmacct/

Change the device name and IP network addresses in file

/etc/pmacct/pmacctd-pnrg.conf

Run pmacctd daemon

pmacctd -i ens18 -f /etc/pmacct/pmacctd-pnrg.conf

pmacctd -i ens18 -f /etc/pmacct/pmacctd.conf ;

Create SQLite3 DB file:

cd /opt/traffic-control/ ; ./create_db.py

Example run PMACCT command from screen:

cd /opt/traffic-control/

screen -d -m -A -S PMACCT ./pmacct.sh

Example run TC command from screen:

cd /opt/traffic-control/

screen -d -m -A -S TRAFFIC ./traffic_controle.py 0.0.0.0 10000 ens19

alt text

Traffic Control in Docker.

1. Install pmacct on host system

apt install pmacct

Clone remote repositoy

cd /opt ; git clone repository

Merge configuration file from catalog

mv /etc/pmacct/ /etc/pmacct.orig

ln -s /opt/traffic-control/pmacct_config/etc /etc/pmacct

Change the device name and IP network addresses in file:

/etc/pmacct/pmacctd-pnrg.conf

Run pmacctd daemon

pmacctd -i ens18 -f /etc/pmacct/pmacctd-pnrg.conf

pmacctd -i ens18 -f /etc/pmacct/pmacctd.conf ;

Change device

vim ./pmacct.sh ... device='ens18' ...

Run pmacct_traffic_control

cd /opt/traffic-control/

/usr/bin/screen -d -m -A -S PMACCT ./pmacct.sh

2. Next build docker container

Create dir for build

mkdir /opt/build ;

cd /opt/build ;

Create Dockerfile

cat >> Dockerfile <<EOF

FROM debian:latest

RUN apt-get update && apt-get install -y python3 python3-pip git librrd-dev sqlite3 libsqlite3-dev libsqlite3-0 rrdtool pmacct

RUN pip3 install rrdtool flask-debugtoolbar flask

CMD ["python3", "/opt/traffic-control/traffic_count.py", "0.0.0.0", "10000", "ens18"]

EOF

Create container

docker build .

.......

.......

Step 4/4 : CMD ["python3", "/opt/traffic-control/traffic_count.py", "0.0.0.0", "10000", "ens18"] ---> Running in 41cc4fb92e0d

Removing intermediate container 41cc4fb92e0d

---> a4fffd00378a

Successfully built a4fffd00378a

Run container

docker run -it -p 10000:10000 -v /opt/traffic-control/:/opt/traffic-control/ a4fffd00378a

Commit container

docker commit 7634dab49b86 tc:latest

Start container

docker start 7634dab49b86

Open browser and check connection to port 10000

traffic-control's People

Contributors

evfoan avatar jefomin avatar

Forkers

jefomin

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.