Author Topic: Installing Smokeping on CentOS 5.5  (Read 26863 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2145
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Installing Smokeping on CentOS 5.5
« on: กุมภาพันธ์ 10, 2011, 11:09:31 AM »
Lets begin by installing the framework required by Smokeping.

    # yum update
    # rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
    # 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

    # 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

    # 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

    # 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:

    # 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

    # patch -p1 -i smokeping.patch /opt/smokeping/bin/smokeping
    patching file /opt/smokeping/bin/smokeping

    # 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:

    # 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

    # patch -p1 -i smokeping_cgi.patch /opt/smokeping/htdocs/smokeping.cgi
    patching file /opt/smokeping/htdocs/smokeping.cgi

    # 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:

    # 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;

    # patch -p1 -i tr_cgi.patch /opt/smokeping/htdocs/tr.cgi
    patching file /opt/smokeping/htdocs/tr.cgi

    # 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

    # 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

    # chmod 4775 /bin/traceroute

    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

    # 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:

    # 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>

    # patch -p1 -i basepage.patch /opt/smokeping/etc/basepage.html
    patching file /opt/smokeping/etc/basepage.html

    # 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>

    # ln -s /opt/smokeping/htdocs/tr.html /var/www/html/smokeping/tr.html

Lets create a basic Config file for Smokeping to get started:

    # 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

    # 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
        ### 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

    # chmod 755 /etc/init.d/smokeping

Finally lets add Apache and Smokeping to startup and get them started:

    # chkconfig smokeping on
    # chkconfig httpd on
    # service smokeping start
    Starting Smokeping: [ OK ]
    # service httpd start
    Starting httpd: [ OK ]



Thank you for link : http://www.how2centos.com/installing-smokeping-on-centos-5-5/
« Last Edit: กุมภาพันธ์ 10, 2011, 12:12:22 PM by golfreeze »