Bandwidthd-pgsql is a free traffic statistics tool under Linux, which can be used to visualize the traffic usage of each IP in LAN.
0. Install Linux, this tutorial uses Ubuntu-budgie this release, after installation is updated.
sudo apt-get update
sudo apt-get upgrade
1. Installing Apache2
sudo apt-get install apache2 #安装完基本上不用改动
Test: The browser accesses the Http://Ubuntu IP and the IT works! page appears.
View Status: Service Apache2 Status/start/stop/restart
Web directory:/var/www/html
Installation directory:/etc/apache2/
Global configuration:/etc/apache2/apache2.conf
Listening Port:/etc/apache2/ports.conf
Virtual Host:/etc/apache2/sites-enabled/000-default.conf
2. Install PHP
sudo apt-get install php7.0 libapache2-mod-php7.0 #安装php and Apache modules
Sudo/etc/init.d/apache2 Restart #重启apache服务
Write a test php file info.php #放在 the/var/www/html directory
Hello PHP
<?php
Phpinfo ();
?>
Enter http://127.0.0.1/info.php in the browser to see the PHP information
3. Install PostgreSQL database, currently 9.5 version
sudo apt-get install PostgreSQL
sudo apt-get install php7.0-pgsql php7.0-gd #给php安装pgslq模块
4. Install the Phppgadmin #数据库的可视化管理器
sudo apt-get install Phppgadmin # You can open the Http://127.0.0.1/phppgadmin directly with your browser after the installation is complete, but the database is temporarily unable to log in
5. Modify the phppgadmin login file/etc/phppgadmin/config.inc.php
$conf [' extra_login_security '] = true; Change true to False
6. Modify the/etc/postgresql/9.5/main/pg_hba.conf file for the database
On the last line, add host all 0.0.0.0 0.0.0.0 MD5 #允许所有IP通过md5密码验证方式访问
7. Modify the/etc/postgresql/9.5/main/postgresql.conf file of the database to change the address to *
listen_addresses = ' * '
8. Restart the database to have the configuration file that you just modified take effect
/etc/init.d/postgresql restart
9. Configure the password for the Postgres administrator account for PostgreSQL so that the remote user can access it. Ps:postgresql data By default creates a Postgres database user as the administrator of the database, the password is random
First step: PostgreSQL login (Login with psql client)
# sudo-u Postgres psql//Where Sudo-u Postgres is using the Postgres user login meaning, enter into the database manager
Step Two: Modify the PostgreSQL login password:
postgres=# ALTER USER postgres with PASSWORD ' postgres '; postgres= #为PostgreSQL下的命令提示符
ALTER USER postgres PASSWORD ' Postgres '; or with this syntax.
Step three: Exit the PostgreSQL psql client
postgres=# \q
10. How to access the database:
Sudo-u postgres psql-p 5432//U is followed by a user name, after-P with the port after 5432 is the default port after
Sometimes, there are two instances of Postgres server on the same Ubuntu that can be queried with sudo service PostgreSQL status
11. You can then select Server in Http://127.0.0.1/phppgadmin, log in to the database with Postgres/postgres
12. Create BANDWIDTHD database and account first
Sudo-u Postgres psql-p 5432
CREATE USER Bandwidthdpgsql;
ALTER USER bandwidthdpgsql PASSWORD ' 123456 ';
Create Database Bandwidthdpgsql;
13. Installing the Bandwidthd-pgsql Software
sudo apt-get install bandwidthd-pgsql//installation will prompt monitoring of the network card, network segment, database address (choose localhost), password can be directly enter or input just set 123456, it is recommended to directly enter.
14. Modify the/etc/bandwidthd/bandwidthd.conf configuration file
The subnet can be set, if the wrong input is entered at the time of installation
Subnet 10.0.0.0 255.0.0.0
Subnet 192.168.0.0 255.255.0.0
Subnet 172.16.0.0 255.255.0.0
Can modify the database connection information, because the installation time has been set, generally do not change
pgsql_connect_string "user = bandwidthdpgsql Password = 123456 dbname = Bandwidthdpgsql host = localhost"
Network card operating mode changed to "Promiscuous mode"
Promiscuous true
#promiscuous false
/ETC/INIT.D/BANDWIDTHD Restart #重启bandwidthd服务
2-3 minutes after launch, you can see the data by looking at the database with the Pgadmin tool.
16. Make a soft Connect to BANDWIDTHD page address under/var/www/html
sudo ln-s/var/lib/bandwidthd/htdocs//VAR/WWW/HTML/BANDWIDTHD
17. Enter 127.0.0.1/bandwidthd/sensors.php in the browser to see the information
or the/var/lib/bandwidthd/htdocs/directory under the sensors.php renamed to Index.php, directly through the 127.0.0.1/bandwidthd/access.
The results of the traffic statistics are as follows:
Bandwidthd-pgsql Installation Guide