Slackware 12.2 - Collecting Bandwidthd data in PostgreSQL (with epkg) ========================================================= *update with slapt-get* *Install pgsql* Public domain ******************************************************************************** ### PHP mkdir -p /usr/src/packages/{php,alpine} cd /usr/src/packages/alpine/ wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/alpine-2.00.tar.bz2" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/alpine.SlackBuild" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/alpine.config.h.diff.gz" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/alpine.manpage.diff.gz" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/alpine.tech-notes.txt.diff.gz" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/doinst.sh.alpine" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/pinepgp-0.18.0-makefile-sed-fix.diff.gz" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/pinepgp-0.18.0.tar.gz" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/pinepgp-0.18.0.tar.gz.sig" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/pinepgp.pinegpgp.in.diff.gz" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/slack-desc.alpine" wget -c "http://www.slackware.at/data/slackware-12.2/source/n/alpine/slack-desc.imapd" chmod +x alpine.SlackBuild cd /usr/src/packages/php wget -c "http://www.slackware.at/data/slackware-12.2/patches/source/php/doinst.sh.gz" wget -c "http://www.slackware.at/data/slackware-12.2/patches/source/php/mod_php.conf.example" wget -c "http://www.slackware.at/data/slackware-12.2/patches/source/php/php-5.3.8.tar.bz2" wget -c "http://www.slackware.at/data/slackware-12.2/patches/source/php/php.SlackBuild" wget -c "http://www.slackware.at/data/slackware-12.2/patches/source/php/php.ini.diff.gz" wget -c "http://www.slackware.at/data/slackware-12.2/patches/source/php/php.recommended.ini.diff.gz" wget -c "http://www.slackware.at/data/slackware-12.2/patches/source/php/slack-desc" chmod +x php.SlackBuild ******************************************************************************** ### /usr/src/packages/php/php.SlackBuild.patch --- php.SlackBuild.origin 2010-09-15 17:50:30.000000000 +0430 +++ php.SlackBuild 2010-09-15 17:50:57.000000000 +0430 @@ -201,6 +201,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.8-i486-1_slack12.2.tgz . removepkg php installpkg php-5.3.8-i486-1_slack12.2.tgz ******************************************************************************** ### /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 cd /usr/src wget -c "http://downloads.sourceforge.net/project/bandwidthd/bandwidthd/bandwidthd%202.0.1/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 2>&1 ******************************************************************************** ### 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: 2011-04-21 15:43:57_