update with slapt-get
Install pgsql
Public domain
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
--- 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
}
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
listen_addresses = 'localhost,172.16.20.1'
host bandwidthdpgsqldb bandwidthdpgsqluser 172.16.20.1/32 md5
createuser -P bandwidthdpgsqluser
createdb bandwidthdpgsqldb
psql -c "ALTER DATABASE bandwidthdpgsqldb OWNER TO bandwidthdpgsqluser" bandwidthdpgsqldb
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
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"
psql bandwidthdpgsqldb bandwidthdpgsqluser < /usr/local/bandwidthd/etc/schema.postgresql
echo "/usr/local/bandwidthd/bandwidthd " >> /etc/rc.d/rc.local
cd
/usr/local/bandwidthd/bandwidthd
# 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
00 6 * * 3 /usr/local/bandwidthd/bd_pgsql_purge.sh | /usr/bin/psql --dbname=bandwidthdpgsqldb --username=root > /dev/null 2>&1
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
<?php
define("DFLT_WIDTH", 900);
define("DFLT_HEIGHT", 256);
define("DFLT_INTERVAL", INT_DAILY);
$db_connect_string = "user = bandwidthdpgsqluser dbname = bandwidthdpgsqldb";
?>
BY: Pejman Moghadam
TAG: epkg, bandwidthd, postgresql
DATE: 2011-04-21 15:43:57