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

20 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
  10. Hi, I'm missing this command, Somebody could help me please?
    Big thanks from Cambodia!

    [root@free ~]# ./bin/smokeping --config=/opt/smokeping/etc/config --logfile=smoke.log
    -bash: ./bin/smokeping: No such file or directory

    ReplyDelete
    Replies
    1. I'm reconfigured it!

      [root@free smokeping-2.6.9]# ./configure --prefix=/opt/smokeping
      checking build system type... x86_64-unknown-linux-gnu
      checking host system type... x86_64-unknown-linux-gnu
      checking target system type... x86_64-unknown-linux-gnu
      checking for gcc... gcc
      checking whether the C compiler works... yes
      checking for C compiler default output file name... a.out
      checking for suffix of executables...
      checking whether we are cross compiling... no
      checking for suffix of object files... o
      checking whether we are using the GNU C compiler... yes
      checking whether gcc accepts -g... yes
      checking for gcc option to accept ISO C89... none needed
      checking how to run the C preprocessor... gcc -E
      checking for grep that handles long lines and -e... /usr/bin/grep
      checking for egrep... /usr/bin/grep -E
      checking for ANSI C header files... yes
      checking for sys/types.h... yes
      checking for sys/stat.h... yes
      checking for stdlib.h... yes
      checking for string.h... yes
      checking for memory.h... yes
      checking for strings.h... yes
      checking for inttypes.h... yes
      checking for stdint.h... yes
      checking for unistd.h... yes
      checking minix/config.h usability... no
      checking minix/config.h presence... no
      checking for minix/config.h... no
      checking whether it is safe to define __EXTENSIONS__... yes
      checking for a BSD-compatible install... /usr/bin/install -c
      checking whether build environment is sane... yes
      checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
      checking for gawk... gawk
      checking whether make sets $(MAKE)... yes
      checking for style of include used by make... GNU
      checking dependency style of gcc... none
      checking whether to enable maintainer-specific portions of Makefiles... no
      checking whether make supports nested variables... yes
      checking for perl... /usr/bin/perl
      checking for sed... /usr/bin/sed
      checking for grep... (cached) /usr/bin/grep
      checking for echo... /usr/bin/echo
      checking for ln... /usr/bin/ln
      checking for cp... /usr/bin/cp
      checking for rm... /usr/bin/rm
      checking for rmdir... /usr/bin/rmdir
      checking for mkdir... /usr/bin/mkdir
      checking for find... /usr/bin/find
      checking for sendmail... /usr/sbin/sendmail
      checking for gnroff... /usr/bin/gnroff
      checking for gnumake... no
      checking for gmake... /usr/bin/gmake
      checking checking for gnu make availablility... /usr/bin/gmake is GNU make
      checking checking for perl module 'RRDs'... Ok
      checking checking for perl module 'FCGI'... Ok
      checking checking for perl module 'CGI'... Ok
      checking checking for perl module 'CGI::Fast'... Ok
      checking checking for perl module 'Config::Grammar'... Ok
      checking checking for perl module 'Digest::HMAC_MD5'... Ok
      checking checking for perl module 'LWP'... Ok
      configure: creating ./config.status
      config.status: creating Makefile
      config.status: creating bin/Makefile
      config.status: creating doc/Makefile
      config.status: creating htdocs/Makefile
      config.status: creating etc/Makefile
      config.status: creating lib/Makefile
      config.status: creating etc/config.dist
      config.status: executing depfiles commands

      ** Ready to install Smokeping ******************************

      Settings:

      PERL5LIB = not set
      PERL = /usr/bin/perl

      The Smokeping Makefiles use GNU make functionality.
      Continue installation with

      /usr/bin/gmake install

      [root@free smokeping-2.6.9]#

      Delete
  11. Dear team
    Please help to assist me i have issue as below,thanks.

    [root@smp-test etc]# ./bin/smokeping --config=/opt/smokeping/etc/config --logfile=smoke.log
    -bash: ./bin/smokeping: No such file or directory

    ReplyDelete
    Replies
    1. i see there are other comment mention they face the same problem and it was solve by configure again. here is the comment they use

      ./configure --prefix=/opt/smokeping
      /usr/bin/gmake install

      Delete