Smokeping: Difference between revisions

From QNAPedia
Jump to navigation Jump to search
(Created page with "= Installation guide for Smokeping on a QNAP NAS. = Please note that the following disciplines will be touched; <br> *Minimum Linux shell skills via SSH/Telnet session.<...")
 
 
Line 204: Line 204:


For more information about smokeping and the command-line switches of the script please go to [http://oss.oetiker.ch/smokeping/doc/index.en.html]
For more information about smokeping and the command-line switches of the script please go to [http://oss.oetiker.ch/smokeping/doc/index.en.html]
[[Category:Adding new optware services]]

Latest revision as of 18:04, 26 October 2015

Installation guide for Smokeping on a QNAP NAS.

Please note that the following disciplines will be touched;


  • Minimum Linux shell skills via SSH/Telnet session.
  • Compiling from source
  • Editing custom virtual hosts under Apache


What is Smokeping

Smokeping is a tool that will graph network latency.


Smokeping sample graph

Pre-requisites

The installation of smokeping requires quite a few pre-requisites as well does fping. 

Downloading and installing Optware

Please follow the Optware guide to have Optware installed on your NAS first.

Installing the Optware pre-requisites

Update your ipkg repository before installing

# ipkg update


Next install the files required to compile sources on your QNAP

# ipkg install optware-devel gawk perl

Downloading Smokeping

Go to http://oss.oetiker.ch/smokeping/pub/ and download the latest version of smokeping. Smokeping is also dependent on fping for it probing. We will need to compile a binary of fping as well. At the creation date of this Wiki page the latest versions are Smokeping 2.6.8 and Fping 2.4.b2


Download the files in a temporary area on your QNAP (eg. /share/Public/tmp) and uncompress the tarballs.

# cd /share/Public
# mkdir tmp
# cd tmp
# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.8.tar.gz
# tar zxvf smokeping-2.6.8.tar.gz

Repeat the same for fping;

# wget http://oss.oetiker.ch/smokeping/pub/fping-2.4b2_to4-ipv6.tar.gz
# tar zxvf fping-2.4b2_to4-ipv6.tar.gz

Building the Perl modules and Fping executable

Before Smokeping can be compiled it will require a few Perl pre-requisites. To install these pre-requisites run the following;

#  cd /share/Public/tmp/smokeping-2.6.8/setup
#  ./build-perl-modules.sh

Now we can start building smokeping;

# export LC_ALL=
# export PERL5LIB=/opt/lib/perl5/5.10.0
# export PATH = /opt/bin:/opt/sbin:$PATH
# cd ..
# ./configure --prefix=/opt
# make install

Before configuring smokeping we still need to configure and compile fping from source;

# cd /share/Public/tmp/ fping-2.4b2_to4-ipv6
# ./configure --prefix=/opt
# make install

Preparing Apache

Please make sure you have a virtual host configuration in place as described in this HOWTO forum.qnap.com/viewtopic.php


For security reasons the virtual host configuration will require that the script alias is not physically located below the document root of the Apache host. A typical folder structure looks something like this;

/
|-backups/
|-cgi-bin/
|-htdocs/
|-logs/
|-tmp/


  • Copy the smokeping.fcgi file from the /opt/local/smokeping/htdocs folder to your /cgi-bin folder of your virtual host
  • Copy the cropper folder from the /opt/local/smokeping/htdocs folder to your htdocs folder of your virtual host
  • Create a folder called imgcache in your htdocs folder of your virtual host


Make sure the folders all have the permssions set so the Apache user can write files in the imgcache folder. E.g.  

# chown -R httpdusr:administrators /share/MD0_DATA/vhosts/mydomain.com/htdocs

Edit the smokeping.fcgi file in your cgi-bin folder to have the following content;

#!/bin/sh
/opt/local/smokeping/bin/smokeping_cgi /opt/local/smokeping/etc/config


Setting the Apache Directives

The QNAP Apache configuration does not support CGI executables out of the box, to add support for CGI execution add the following directives to your customized.conf in the appropriate vhost section below your last </Directory> closing tag. Edit paths where necessary.

AddHandler cgi-script .fcgi .cgi .pl
Options +ExecCGI
ScriptAlias /cgi-bin/ /share/MD0_DATA/vhosts/yourdomain.com/cgi-bin/

<Directory /share/MD0_DATA/vhosts/yourdomain.com/cgi-bin>
Options +ExecCGI -Indexes
Order allow,deny
Allow from all
</Directory>

To reflect the changes made restart the Apache daemon;

# /etc/init.d/Qthttpd.sh restart

Configuring Smokeping

For smokeping to run properly a few directories need to be created; 

# mkdir -p /opt/local/smokeping/data
# mkdir -p /opt/local/smokeping/logs
# mkdir -p /opt/local/smokeping/var


Then copy the distributed configuration example from etc folder;

# cp /opt/local/smokeping/etc/config.dist /opt/local/smokeping/etc/config

Comment out the syslog feature in the /opt/local/smokeping/etc/config file with a # sign;

#syslogfacility = local0

Edit the paths accordingly to your needs;

imgcache = /share/MD0_DATA/vhosts/yourdomain.com/htdocs/imgcache
imgurl = /imgcache
datadir = /opt/local/smokeping/data
piddir = /opt/local/smokeping/var
cgiurl = http://yourdomain.com/cgi-bin/smokeping.fcgi

Make sure the imgcache folder is writeable by the Apache user.

Point the FPing binary to its proper path;

+FPing

binary = /opt/sbin/fping


Sample probe menu;

menu = Top
title = Network Latency Grapher
remark = Welcome to the yourdomain.com SmokePing website.

+ provider
menu = PROVIDER
title = Provider targetted hosts for tracking quality of overall latency in their network

++ gateway
host = mysamplehost.com
++ smtp
host = smtp.mysamplehost.com
++ primarydns
host = ns1.mysamplehost.com
++ secondarydns
host = ns2.mysamplehost.com


Fixing the default template

The default template located in /opt/local/smokeping/etc will try to load the cropper javascript from a relative location (eg. /cgi-bin/). This needs to be changed to the Apache document root of the virtual host we are connecting to.

Edit the /opt/local/smokeping/etc/basepage.html.dist and alter the following lines;

<script src="cropper/lib/prototype.js" type="text/javascript"></script>
<script src="cropper/lib/scriptaculous.js?load=builder,effects,dragdrop" type="text/javascript"></script>
<script src="cropper/cropper.js" type="text/javascript"></script>
<script src="cropper/smokeping-zoom.js" type="text/javascript"></script>

to

<script src="../cropper/lib/prototype.js" type="text/javascript"></script>
<script src="../cropper/lib/scriptaculous.js?load=builder,effects,dragdrop" type="text/javascript"></script>
<script src="../cropper/cropper.js" type="text/javascript"></script>
<script src="../cropper/smokeping-zoom.js" type="text/javascript"></script>

Testing your probes

To run the smokeping perl script properly you need to clear the LC_ALL variable to prevent conflicts. The final script that will launch the daemonized version of smokeping will have this declaration included in the script.

To manually do this to enable debugging and testing your scripts you can;

# export LC_ALL=
./opt/local/smokeping/smokeping --config=/opt/smokeping/etc/config --debug

Once everything runs to wish you can create a script that daemonizes the process;

# touch /opt/bin/smoked.sh
# chmod 755 /opt/bin/smoked.sh

smoked.sh should contain;

#!/bin/sh

export LC_ALL=
cd /opt/local/smokeping/bin
./smokeping --config=../etc/config --logfile=/opt/smokeping/logs/smoke.log

Troubleshooting

Q: There are no graphs yet, what is going on?
A: The tool updates in intervals of 5 minutes, please give it some time to populate it with data

Q: I have added a new host on the config file while the daemon was running, now it won't update the graph for the new host
A: Terminate the current smokeping process and start the script again

 

Additional reading

For more information about smokeping and the command-line switches of the script please go to [1]