Tuesday 1 March 2016

Smokeping Configuration in Ubuntu



Smokeping is a latency measurement tool. It sends test packets out to the net and measures the amount of time they need to travel from one place to the other and back. For every round of measurement smokeping sends several packets.


Prerequisite 

This installation will require web service to be installed, for me am going to use Apache,but also it will need mail service for sending the email am going to use sendmail, run the following command to install web and mail service
$ sudo apt-get update
$ sudo apt-get install apache2
$ sudo apt-get install sendmail
Install Smokeping

$ sudo -s
#
# apt-get install smokeping

For Ubuntu 14.04: you need to install a symlink to the apache2 config
# ln -s /etc/smokeping/apache2.conf /etc/apache2/conf-available/smokeping.conf
# a2enconf smokeping

Also, the CGI module needs to be enabled in Apache:
# a2enmod cgi

Finally, reload the Apache configuration:
# service apache2 reload

Then point your web browser at
http://X.X.X.X/smokeping/smokeping.cgi

where X.X.X.X is your server IP


Initial Configuration
# cd /etc/smokeping/config.d
# ls -l
Output:
total 40K
drwxr-xr-x 2 root root 4.0K Oct  1 13:12 .
drwxr-xr-x 3 root root 4.0K Oct  1 13:12 ..
-rw-r--r-- 1 root root  177 Jan 28  2014 Alerts
-rw-r--r-- 1 root root  237 Jan 28  2014 Database
-rw-r--r-- 1 root root  489 Jan 28  2014 General
-rw-r--r-- 1 root root  225 Jan 28  2014 pathnames
-rw-r--r-- 1 root root  876 Jan 28  2014 Presentation
-rw-r--r-- 1 root root   50 Jan 28  2014 Probes
-rw-r--r-- 1 root root  147 Jan 28  2014 Slaves
-rw-r--r-- 1 root root  380 Jan 28  2014 Targets

The files that you'll need to change, at a minimum, are:
-Alerts
-General
-Probes
-Targets


Now open the General file with your favoirite editor 
# vi General

Change the following lines;
owner    = NOC
contact  = sysadmin@localhost
mailhost = localhost
cgiurl   = http://localhost/smokeping.cgi
# specify this to get syslog logging
syslogfacility = local5

Save the file and exit. Now let's restart the Smokeping service to verify that no mistakes have been made before going any further:
# service smokeping restart


Now open the Alerts file 

# vi Alerts
 
Change the following lines:
to = root@localhost
from = smokeping-alert@localhost

Save the file and exit. Restart Smokeping:
# service smokeping reload

Note: When you do some changes there is not need of restarting smokeping, just reload it for it to see configuration.


  Configuring monitoring of devices
For device configuration, most of configuration is done on
/etc/smokeping/config.d/Targets file.


As an example am going to configure some few devices where am going to have two groups Local devices and Public Servers,
# vi /etc/smokeping/config.d/Targets

Add the following to creates two groups:

+ LocalDevices
menu = LocalDevices
title = Local Network Devices

+ InternetServers
menu = InternetServers
title = InternetServers


Then add devices on those two groups :
+ LocalDevices
menu = LocalDevices
title = Local Network Devices

++MyRouter
menu = Router
title = Router
host = 100.100.100.100

++DC
menu = DC
title = Domain Controller
host = 172.16.0.1

+ InternetServers
menu = InternetServers
title = InterentServers

++Google
menu = Google
title = Google
host = google.com

++Yahoo
menu = Yahoo
title = Yahoo
host = yahoo.com

++Facebook
menu = Facebook
title = Facebook
host = facebook.com
 

OK. Let's see if we can get Smokeping to stop and start with the changes we have made, so far. Save and exit from the Targets file. Now try doing:
# service smokeping reload

If you see error messages, then read them closely and try to correct the problem in the Targets file. In addition, Smokeping is now sending log message to the file /var/log/syslog. You can view what Smokeping is saying by typing:
# tail /var/log/syslog

If you want to see all smokeping related messages in the file /var/log/syslog you can do this:
# grep smokeping /var/log/syslog

If there are no errors you can view the results of your changes by going to:
http://X.X.X.X/smokeping/smokeping.cgi

where X.X.X.X is your server IP


That's It.