Slackware 13.37 - Collecting Bandwidthd data in PostgreSQL (with epkg) ====================================================================== Public domain ******************************************************************************** ### Prerequisites * PostgreSQL ******************************************************************************** ### PHP mkdir -p /usr/src/packages/alpine cd /usr/src/packages/alpine/ wget -c \ http://slackware.at/data/slackware-13.37/source/n/alpine/alpine-2.00.tar.bz2 \ http://slackware.at/data/slackware-13.37/source/n/alpine/alpine.SlackBuild \ http://slackware.at/data/slackware-13.37/source/n/alpine/alpine.config.h.diff.gz \ http://slackware.at/data/slackware-13.37/source/n/alpine/alpine.manpage.diff.gz \ http://slackware.at/data/slackware-13.37/source/n/alpine/alpine.tech-notes.txt.diff.gz \ http://slackware.at/data/slackware-13.37/source/n/alpine/doinst.sh.alpine \ http://slackware.at/data/slackware-13.37/source/n/alpine/pinepgp-0.18.0-makefile-sed-fix.diff.gz \ http://slackware.at/data/slackware-13.37/source/n/alpine/pinepgp-0.18.0.tar.gz \ http://slackware.at/data/slackware-13.37/source/n/alpine/pinepgp-0.18.0.tar.gz.sig \ http://slackware.at/data/slackware-13.37/source/n/alpine/pinepgp.pinegpgp.in.diff.gz \ http://slackware.at/data/slackware-13.37/source/n/alpine/slack-desc.alpine \ http://slackware.at/data/slackware-13.37/source/n/alpine/slack-desc.imapd chmod +x alpine.SlackBuild mkdir -p /usr/src/packages/php cd /usr/src/packages/php wget -c \ http://slackware.at/data/slackware-13.37/source/n/php/doinst.sh.gz \ http://slackware.at/data/slackware-13.37/source/n/php/fetch-php.sh \ http://slackware.at/data/slackware-13.37/source/n/php/mod_php.conf.example \ http://slackware.at/data/slackware-13.37/source/n/php/php-5.3.6.tar.xz \ http://slackware.at/data/slackware-13.37/source/n/php/php.SlackBuild \ http://slackware.at/data/slackware-13.37/source/n/php/php.ini-development.diff.gz \ http://slackware.at/data/slackware-13.37/source/n/php/php.session.save_path.diff.gz \ http://slackware.at/data/slackware-13.37/source/n/php/slack-desc chmod +x php.SlackBuild ******************************************************************************** ### /usr/src/packages/php/php.SlackBuild.patch --- php.SlackBuild.origin 2013-02-09 13:02:56.000000000 +0330 +++ php.SlackBuild 2013-02-09 13:03:38.000000000 +0330 @@ -214,6 +214,7 @@ --enable-static=no \ --with-gnu-ld \ --with-pic \ + --with-pgsql \ --build=$ARCH-slackware-linux } ******************************************************************************** ### Making new php package cd /usr/src/packages/php patch -p0 < php.SlackBuild.patch ./php.SlackBuild cd /usr/src/packages mv /tmp/php-5.3.6-i486-6.txz . removepkg php installpkg php-5.3.6-i486-6.txz ******************************************************************************** ### /var/lib/pgsql-data/postgresql.conf listen_addresses = 'localhost,172.16.20.1' ******************************************************************************** ### /var/lib/pgsql-data/pg_hba.conf host bandwidthdpgsqldb bandwidthdpgsqluser 172.16.20.1/32 md5 ******************************************************************************** ### PostgreSQL config createuser -P bandwidthdpgsqluser createdb bandwidthdpgsqldb psql -c "ALTER DATABASE bandwidthdpgsqldb OWNER TO bandwidthdpgsqluser" bandwidthdpgsqldb ******************************************************************************** ### Installation [original download links](http://downloads.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/bandwidthd-2.0.1.tgz) cd /usr/src wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/bandwidthd-2.0.1.tgz" su - install cd /usr/src tar xf bandwidthd-2.0.1.tgz cd bandwidthd-2.0.1 ./configure && make make install DESTDIR=/usr/local/encap/bandwidthd-2.0.1 /bin/cp phphtdocs/bd_pgsql_purge.sh /usr/local/encap/bandwidthd-2.0.1/usr/local/bandwidthd/ /bin/cp schema.postgresql /usr/local/encap/bandwidthd-2.0.1/usr/local/bandwidthd/etc /bin/cp /usr/local/encap/bandwidthd-2.0.1/usr/local/bandwidthd/etc/bandwidthd.conf{,.default} cd /usr/local/encap/ mkencap bandwidthd-2.0.1/ logout rm -rf /usr/src/bandwidthd-2.0.1 cd /usr/local/encap/ epkg bandwidthd-2.0.1 ******************************************************************************** ### /usr/local/bandwidthd/etc/bandwidthd.conf subnet 172.16.20.0/24 # Run "bandwidthd -l" for a list of devices dev "eth1" #skip_intervals 0 #graph_cutoff 1024 #promiscuous true #output_cdf false recover_cdf false #filter "ip" graph false #meta_refresh 150 #pgsql_connect_string "user = bandwidthdpgsqluser dbname = bandwidthdpgsqldb host = localhost " pgsql_connect_string "host=172.16.20.1 port=5432 user=bandwidthdpgsqluser password=123456 dbname=bandwidthdpgsqldb" sensor_id "sensor1.example.net" ******************************************************************************** ### Launch psql bandwidthdpgsqldb bandwidthdpgsqluser < /usr/local/bandwidthd/etc/schema.postgresql echo "/usr/local/bandwidthd/bandwidthd " >> /etc/rc.d/rc.local cd /usr/local/bandwidthd/bandwidthd ******************************************************************************** ### Debug # tail -f /var/log/messages /var/log/syslog # psql bandwidthdpgsqldb bandwidthdpgsqldb=# \dt List of relations Schema | Name | Type | Owner --------+-----------------+-------+--------------------- public | bd_rx_log | table | bandwidthdpgsqluser public | bd_rx_total_log | table | bandwidthdpgsqluser public | bd_tx_log | table | bandwidthdpgsqluser public | bd_tx_total_log | table | bandwidthdpgsqluser public | sensors | table | bandwidthdpgsqluser (5 rows) select * from bd_rx_log; select * from bd_rx_total_log; select * from bd_tx_log; select * from bd_tx_total_log; select * from sensors; bandwidthdpgsqldb=# \q ******************************************************************************** ### crontab -e 00 6 * * 3 /usr/local/bandwidthd/bd_pgsql_purge.sh | /usr/bin/psql --dbname=bandwidthdpgsqldb --username=root &> /dev/null ******************************************************************************** ### Web Interface cd /var/www/htdocs wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/bandwidthd-phphtdocs-0.1.tar.gz" tar xf bandwidthd-phphtdocs-0.1.tar.gz mv bandwidthd-phphtdocs-0.1 bandwidthd /bin/rm bandwidthd-phphtdocs-0.1.tar.gz ******************************************************************************** ### /var/www/htdocs/bandwidthd/config.php ******************************************************************************** _BY: Pejman Moghadam_ _TAG: epkg, bandwidthd, postgresql_ _DATE: 2013-02-09 14:28:58_