Friday, September 19, 2014

smokeping for Centos7

I am using Centos7 + smokeping-2.6.9

lets start up by install needed package
before that, we will need to enable Epel repo
You can install EPEL by running yum install epel-release. The package is included in the CentOS Extras repository, enabled by default.

# yum install epel-release

Then follow up by the package for
  • mod_fcgid
  • httpd
  • httpd-devel
  • rrdtool
  • perl-CGI-SpeedyCGI
  • fping
  • rrdtool-perl
  • perl
  • perl-Sys-Syslog
# yum install mod_fcgid httpd httpd-devel rrdtool perl-CGI-SpeedyCGI fping rrdtool-perl perl perl-Sys-Syslog

Then we will needed some package for Cpan to install perl stuff

# yum install perl-CPAN perl-local-lib perl-Time-HiRes

The last one is the package to create installation for smokeping

# yum groupinstall "Development tools"
-----------------------------------------------------------------------------------------------------------------

Now lets download the latest smokeping at http://oss.oetiker.ch/smokeping/pub/
currently the latest i saw is 2.6.9, so i just download that

# wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz

then extract it

# tar -zxvf smokeping-2.6.9.tar.gz

Install the smokeping perl stuff

# cd smokeping-2.6.9/setup
# ./build-perl-modules.sh

it will auto install needed perl
Once done, back to smokeping-2.6.9 folder and you will notice a folder name thirdparty is created
we will need to move it to /opt folder, but before that, lets create smokeping folder at /opt first
then copy the thirdparty folder into it

# mkdir /opt/smokeping
# cp -r thirdparty /opt/smokeping/

# ./configure --prefix=/opt/smokeping
# make install

~ NOTE ~
if you encounter problem, please try make install again
this is because for my situation when i first make install, it pop some error but when i try make install again, the error gone

Now you can go to /opt/smokeping/etc and prepare the config file

# cd /opt/smokeping/etc
# for foo in *.dist; do cp $foo `basename $foo .dist`; done

--------------------------------------------------------------------------------------------------------------

Now is time to prepare for the interface
make sure you had install apache
else please install it using yum install httpd

#vim /etc/httpd/conf/httpd.conf

change:
DirectoryIndex index.html index.html.var
to:
DirectoryIndex index.html index.html.var smokeping.fcgi

then enable this
AddHandler cgi-script .cgi

---------------------------------
# vim /etc/httpd/conf.d/smokeping.conf

<Directory "/var/www/html/smokeping">
    Options +ExecCGI
</Directory>
--------------------------------
# mkdir /opt/smokeping/img
# mkdir /opt/smokeping/data
# mkdir /opt/smokeping/var
# mkdir /opt/smokeping/cache
# chown -R apache:apache /opt/smokeping/img
# chown -R apache:apache /opt/smokeping/cache
# ln -s /opt/smokeping/htdocs /var/www/html/smokeping
# ln -s /opt/smokeping/img /var/www/html/smokeping
# ln -s /opt/smokeping/cache /var/www/html/smokeping


# chmod 600 /opt/smokeping/etc/smokeping_secrets
# chmod 600 /opt/smokeping/etc/smokeping_secrets.dist
# chown -R apache:apache /var/www/html/smokeping

Before we start smokeping, please edit your configuration first
edit the smokeping config to your need (change the part in Red color word
# vim /opt/smokeping/etc/config
------------------------------------------
*** General ***

owner    = Peter Random
contact  = some@address.nowhere
mailhost = my.mail.host (Ignore if you do not have smtp server)
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 = /opt/smokeping/cache
imgurl   = cache
datadir  = /opt/smokeping/data
piddir  = /opt/smokeping/var
cgiurl   = http://some.url/smokeping.cgi
smokemail = /opt/smokeping/etc/smokemail.dist
tmail = /opt/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%,*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.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 400 Days"   400d

#+ hierarchies
#++ owner
#title = Host Owner
#++ location
#title = Location

*** Probes ***

+ FPing

binary = /usr/sbin/fping

*** Slaves ***
secrets=/opt/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.

+ Server
menu= Targets

++ google

menu = google.com
title = google.com
alerts = someloss
host = www.google.com
-----------------------------------------------------------------

For mine, i had turn off my firewalld as it was mean for private LAN
# systemctl stop firewalld

and i also had turn SeLinux
# setenforce 0

Start the apache service
# systemctl start httpd

start the smokeping services
# ./bin/smokeping --config=/opt/smokeping/etc/config --logfile=smoke.log

For startup script
you can get it from here
http://oss.oetiker.ch/smokeping/pub/contrib/smokeping-start-script
just edit the smokeping path
then put at /etc/init.d/
chmod 755 it


Thanks Will for pointing out the typo and mistake

15 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Good guide but couple of mistakes, and as you asked for corrections I'll oblige :)
    # mkdir /opt/smokeping/cache; command is missing from the instructions,
    # ln -s /opt/smokeping/cache /var/www/htnl/smokeping <- typo should be HTML,
    Worth mentioning that firewalld will need to be adjusted, I simply opted for,
    # systemctl disable firewalld; in a secure LAN ymmv

    Otherwise excellent - saved me a bunch of time!

    ReplyDelete
    Replies
    1. Thanks Will, great to get know my mistake and things i had left out~

      Delete
  3. so how to enforce user based smokeping??

    ReplyDelete
    Replies
    1. mean you wanna run it as smokeping user.?

      Delete
  4. Thanks for the instructions.
    Most of the installation instructions I found require rpmforge, that is now dead or almost, so I was relieved to discover that EPEL can replace it, and I can continue to use SmokePing.

    In case anybody had the same problem, my system required a reboot after installation before I could start the service.

    ReplyDelete
  5. hi

    its show png files not save in image path but full permissions given to all image path floders

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. I think you miss the most important command:
    mv /opt/smokeping/htdocs/smokeping.fcgi.dist /opt/smokeping/htdocs/smokeping.fcgi
    otherwise you will get the plain-text smokeping main website

    ReplyDelete
    Replies
    1. must be miss out, thanks for pointing out. will update into it

      Delete
  8. Hi,

    I recently followed your tutorial everything works fine except i get a error like this back:

    Forbidden

    You don't have permission to access /smokeping.cgi on this server.

    i constantly get [cgi:error]pid client Options ExecCGI is off in this directory: /var/www/html/smokeping.cgi

    i hope you can help me, thanks in advance!

    ReplyDelete
    Replies
    1. you got enable this inside you apache config.?
      AddHandler cgi-script .cgi

      Delete
  9. Hi,

    I followed the steps which you have provided i get an error and mentioned below.

    Forbidden

    You don't have permission to access /smokeping.cgi on this server.

    I have checked and enabled apache config ?
    AddHandler cgi-script .cgi.

    Could you please help me on this

    ReplyDelete
    Replies
    1. sorry for the late reply, not sure what causing this but you can try checking the file permission and your mod_access
      and make sure the selinux disable

      Delete