Archive for April, 2008

Smokeping on FreeBSD 7

Thursday, April 24th, 2008

This write-up assumes a working copy of FreeBSD 7.0.  It was built using 7.0-RELEASE.  It should work on FreeBSD 6.x-STABLE and future versions of FreeBSD 7.  The package versions listed were current as of this writing but may have been updated by the time someone uses this howto.

This is a basic setup of Smokeping.  There are many extra features that I do not touch on here such as multi-target graphs, alerting, slaves, agents and additional probe types.  Check the online documentation for further info.

Please let me know if you run into typos or other technical issues when implementing this.

1.) First let’s update the ports collection.

Setup the update:


# cd /usr/ports/ports-mgmt/portupgrade
# make install clean
# cd /usr/ports/net/cvsup
# make install clean
# cp /usr/share/examples/cvsup/ports-supfile /root/ports-supfile
# pico /root/ports-supfile

Make it look something like this:


#######################################################
*default host=cvsup1.us.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs  tag=.
*default delete use-rel-suffix
#comment the below line if you don't want to update the /src directory
#src-all
#update /usr/ports
ports-all tag=.
#######################################################

Run the update:


# cvsup -L 2 /root/ports-supfile
# portsdb -Uu

Update installed ports:


# portversion -l "<"
# portupgrade -arR
# pkgdb -F

2.) Install the necessary packages.

Descriptions of packages and uses here: http://oss.oetiker.ch/smokeping/doc/smokeping_install.en.html

  •          Perl 5.8:
  • Installed by default with FreeBSD install

  •          RRDTool 1.2.26:

  • # cd /usr/ports/databases/rrdtool
    # make install clean

     

  •          Fping 2.4b2_to-ipv6:

  • # cd /usr/ports/net/fping
    # make install clean

     

  •          EchoPing 6.0.0:

  • # cd /usr/ports/net/echoping
    # make install clean

  •          Dig:
  • Installed by default with FreeBSD install

  •         Perl modules:
  • Socket6

    # cpan
    # install Socket6

    Net:DNS

    # install Net::DNS
    # quit

  •          Apache 2.2.8:

  • # cd /usr/ports/www/apache22
    # make install clean

  •          SpeedyCGI 2.22_4:

  • # cd /usr/ports/www/p5-CGI-SpeedyCGI/
    # make install clean

  •          Smokeping 2.2.7_2:

  • # cd /usr/ports/net-mgmt/smokeping
    # make install clean

    3.) Configure the packages.

  •          Configure Apache:

  • # pico /usr/local/etc/apache22/httpd.conf

    Add:

    (within the <IfModule alias_module> section)


    <Directory "/usr/local/smokeping/htdocs">

    Add:

    (within the <IfModule dir_module> section)

    Add smokeping.cgi after index.html on the DirectoryIndex line to allow smokeping.cgi to load as a default document.

    It should look like:

    DirectoryIndex index.html smokeping.cgi

    Allow the startup of Apache:

    Add the following to /etc/rc.conf

    apache22_enable="YES"           # enable Apache 2.2

    Start Apache:

    # /usr/local/etc/rc.d/apache22 start

  •          Configure Smokeping:
  • Edit the variables in the following files appropriately

    # pico /usr/local/etc/smokeping/config

    Variable example settings in the first section:


    owner    = Systems Administrator
    contact  = sysadmin@domain.com
    mailhost = localhost
    sendmail = /usr/sbin/sendmail
    imgcache = /usr/local/smokeping/htdocs/img
    imgurl   = /smokeping/img
    datadir  = /usr/local/var/smokeping
    piddir  = /usr/local/var/smokeping
    cgiurl   = http://server.domain.com/smokeping/smokeping.cgi
    smokemail = /usr/local/etc/smokeping/smokemail
    tmail = /usr/local/etc/smokeping/tmail

    *** Alerts ***

    The “*** Targets ***” section is where you define your Smokeping targets and build the navigation menu.  It is a little too in depth to cover here.  Play around with it to figure out how it works.

    In depth configuration info is here: http://oss.oetiker.ch/smokeping/doc/smokeping_config.en.html

    There are some configuration samples here: http://oss.oetiker.ch/smokeping/doc/smokeping_examples.en.html

    Verify the path to Speedy:

    # pico /usr/local/smokeping/htdocs/smokeping.cgi

    -first line pointing to full path of speedy

    Customizations to the Smokeping web page templates can be made in the following config files:


    /usr/local/etc/smokeping/smokemail
    /usr/local/etc/smokeping/basepage.html
    /usr/local/etc/smokeping/tmail

    Set file system permissions to make the img folder and files writeable:

    # find /usr/local/smokeping/htdocs/img -type d -exec chmod 777 {} \;
    # find /usr/local/smokeping/htdocs/img -type f -exec chmod 666 {} \;

    Allow the startup of Smokeping:

    Add the following to /etc/rc.conf

  • smokeping_enable=”YES”          # enable smokeping
  • Start Smokeping:


    # /usr/local/etc/rc.d/smokeping start

    Operational Notes:

  •          You should now be able to browse to http://www.yourdomain.com/smokeping/ to view your Smokeping statistics.
  •          You may want to consider securing the Smokeping page with .htaccess users, a firewall or other form of authentication.
  •          I updated the index.html page in the root of the default Apache site:
  •  index.html at /usr/local/www/apache22/data/

    <meta http-equiv=”refresh” content=”0;url=http://www.someotherdomain.com”/>

    This redirects traffic sent to the root of your server to a different domain since this traffic obviously doesn’t need to be hitting the Smokeping server.

  •          When you add new targets or change targets in the /usr/local/etc/smokeping/config file you will need to restart Smokeping:
  • #/usr/local/etc/rc.d/smokeping restart