Monitoring Network Latency With Smokeping in Ubuntu Jaunty (9.04)


I have tested this on an Ubuntu 9.04 system. I will use the hostname www.example.com for this system in this tutorial. We need a web server on the system to display the graphs. I will install Apache2 and use Apache's default vhost for hosting the graphs. If you use a different vhost, you might have to adjust its settings or copy the smokeping.cgi script from /usr/lib/cgi-bin/smokeping.cgi to the appropriate location.

I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

$ sudo su

1. Installing smokeping


To install Smokeping along with some other recommended packages, we simply run:

aptitude install smokeping curl libauthen-radius-perl libnet-ldap-perl libnet-dns-perl libio-socket-ssl-perl libnet-telnet-perl libsocket6-perl libio-socket-inet6-perl apache2


2. Configuring


SmokepingThe Smokeping configuration is in the file /etc/smokeping/config. This file just includes some other files from the /etc/smokeping/config.d directory so we have to modify these files. First we modify /etc/smokeping/config.d/General. In this file, you find some email settings and the URL of the Smokeping web interface. Change them like this:

$ gedit /etc/smokeping/config.d/General

*** General ***
@include /etc/smokeping/config.d/pathnames

# Please edit this to suit your installation
owner = Falko Timme
contact = me@example.com
cgiurl = http://www.example.com/cgi-bin/smokeping.cgi
mailhost = smtp.example.com
# specify this to get syslog logging
syslogfacility = local0
# each probe is now run in its own process
# disable this to revert to the old behaviour

# concurrentprobes = no


(Make sure that mailhost contains the primary MX for your email domain!)

Open /etc/smokeping/config.d/Alerts and set the correct to and from addresses for emails sent by Smokeping:

$ gedit /etc/smokeping/config.d/Alerts


*** Alerts ***

to = me@example.com

from = smokealert@example.com

[...]


Next open /etc/smokeping/config.d/Targets. In this file, you find the remark line. Modify it to your likings:

$ gedit /etc/smokeping/config.d/Targets


[...]

remark = Welcome to the SmokePing website of 'Example Company'

[...]


Basic Example

We will now do a basic configuration to measure the network latency to certain servers in various countries (e.g. Germany, UK, USA). In this example, I'm going to test the network connection to the servers www.heise.de (Germany), bbc.co.uk (UK), and web.mit.edu (USA). You should choose different servers to avoid a DOS!


Open /etc/smokeping/config.d/Targets again:

$ gedit /etc/smokeping/config.d/Targets

At the end of this file, you should see this:

[...]

+ Local

menu = Local
title = Local Network

++ LocalMachine

menu = Local Machine
title = This host

host = localhost

[...]


Add the following lines to the file:


[...]

+ World

+ Local

menu = Local
title = Local Network

++ LocalMachine

menu = Local Machine

title = This host

host = localhost

menu = World

title = World

++ Europe

menu = Europe
title =European Connectivity

+++ Germany

menu = Germany

title = German Connectivity

alerts = bigloss,someloss,startloss

++++ Heise

menu = Heise

title = Heise

host = www.heise.de

+++ UK

menu = United Kingdom

title = United Kingdom

++++ BBC

menu = BBC

title = BBC

host = bbc.co.uk

++ USA

menu = North America

title =North American Connectivity

+++ MIT
menu = MIT
title = Massachusetts Institute of Technology Webserver

host = web.mit.edu


Save your changes and restart Smokeping:

/etc/init.d/smokeping restart

Smokeping will now probe the servers by pinging them (by using /usr/bin/fping) - this is the default test.

Now open a web browser and go to http://www.example.com/cgi-bi/smokeping.cgi.

After a few minutes you should see the first graphs. This is how the latency of localhost looks (which is configured by default in /etc/smokeping/config.d/Targets unless you changed that):

In the menu on the left side we can now go to the countries/servers that we configured earlier and take a look at their graphs:

Advanced Example


Until now, we are only pinging servers, but it would be good if we could do some other tests as well (e.g. measure how fast a DNS server resolves a domain or measure HTTP latency). Therefore we open /etc/smokeping/config.d/Probes and add the following section.

$ gedit /etc/smokeping/config.d/Probes


[...]
+ DNS
binary = /usr/bin/dig
lookup = domain-to-lookup.com
pings = 5
step = 180

+ Curl
# probe-specific variables
binary = /usr/bin/curl
step = 60

# a default for this target-specific variable

urlformat = http://%host%/

As you see, we've now added tests for DNS (the lookup line should contain a domain/hostname that you'd like the name servers (that we still have to configure in Smokeping) to look up) and HTTP / FTP (using Curl).

Now at the end of /etc/smokeping/config.d/Targets, we can add the name servers /HTTP servers /FTP servers we'd like to monitor (you can enable/disable tests by uncommenting them/commenting them out):

[...]
+ services
menu = Service Latency
title = Service Latency (DNS, HTTP)

++ DNS
probe = DNS
menu = DNS Latency
title = DNS Latency

+++ dns1
host = ns1.example.com

+++ dns2
host = ns2.example.com

++ HTTP
probe = Curl
menu = HTTP Latency
title = HTTP Latency

+++ server1
menu = server1
title = HTTP Latency for server1
host = server1.example.com

+++ server2
menu = server2
title = HTTP Latency for server2
host = server2.example.com

#+++ server3
#menu = server3
#title = HTTP Latency for server3 (port 8080!)
#host = server3.example
#urlformat = http://%host%:8080/

#++ FTP
#probe = Curl
#menu = FTP Latency
#title = FTP Latency
#urlformat = ftp://%host%/

#+++ server1
#menu = server1
#title = FTP Latency for server1
#host = server1.example.com

#+++ server2
#menu = server2
#title = FTP Latency for server2
#host = server2.example.com


As you see, we are monitoring the name servers ns1.example.com and ns2.example.com using the DNS probe we've configured in /etc/smokeping/config.d/Probes. We are also measuring the HTTP latency of server1.example.com and server2.example.com by using the Curl probe. If you like, you can also measure FTP latency using the Curl probe, but make sure that you specify a new urlformat for the FTP section (the default, urlformat = http://%host%/, is configured in /etc/smokeping/config.d/Probes; for FTP it should be urlformat = ftp://%host%/).

Restart Smokeping after your changes:

/etc/init.d/smokeping restart

After a few minutes, you should see some data for your new tests in the Smokeping web interface (http://www.example.com/cgi-bin/smokeping.cgi): You can read up on the Smokeping configuration and further configuration examples

here: http://oss.oetiker.ch/smokeping/doc/smokeping_examples.en.html

Debbunging

If you think that Smokeping isn't working as expected, you can try to find the problem by running Smokeping in debug mode:

/etc/init.d/smokeping stop
smokeping --debug


Happy Tersing...!!

Sources : http://www.ubuntu.com
http://www.howtoforge.com/
http://oss.oetiker.ch/smokeping/index.en.html

No comments:

Post a Comment

Please Comment...!!