In this CentOS 5.5 tutorial we will be installing Smokeping and SmokeTrace on a CentOS 5.5 i386 server. The assumption is that you have a basic to medium understanding of Apache but if you follow this tutorial you should be able to complete the task successfully.
A bit on the software that we’ll be using:
Smokeping
SmokePing keeps track of your network latency:
* Best of breed latency visualisation.
* Interactive graph explorer.
* Wide range of latency measurment plugins.
* Master/Slave System for distributed measurement.
* Highly configurable alerting system.
* Live Latency Charts with the most ‘interesting’ graphs.
* Free and OpenSource Software written in Perl written by Tobi Oetiker, the creator of MRTG and RRDtool
http://oss.oetiker.ch/smokeping/
Preliminary Note:
I am using a CentOS 5.5 i386 base installation in this tutorial.
* www.how2centos.com (IP 10.0.0.100): CentOS 5.5 i386 base installation
Lets begin by installing the framework required by Smokeping.
|
1 2 3 |
# yum install yum-priorities |
:epel-c5_32:
:rpmf-c5_32:
|
1 2 3 4 5 6 7 8 |
# yum install httpd # yum install rrdtool # yum install fping # yum install echoping # yum install curl # yum install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI |
|
1 2 3 4 5 6 |
# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.1.tar.gz # tar zxvf smokeping-2.4.1.tar.gz # mv smokeping-2.4.1 /opt/smokeping # cd /opt/smokeping |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# cd bin/ # cp smokeping.dist smokeping # cd ../htdocs/ # cp smokeping.cgi.dist smokeping.cgi # cp tr.cgi.dist tr.cgi # cd ../etc/ # cp config.dist config # cp basepage.html.dist basepage.html # cp smokemail.dist smokemail # cp tmail.dist tmail # cp smokeping_secrets.dist smokeping_secrets # chmod 600 /opt/smokeping/etc/smokeping_secrets |
|
1 2 3 |
# vi /opt/smokeping/bin/smokeping |
Replace this:
|
1 2 3 4 5 6 7 8 9 |
#!/usr/sepp/bin/perl-5.8.4 -w # -*-perl-*- use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl); use lib qw(lib); use Smokeping 2.004000; Smokeping::main("etc/config.dist"); |
With This:
|
1 2 3 4 5 6 7 8 9 |
#!/usr/bin/perl -w # -*-perl-*- use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs/); use lib qw(/opt/smokeping/lib); use Smokeping 2.004000; Smokeping::main("/opt/smokeping/etc/config"); |
or you can Patch the file:
|
1 2 3 4 |
# cd /opt/smokeping/bin # vi /opt/smokeping/bin/smokeping.patch |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
*** /opt/smokeping/bin/smokeping.dist 2008-06-10 15:08:07.000000000 +0200 --- /opt/smokeping/bin/smokeping 2010-08-04 16:43:08.000000000 +0200 *************** *** 1,12 **** ! #!/usr/sepp/bin/perl-5.8.4 -w # -*-perl-*- ! use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl); ! use lib qw(lib); use Smokeping 2.004000; ! ! Smokeping::main("etc/config.dist"); =head1 NAME --- 1,12 ---- ! #!/usr/bin/perl -w # -*-perl-*- ! use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs/); ! use lib qw(/opt/smokeping/lib); use Smokeping 2.004000; ! ! Smokeping::main("/opt/smokeping/etc/config"); =head1 NAME |
|
1 2 3 4 |
# patch -p1 -i smokeping.patch /opt/smokeping/bin/smokeping patching file /opt/smokeping/bin/smokeping |
|
1 2 3 |
# vi /opt/smokeping/htdocs/smokeping.cgi |
Replace this:
|
1 2 3 4 5 6 7 8 9 10 |
#!/usr/sepp/bin/speedy -w # -*-perl-*- use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl); use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib); use CGI::Carp qw(fatalsToBrowser); use Smokeping 2.004000; Smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config"); |
With this:
|
1 2 3 4 5 6 7 8 9 10 |
#!/usr/bin/speedy -w # -*-perl-*- use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs); use lib qw(/opt/smokeping/lib); use CGI::Carp qw(fatalsToBrowser); use Smokeping 2.004000; Smokeping::cgi("/opt/smokeping/etc/config"); |
or you can Patch the file:
|
1 2 3 4 |
# cd /opt/smokeping/htdocs/ # vi /opt/smokeping/htdocs/smokeping_cgi.patch |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
*************** *** 1,13 **** ! #!/usr/sepp/bin/speedy -w # -*-perl-*- ! use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl); ! use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib); use CGI::Carp qw(fatalsToBrowser); use Smokeping 2.004000; ! Smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config"); =head1 NAME --- 1,13 ---- ! #!/usr/bin/speedy -w # -*-perl-*- ! use lib qw(/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/RRDs); ! use lib qw(/opt/smokeping/lib); use CGI::Carp qw(fatalsToBrowser); use Smokeping 2.004000; ! Smokeping::cgi("/opt/smokeping/etc/config"); =head1 NAME |
|
1 2 3 4 |
# patch -p1 -i smokeping_cgi.patch /opt/smokeping/htdocs/smokeping.cgi patching file /opt/smokeping/htdocs/smokeping.cgi |
|
1 2 3 4 |
# cd /opt/smokeping/htdocs # vi /opt/smokeping/htdocs/tr.cgi |
Change this:
|
1 2 3 4 |
#!/usr/sepp/bin/speedy-5.8.8 -w use strict; use lib qw(/home/oposs/smokeping/software/lib); use lib qw(perl); |
To this:
|
1 2 3 4 |
#!/usr/bin/speedy -w use strict; use lib qw(/opt/smokeping/lib); use lib qw(perl); |
or you can Patch the file:
|
1 2 3 |
# vi /opt/smokeping/htdocs/tr_cgi.patch |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
*** /opt/smokeping/htdocs/tr.cgi.dist 2008-06-14 00:02:34.000000000 +0200 --- /opt/smokeping/htdocs/tr.cgi 2010-08-06 15:01:31.000000000 +0200 *************** *** 1,6 **** ! #!/usr/sepp/bin/speedy-5.8.8 -w use strict; ! use lib qw(/home/oposs/smokeping/software/lib); use lib qw(perl); use CGI; --- 1,6 ---- ! #!/usr/bin/speedy -w use strict; ! use lib qw(/opt/smokeping/lib); use lib qw(perl); use CGI; |
|
1 2 3 4 |
# patch -p1 -i tr_cgi.patch /opt/smokeping/htdocs/tr.cgi patching file /opt/smokeping/htdocs/tr.cgi |
|
1 2 3 4 |
# mkdir -p /var/www/html/smokeping/img /var/www/html/smokeping/script/ /opt/smokeping/data /opt/smokeping/var # chown -R apache:apache /var/www/html/smokeping/img |
|
1 2 3 4 5 6 7 |
# ln -s /opt/smokeping/htdocs/cropper /var/www/html/smokeping/cropper # ln -s /opt/smokeping/htdocs/resource /var/www/html/smokeping/resource # ln -s /opt/smokeping/htdocs/script/Tr.js /var/www/html/smokeping/script/Tr.js # ln -s /opt/smokeping/htdocs/smokeping.cgi /var/www/html/smokeping/smokeping.cgi # ln -s /opt/smokeping/htdocs/tr.cgi /var/www/html/smokeping/tr.cgi |
|
1 2 3 |
# chmod 4775 /bin/traceroute |
|
1 2 3 |
vi /etc/httpd/conf/httpd.conf |
change > #AddHandler cgi-script .cgi
to > AddHandler cgi-script .cgi
Under <Directory “/var/www/html”>
change > Options Indexes FollowSymLinks
to > Options Indexes FollowSymLinks ExecCGI
|
1 2 3 |
# vi /opt/smokeping/etc/basepage.html |
Change this:
|
1 2 3 4 |
<script src="cropper/lib/prototype.js" type="text/javascript"></script> <script src="cropper/lib/scriptaculous.js?load=builder,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 this:
|
1 2 3 4 |
<script src="/smokeping/cropper/lib/prototype.js" type="text/javascript"></script> <script src="/smokeping/cropper/lib/scriptaculous.js?load=builder,dragdrop" type="text/javascript"></script> <script src="/smokeping/cropper/cropper.js" type="text/javascript"></script> <script src="/smokeping/cropper/smokeping-zoom.js" type="text/javascript"></script> |
or you can Patch the file:
|
1 2 3 4 |
# cd /opt/smokeping/etc/ # vi /opt/smokeping/etc/basepage.patch |
|
1 2 3 4 5 6 7 8 9 10 |
56,59c56,59 < <script src="cropper/lib/prototype.js" type="text/javascript"></script> < <script src="cropper/lib/scriptaculous.js?load=builder,dragdrop" type="text/javascript"></script> < <script src="cropper/cropper.js" type="text/javascript"></script> < <script src="cropper/smokeping-zoom.js" type="text/javascript"></script> --- > <script src="/smokeping/cropper/lib/prototype.js" type="text/javascript"></script> > <script src="/smokeping/cropper/lib/scriptaculous.js?load=builder,dragdrop" type="text/javascript"></script> > <script src="/smokeping/cropper/cropper.js" type="text/javascript"></script> > <script src="/smokeping/cropper/smokeping-zoom.js" type="text/javascript"></script> |
|
1 2 3 4 |
# patch -p1 -i basepage.patch /opt/smokeping/etc/basepage.html patching file /opt/smokeping/etc/basepage.html |
|
1 2 3 |
# vi /opt/smokeping/htdocs/tr.html |
Change this:
|
1 2 3 4 5 6 7 |
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>SmokeTrace</title> <script type="text/javascript" src="script/Tr.js"></script> </head> </html> |
To this:
|
1 2 3 4 5 6 7 |
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>SmokeTrace</title> <script type="text/javascript" src="/script/Tr.js"></script> </head> </html> |
|
1 2 3 |
# ln -s /opt/smokeping/htdocs/tr.html /var/www/html/smokeping/tr.html |
Lets create a basic Config file for Smokeping to get started:
|
1 2 3 |
# vi /opt/smokeping/etc/config |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
*** General *** owner = Peter Random contact = some@address.nowhere mailhost = my.mail.host sendmail = /usr/sbin/sendmail # NOTE: do not put the Image Cache below cgi-bin # since all files under cgi-bin will be executed ... this is not # good for images. imgcache = /var/www/html/smokeping/img imgurl = http://www.how2centos.com/smokeping/img datadir = /opt/smokeping/data piddir = /opt/smokeping/var cgiurl = http://www.how2centos.com/smokeping/smokeping.cgi smokemail = /opt/smokeping/etc/smokemail tmail = /opt/smokeping/etc/tmail # 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 *** Alerts *** to = alertee@address.somewhere from = smokealert@company.xy +someloss type = loss # in percent pattern = >0%,*12*,>0%,*12*,>0% comment = loss 3 times in a row *** Database *** step = 300 pings = 20 # consfn mrhb steps total AVERAGE 0.5 1 1008 AVERAGE 0.5 12 4320 MIN 0.5 12 4320 MAX 0.5 12 4320 AVERAGE 0.5 144 720 MAX 0.5 144 720 MIN 0.5 144 720 *** Presentation *** template = /opt/smokeping/etc/basepage.html + charts menu = Charts title = The most interesting destinations ++ stddev sorter = StdDev(entries=>4) title = Top Standard Deviation menu = Std Deviation format = Standard Deviation %f ++ max sorter = Max(entries=>5) title = Top Max Roundtrip Time menu = by Max format = Max Roundtrip Time %f seconds ++ loss sorter = Loss(entries=>5) title = Top Packet Loss menu = Loss format = Packets Lost %f ++ median sorter = Median(entries=>5) title = Top Median Roundtrip Time menu = by Median format = Median RTT %f seconds + overview width = 600 height = 50 range = 10h + detail width = 600 height = 200 unison_tolerance = 2 "Last 3 Hours" 3h "Last 30 Hours" 30h "Last 10 Days" 10d "Last 400 Days" 400d #+ hierarchies #++ owner #title = Host Owner #++ location #title = Location *** Probes *** + FPing binary = /usr/sbin/fping *** Targets *** menuextra = <a target='_blank' href='/smokeping/tr.html{HOST}' class='{CLASS}' \ onclick="window.open(this.href,this.target, \ 'width=800,height=500,toolbar=no,location=no,status=no,scrollbars=no'); \ return false;">(TR)</a> probe = FPing menu = Top title = Network Latency Grapher remark = Welcome to the SmokePing website of xxx Company. \ Here you will learn all about the latency of our network. + hosts menu= Targets ++ How2CentOS menu = How2CentOS.com title = How2CentOS.com alerts = someloss host = www.how2centos.com ++ CentOS menu = CentOS.org title = CentOS.org alerts = someloss host = www.centos.org |
Lets create a service startup script for Smokeping
|
1 2 3 |
# vi /etc/init.d/smokeping |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
#!/bin/bash # # chkconfig: 2345 80 05 # Description: Smokeping init.d script # Hacked by : How2CentOS - http://www.how2centos.com # Get function from functions library . /etc/init.d/functions # Start the service Smokeping start() { echo -n "Starting Smokeping: " /opt/smokeping/bin/smokeping >/dev/null 2>&1 ### Create the lock file ### touch /var/lock/subsys/smokeping success $"Smokeping startup" echo } # Restart the service Smokeping stop() { echo -n "Stopping Smokeping: " kill -9 `ps ax | grep "/opt/smokeping/bin/smokeping" | grep -v grep | awk '{ print $1 }'` >/dev/null 2>&1 && killall speedy_backend ### Now, delete the lock file ### rm -f /var/lock/subsys/smokeping success $"Smokeping shutdown" echo } ### main logic ### case "$1" in start) start ;; stop) stop ;; status) status Smokeping ;; restart|reload|condrestart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}" exit 1 esac exit 0 |
|
1 2 3 |
# chmod 755 /etc/init.d/smokeping |
Finally lets add Apache and Smokeping to startup and get them started:
|
1 2 3 4 5 6 7 8 |
# chkconfig smokeping on # chkconfig httpd on # service smokeping start Starting Smokeping: <span style="color: #339966;">[ OK ]</span> # service httpd start Starting httpd: <span style="color: #339966;">[ OK ]</span> |
Now browse to your new installed Smokeping and Smoketrace installation
http://www.how2centos.com/smokeping/smokeping.cgi