Install bandwidthd-pgsql in Ubuntu

Source: Internet
Author: User
Tags psql
The front-end time leader asked bandwidthd to check network traffic and asked to store the data in the database. I searched the internet for half a day and found very little information about storing bandwidthd data in postgresql, I have studied it for half a day to understand that this article is installed using the deb package of Ubuntu, and I will also publish a self-compiled installation method. Environment Description: hostnameBK4, domainlocaldomain, account netuser and password abcd during installation

The front-end time leader asked bandwidthd to check network traffic and asked to store the data in the database. I searched the internet for half a day and found very little information about storing bandwidthd data in postgresql, I have studied it for half a day to understand that this article is installed using the deb package of Ubuntu, and I will also publish a self-compiled installation method.

Environment Description:

Hostname BK4, domain localdomain, account netuser during installation, password abcd.1234, IP address used instead;

Detailed steps

After the system is installed, use netuser to log on to the computer.

Sudo passwd root # Set the password for the root user

Set the password to abcd.1234

Su root # Switch to the root account

Apt-get install apache2 # install apache

Apt-get install php5 # install php language support

Apt-get install php5-pgsql # support for php connection to postgresql database

Apt-get install php5-gd # supports php to read images from the database

/Etc/init. d/apache2 restart # restart apache2

Cd/var/www # Enter The apache2 directory

Vi info. php # create the info. php file

Input # Input in the file

Wq # Save and exit

Access http: // ip/info. php # in the browser to check whether apache supports php.

Apt-get install postgresql # install the postgresql database

Su postgres # converts it to postgres account. This account is the postgresql database administrator, and the database service is started by this account by default.

Createuser netuser # Set netuser as the database administrator

The message "Shall the new role be allowed to create more new roles" is displayed? (Y/n) Select y

Createuser root # steps are the same as above

Exit # Return to root user

Exit # Return to netuser

Createdb mydb # Use netuser to create a database mydb

Psql mydb # Use the client tool psql to connect to the database mydb

# Display: mydb = #, indicating that the connection is successful and this account is the database administrator

Exit # exit the database

# Modify pg_cmd.conf to solve the authentication failure problem and enable the php program to connect to the database,

# Change according to the following content

Host all 127.0.0.1/32 trust

Local all trust

Host all: 1/128 trust

# Modify postgresql. conf to modify the listening range of the database.

Listen_addresses = '*'

Sudo apt-get install bandwidthd-pgsql # install bandwidthd that supports postgresql databases

# During the installation process, a window will prompt you to pay attention to the mode when installing the CRT. Otherwise, garbled characters will occur. Select the default Nic, default network segment, and no database configuration.

Sudo vi/etc/bandwidthd. conf # compile the bandwidthd configuration file

Edit the following content

Pgsql_connect_string "user = netuser dbname = mydb host = localhost"

Sensor_id "netuser. BK4.localdomain" # sensor name, which will be selected on the php webpage

Graph false # do not generate static webpages

Recover_cdf false

Promiscuous true # default value. If this parameter is set to false in the package, the hybrid mode of the NIC should be enabled.

Wq # Save and exit

Sudo/etc/init. d/bandwidthd restart # restart the bandwidthd Service

Cd/tmp # enter the Temporary Folder

Cd/bandwidthd-2.0.1 + cvs20090917 # enter the bandwidthd folder, which is generated when bandwidthd-pgsql is installed and can be obtained from the bandwidthd-2.0.1 + cvs20090917 package if not.

Sudo mv phphtdocs/var/www/monitor # Move the phphtdocs folder to/var/www/and change it to monitor. The php program in this folder is used to read data from the database, the folder name can be any

Cd/var/www/monitor # enter the monitor folder

Sudo rm index. php # Delete the Home Page. This page is not what we need

Sudo mv sensors. php index. php # rename the sensors. php folder to index. php. This page is the home page we need, or you can use the phphtdocs folder in the source code without the need for these two steps.

Sudo vi config. conf # modify the configuration file

Modify a row in pgsql_connect_string "user = netuser dbname = mydb,

Now, the installation and configuration are complete. You can visit this website to view the data collected by bandwidthd.

Http: // ip/monitor

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.