Script installation of smokeping
I will provide two ways to install smokeping, one is common installation, the other is automatic installation under script, just for you to learn, reference!
General installation:
Install smokeping under centos 5.4
Required software:
(1) httpd
(2) rrdtool
(3) smokeping
(4) fping
(5) libwww-perl
Preparation before installing rrdtool
/ etc/yum.repos.d/dag.repo
[dag]
Name=Dag RPM Repository for Red Hat Enterprise Linux
Baseurl= http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
Gpgcheck=1
Gpgkey= http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
Enabled=1
Yum-y install freetype-devel zlib-devel libpng-devel libart_lgpl-devel rrdtool
# Install httpd
Useradd www
Tar zxvf httpd-2.2.15.tar.gz
Cd httpd-2.2.15
. / configure-prefix=/usr/local/apache2-enable-so
Make & & make install
Wget http://fping.sourceforge.net/download/fping.tar.gz
# Install fping
Tar zxvf fping.tar.gz
Cd fping-2.4b2_to/
. / configure
Make & & make install
Wget http://daemoninc.com/SpeedyCGI/CGI-SpeedyCGI-2.22.tar.gz
# Install CGI-SpeedyCGI
Tar-zxvf CGI-SpeedyCGI-2.22.tar.gz
Cd CGI-SpeedyCGI-2.22
Perl Makefile.PL
Compile mod_speedycgi (default no)? No
Make & & make install
# Install Perl modules libwww-perl
Wget http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/libwww-perl-5.836.tar.gz
Tar-zxvf libwww-perl-5.836.tar.gz
Cd libwww-perl-5.836
Perl Makefile.PL
Make & & make install
Wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.4.2.tar.gz
Tar-zxvf smokeping-2.4.2.tar.gz
Mv smokeping-2.4.2 / usr/local/smokeping
Modify smokeping&httpd configuration file
Mkdir-p / usr/local/smokeping/htdocs/img
Mkdir-p / usr/local/smokeping/var
Under smokeping/bin
Mv smokeping.dist smokeping
File: smokeping
Use lib qw (/ usr/lib/perl5)
Use lib qw (/ usr/local/smokeping/lib)
Smokeping::main ("/ usr/local/smokeping/etc/config")
Smokeping/etc
Mv config.dist config
File:config
* General * *
Owner = Peter Random
Contact = some@address.nowhere
Mailhost = my.mail.host
# sendmail = / usr/lib/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 p_w_picpaths.
Imgcache = / usr/local/smokeping/htdocs/img
Imgurl = http:// native IP/img
Datadir = / usr/local/smokeping/var
Piddir = / usr/local/smokeping/var
Cgiurl = http:// native IP/smokeping.cgi
Smokemail = / usr/local/smokeping/etc/smokemail.dist
Tmail = / usr/local/smokeping/etc/tmail.dist
# 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%, > 0%, > 0%, > 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 = / usr/local/smokeping/etc/basepage.html.dist
+ 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 400Days" 400d
# + hierarchies
# + + owner
# title = Host Owner
# + + location
# title = Location
* Probes * *
+ FPing
Binary = / usr/local/sbin/fping
* Slaves * *
Secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
+ boomer
Display_name=boomer
Color=0000ff
+ slave2
Display_name=another
Color=00ff00
* Targets * *
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.
+ Test
Menu= Targets
# parents = owner:/Test/James location:/
+ + James
Menu = James
Title = James
Alerts = someloss
Slaves = boomer slave2
Host = james.address
+ + MultiHost
Menu = Multihost
Title = James and James as seen from Boomer
Host = / Test/James / Test/James~boomer
Smokeping/htdocs
Mv smokeping.cgi.dist smokeping.cgi
File:smokeping.cgi
Use lib qw (/ usr/lib/perl5/)
Use lib qw (/ usr/local/smokeping/lib)
Smokeping::cgi ("/ usr/local/smokeping/etc/config")
Httpd is added as follows
ScriptAlias / smokeping.cgi "/ usr/local/smokeping/htdocs/smokeping.cgi"
Alias / img "/ usr/local/smokeping/htdocs/img"
AllowOverride None
AddHandler cgi-script cgi
Options ExecCGI
Chown-R www.www / usr/local/smokeping
Modify httpd.conf run permission www
Start
Service iptables stop
/ usr/local/smokeping/bin/smokeping start
/ usr/local/apache2/bin/apachectl start
Ps-ef | grep smokeping
Script Automation installation:
Note: there are some configurations that need to be self-contained.
For example, my package is divided into auto_install_smokeping.sh and soft folders. There is a smokeping,apache2,yum folder under the soft folder, and there are some files under these folders. The general structure is as follows:
Auto_install_smokeping.sh
-bin/smokeping
-smokeping-etc/config
-htdocs/smokeping.cgi
Soft-apache2-conf/httpd.conf
-yum/dag.repo
Fping.tar.gz httpd-2.2.15.tar.gz et al.
Script:
#! / bin/bash
# User Zhuzhengjun
# date 2010-06-28
# install need root user.
If [`whoami`! = "root"]; then
Echo "Installtion this package needs root user."
Exit 1
Fi
# set env
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Export PATH
PWD= `pwd`
Export PWD
Mkdir-p logs
Export LOG_FILE= "$PWD/logs/install.log"
Export ERROR_FILE= "$PWD/logs/error.log"
Export Soft= "$PWD/soft"
# add user
Echo "= Add user=" > > $LOG_FILE
Echo "= Add user=" > > $ERROR_FILE
If [`grep ^ www / etc/passwd | wc-l`-eq 0]; then
Useradd www 1 > > $LOG_FILE 2 > > $ERROR_FILE
# echo "wokaosiquba" | passwd-- stdin www 1 > > $LOG_FILE 2 > > $ERROR_FILE
Else echo "www user is add!"
Fi
# add dns
Echo "= Add dns=" > > $LOG_FILE
Echo "= Add dns=" > > $ERROR_FILE
If [`grep "202.96.209.5" / etc/resolv.conf | wc-l `- eq 0]; then
Echo "nameserver 202.96.209.5" > > / etc/resolv.conf 1 > > $LOG_FILE 2 > > $ERROR_FILE
Fi
# add yum repos for rrdtool
Echo "= Add yum repos=" > > $LOG_FILE
Echo "= Add yum repos=" > > $ERROR_FILE
Cp-f $Soft/yum/dag.repo / etc/yum.repos.d/ 1 > > $LOG_FILE 2 > > $ERROR_FILE
# install rrdtool wget cron ntp
Echo "= install rrdtool wget cron ntp=" > > $LOG_FILE
Echo "= install rrdtool wget cron ntp=" > > $ERROR_FILE
Yum-y install ntp freetype-devel zlib-devel libpng-devel wget vixie-cron rrdtool 1 > > $LOG_FILE 2 > > $ERROR_FILE
If [`grep "NTP_IP" / var/spool/cron/root | wc-l`-eq 0]; then
Echo "1 * / usr/sbin/ntpdate NTP_IP; hwclock-w 1 > / dev/null 2 > & 1" > / var/spool/cron/root
Fi
# install httpd
Echo "= Install httpd=" > > $LOG_FILE
Echo "= Install httpd=" > > $ERROR_FILE
Cd $Soft
Tar zxf httpd-2.2.15.tar.gz
Cd httpd-2.2.15/
. / configure-- prefix=/usr/local/apache2-- enable-so 1 > > $LOG_FILE 2 > > $ERROR_FILE
["$?"-eq 0] & & make 1 > > $LOG_FILE 2 > > $ERROR_FILE
["$?"-eq 0] & & make install 1 > > $LOG_FILE 2 > > $ERROR_FILE
# install fping
Echo "= Install fping=" > > $LOG_FILE
Echo "= Install fping=" > > $ERROR_FILE
Cd $Soft/
Tar-zxf fping.tar.gz
Cd fping-2.4b2_to/
. / configure 1 > > $LOG_FILE 2 > > $ERROR_FILE
["$?"-eq 0] & & make 1 > > $LOG_FILE 2 > > $ERROR_FILE
["$?"-eq 0] & & make install 1 > > $LOG_FILE 2 > > $ERROR_FILE
# install CGI-SpeedyCGI
Echo "= Install CGI-SpeedyCGI=" > > $LOG_FILE
Echo "= Install CGI-SpeedyCGI=" > > $ERROR_FILE
Cd $Soft/
Tar-zxf CGI-SpeedyCGI-2.22.tar.gz
Cd CGI-SpeedyCGI-2.22/
Perl Makefile.PL $LOG_FILE 2 > > $ERROR_FILE
["$?"-eq 0] & & make install 1 > > $LOG_FILE 2 > > $ERROR_FILE
# install libwww-perl
Echo "= Install libwww-perl=" > > $LOG_FILE
Echo "= Install libwww-perl=" > > $ERROR_FILE
Cd $Soft/
Tar-zxf libwww-perl-5.836.tar.gz
Cd libwww-perl-5.836/
Perl Makefile.PL 1 > > $LOG_FILE 2 > > $ERROR_FILE
Make 1 > > $LOG_FILE 2 > > $ERROR_FILE
Make install 1 > > $LOG_FILE 2 > > $ERROR_FILE
# install smokeping
Echo "= Install smokeping=" > > $LOG_FILE
Echo "= Install smokeping=" > > $ERROR_FILE
Cd $Soft/
Tar-zxf smokeping-2.4.2.tar.gz
Mv smokeping-2.4.2 / usr/local/smokeping 1 > > $LOG_FILE 2 > > $ERROR_FILE
Mkdir-p / usr/local/smokeping/htdocs/img
Mkdir-p / usr/local/smokeping/var
# config smokeping
Echo "= Config smokeping=" > > $LOG_FILE
Echo "= Config smokeping=" > > $ERROR_FILE
Cp-f $Soft/smokeping/bin/smokeping / usr/local/smokeping/bin/ 1 > > $LOG_FILE 2 > > $ERROR_FILE
Cp-f $Soft/smokeping/etc/config / usr/local/smokeping/etc/ 1 > > $LOG_FILE 2 > > $ERROR_FILE
Cp-f $Soft/smokeping/htdocs/smokeping.cgi / usr/local/smokeping/htdocs/ 1 > > $LOG_FILE 2 > > $ERROR_FILE
Cp-f $Soft/apache2/conf/httpd.conf / usr/local/apache2/conf/ 1 > > $LOG_FILE 2 > > $ERROR_FILE
# authorize
Echo "= authorize=" > > $LOG_FILE
Echo "= authorize=" > > $ERROR_FILE
Chown-R www.www / usr/local/smokeping
Chmod 400 / usr/local/smokeping/etc/smokeping_secrets.dist
Chmod + x / usr/local/smokeping/bin/smokeping
Chmod + x / usr/local/smokeping/htdocs/smokeping.cgi
# start deamon
Echo "= start deamon=" > > $LOG_FILE
Echo "= start deamon=" > > $ERROR_FILE
/ usr/local/smokeping/bin/smokeping start 1 > > $LOG_FILE 2 > > $ERROR_FILE
/ usr/local/apache2/bin/apachectl start 1 > > $LOG_FILE 2 > > $ERROR_FILE
Service iptables stop
Ps-ef | grep smokeping