martybugs.net SmoothwalL Express Info
 navigation
. MartyBugs home
. Smoothwall home
 
 Smoothwall info
. my box
. connect speed display
. red IP address display
. bytes in/out
. VNC over SSH
. time sync
. ad zapping
. ip accounting on 0.9.9 / 1.0
. ip accounting on 2.0
. status LEDs
. adding web users
. iptables config
. internal PPTP VPN
. RRDTool traffic graphs
. password reset
. proxy log analysis
. RRDTool memory graphs
. Squid config
. adding shell users
. Smoothwall links
 
 modem config
. Billion 7402L adsl router
. DSL-300G adsl modem
. DSL-300+ adsl modem
 
 site search
Custom Search
 
RRDTool Traffic Graphs

[This modification has been verified to work with Smoothwall Express 2.0 beta6, beta7.
 This mod will not work on GPL 1.0 or Express 2.0 versions prior to beta6.
 Versions from Smoothwall Express 2.0 RC1 onward include this as standard functionality.]


This page describes how to install RRDTool on Smoothwall, and use it to create traffic graphs for each interface.
The scripts described below will create daily, weekly, monthly and yearly graphs of the network traffic through each interface, viewable through the Smoothwall web interface.

Background:
Smoothwall Express 2.0 uses ipac-ng to generate the default traffic graphs, visible through the web interface.

However, RRDTool provides much more advanced graphing capabilities, and can also be used for monitoring and graphing other parameters.

For example, I use RRDTool on other linux boxes to monitor wireless link details, network traffic, system load, memory usage, motherboard, CPU temperature, PSU voltages (using lm_sensors), HDD temperature (using hddtemp), local weather, uptime of my ADSL connection, peak/offpeak quota and non-quota traffic from my ISP, etc.

Screen Shots:
Here's a screen shot of the summary page, showing daily graphs for the green and red interfaces.


the summary page, showing daily traffic graphs

Note that green trend is the incoming traffic, and the blue trend is outgoing traffic, shown as negative traffic. This allows both incoming and outgoing traffic to be easily shown on the same axis, and still be very readable.

Requirements:
You'll need:
  • A Smoothwall Express 2.0 installation (obviously...).
  • An SCP client (such as WinSCP, or SSH Secure File Transfer Client, part of SSH Secure Shell) for copying files onto your Smoothwall box.
  • A way of getting a command-line prompt on your Smoothwall box (either by logging directly onto your Smoothwall box, using a SSH client such as PuTTY or SSH Secure Shell, or via the Smoothwall web interface).
  • sw_rrdtool.tgz (266KB - contains RRDTool 1.0.45 binary, rrdtool.pl data collection script, rrdtool.cgi web page)
Installing the Components:
SCP the sw_rrdtool.tgz tarball into /tmp and untar it using

tar -zxvf /tmp/sw_rrdtool.tgz -C /

Create directories for storing the RRD files and resulting images:

mkdir /var/lib/rrd
mkdir /home/httpd/html/rrdtool

Test the script by manually running it from a command prompt:

/usr/local/bin/rrdtool.pl

and you should see output similar to this:

green (eth0) traffic in, out: 1231770748, 865270688
creating rrd database for green interface (eth0)...
595x165
595x165
595x165
595x165
red (eth1) traffic in, out: 848675567, 1233131148
creating rrd database for red interface (eth1)...
595x165
595x165
595x165
595x165

Automate the data collection and graph generation process by scheduling this script to run every five minutes, by adding the following to the end of /etc/crontab

# store rrdtool data and generate graphs
*/5 * * * * root /usr/local/bin/rrdtool.pl > /dev/null

Viewing the RRDTool Network Graphs:
Edit /var/smoothwall/header.pl and replace

&subsectiontab('/cgi-bin/graphs.cgi', $tr{'sstraffic graphs'}, 1);

with the following code

&subsectiontab('/cgi-bin/graphs.cgi', $tr{'sstraffic graphs'}, 0);
&subsectiontab('/cgi-bin/rrdtool.cgi', 'RRDTool graphs', 1);

To restrict viewing access to the the graphs, edit /home/httpd/cgi-bin/.htaccess and add the following to the end

<Files rrdtool.cgi>
require user admin
</Files>

Now point a web browser at Smoothwall's web interface, and navigate to the "about your smoothie" menu item, and then to the "RRDTool graphs" menu item to view the graphs.

The default view is of the daily graphs for each of the interfaces. Clicking one of these daily graphs will then display daily, weekly, monthly and yearly graphs for the selected interface.
Use the "back" button of your browser to revert back to the summary view.

Note that 5-minute average values are used for generating the daily graphs, 30-minute averages for the weekly graphs, 2-hour averages for the monthly graphs, and 12-hour averages for the yearly graphs.

Note:
Note that most of the Smoothwall fixes are likely to overwrite header.pl with a newer version, so if you install a new fix, it may overwrite your changes.
As a result, you'll probably need to reapply your changes to header.pl after installing any fixes.

Similarly, when doing a fresh installation of Smoothwall, only make these changes once you've fully patched the installation.

References:
Network Traffic Monitoring with RRDTool
About RRD Tool
RRD Tool Manual


last updated 27 Dec 2012
 
.