You are here: Home / Debian GNU/Linux / Web applications / Monitoring / Install Bandwidthd on Debian

Install Bandwidthd on Debian

by Pierre-Yves Landuré last modified Jan 30, 2014 08:40

Bandwidthd is a local area network traffic monitoring tool. This post help you to install it on Debian.

This howto is tested on :

  • Debian 6.0 Squeeze

This howto is tested with these versions of Bandwidthd :

  • 2.0.1

Warning

This software sniff the network. When used on some setups (plugged on a HP Switch), it can trigger a network crash.

Prerequisite

This howto need one of the following tools, according to the chosen HTTP server :

Parameters

Provide the domain name where will be available the software :

DOMAIN="bandwidthd.domain.lan"

Installation

Environment preparation

Install the needed software :

command apt-get install build-essential libpcap-dev libgd2-noxpm-dev libpng12-dev

Application installation

Fetch the latest sources using the sf-downloader script :

command mkdir --parent '/opt/bin'
command wget 'https://raw.github.com/biapy/howto.biapy.com/master/various/sf-downloader' \
--quiet --no-check-certificate --output-document='/opt/bin/sf-downloader'
command chmod +x '/opt/bin/sf-downloader'
SOURCE="$(/opt/bin/sf-downloader --tgz \
--download-template="bandwidthd/bandwidthd VERSION/bandwidthd-VERSION.tgz" \
"bandwidthd" "bandwidthd-VERSION-binary-windows.zip")"

Go to the software sources folder :

command pushd "${SOURCE}"

Compile the software :

./configure
command make

Install the software :

command make install

Delete the sources :

command popd
command rm -r "${SOURCE}"

Move folders to fit Linux Standard Base :

command mv "/usr/local/bandwidthd/etc/bandwidthd.conf" "/etc/bandwidthd.conf"
command mv "/usr/local/bandwidthd/bandwidthd" "/usr/local/bin/bandwidthd"
command chmod +x "/usr/local/bin/bandwidthd"
command ln -s "/etc/bandwidthd.conf" "/usr/local/bandwidthd/etc/bandwidthd.conf"
command mv "/usr/local/bandwidthd/htdocs" "/var/lib/bandwidthd"
command ln -s "/var/lib/bandwidthd" "/usr/local/bandwidthd/htdocs"

Create a init.d script for the daemon :

command cp "/etc/init.d/skeleton" "/etc/init.d/bandwidthd"
command sed -i \
-e 's|^NAME=.*|NAME="bandwidthd"|' \
    -e 's|^DESC=.*|DESC="Network grapher."|' \
-e 's|^DAEMON=.*|DAEMON="/usr/local/bin/bandwidthd"|' \
-e '/^DAEMON=/a\
DATA_DIR="/usr/local/bandwidthd"' \
-e 's|^DAEMON_ARGS=.*|DAEMON_ARGS=""|' \
-e 's|--start |--start --chdir="${DATA_DIR}" |' \
'/etc/init.d/bandwidthd'
command chmod +x '/etc/init.d/bandwidthd'

Launch the daemon :

/etc/init.d/bandwidthd start

Add the daemon to system startup :

command update-rc.d "bandwidthd" "defaults"

Setup the HTTP server virtual host :

if [ -x "/usr/bin/a2tools" ]; then
  command a2tools "${DOMAIN}" "/var/lib/bandwidthd"
fi
if [ -x "/usr/bin/lighty-tools" ]; then
  command lighty-tools add-vhost "${DOMAIN}" "/var/lib/bandwidthd"
fi

Backup

Backup the installation with Backup Manager (see Install and setup Backup Manager on Debian) :

command backup-manager-tools add "/var/lib/bandwidthd"

Thanks