Smokeping is the best test tool for IDC network quality and stability, including General ping, dig, echoping, and curl. It can monitor www server performance and dns query performance, monitors ssh performance. Smokeping is the work of Tobi Oetiker by rrdtool, so the underlying layer is also supported by rrdtool. Smokeping is a very old open-source project, but considering the requirements of the following two aspects of the current network, it is still necessary to deploy it. 1. The host restart speed on the virtualization platform is fast, and the sensitivity of common monitoring platforms may be insufficient. 2. The business and network departments often have requirements for comparing the network quality and page access speed.
I. Installation conditions of smokeping
For more information about the packages to be prepared before installing smokeping, see the official page: http://oss.oetiker.ch/smokeping/doc/smokeping_install.en.html, the specific needs are as follows (the option with optional is optional package ):
RRDtool 1.2.x or later
FPing (optional)
EchoPing (Optional)
Curl (Optional)
Dig (Optional)
SSH (Optional)
Webserver
Perl 5.8.8 or later (the corresponding modules are as follows)
FCGI
CGI, CGI: Fast
Config: Grammar
LWP
Socket6 (optional)
Net: Telnet (optional)
Net: OpenSSH (optional)
Net: DNS (optional)
Net: LDAP (optional)
IO: Socket: SSL (optional)
Authen: Radius (optional)
In the centos environment, the above packages can be installed completely by adding the third-party source epel. I installed the following package during the test:
[Root @ 361way ~] # Yum install rrdtool fping wget dig curl bind-utils gcc make perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl-RadiusPerl perl-IO-Socket -SSL perl-Socket6 perl-FCGI perl-RRD-Simple perl-CPAN rrdtool-perl-CGI-SpeedCGI perl-ExtUtils-MakeMaker
Because I have integrated some nginx, If apache is available, you need to install the following package:
# Yum install mod_fcgid httpd-devel
II. Install smokeping
1. Install smokeping
[Root @ 361way src] # wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.11.tar.gz
[Root @ 361way src] # tar xvf smokeping-2.6.11.tar.gz
[Root @ 361way src] # cd smokeping-2.6.11
[Root @ 361way smokeping-2.6.11] #./configure -- prefix =/opt/smokeping
[Root @ 361way smokeping-2.6.11] # gmake install
[Root @ 361way smokeping-2.6.11] # make install
When configuring configure, if the perl environment contains a missing package, the following error is reported:
** Aborting Configure ******************************
If you know where perl can find the missing modules, set
The PERL5LIB environment variable accordingly.
FIRST though, make sure that 'Perl 'starts the perl
Binary you want to use for SmokePing.
Now you can install local copies of the missing modules
By running
./Setup/build-perl-modules.sh/opt/smokeping/thirdparty
The RRDs perl module is part of RRDtool. Either use the rrdtool
Package provided by your OS or install rrdtool from source.
If you install from source, the RRDs module is located
PREFIX/lib/perl
When the above error occurs, you can install the required package by executing./setup/build-perl-modules.sh/opt/smokeping/thirdparty (you need to be able to connect to the Internet ). After the installation is complete, execute the following gmake and make install operations.
2. Create a data file directory
# Cd/opt/smokeping
# Mkdir data var cache
# Chown-R www: www data cache
Nginx is executed by www users, so the corresponding data directory must have writable permissions.
3. Create and stop a script file
Before starting the service, you must configure the config configuration file. For more information about configuration, see section 3.
# Wget http://www.111cn.net/wp-content/uploads/2016/05/smokeping.txt
# Mv smokeping.txt/etc/init. d/smokeping
# Chmod 755/etc/init. d/smokeping
To configure auto-start upon startup, you also need to use the chconfig command to execute the following operations:
# Chkconfig-add smokeping
# Chkconfig smokeping on
4. Modify configuration file permissions
Smokeping_secrets is mainly used to configure the key file for master/slave communication. It is not involved when a single host runs smokeping.
# Cd/opt/smokeping/etc/
# For foo in *. dist; do cp $ foo 'basename $ foo. Dist'; done
# Chmod 600/opt/smokeping/etc/smokeping_secrets.dist
III. smokeping configuration file
The smokeping configuration can be divided into seven parts:
The first part of General is the basic configuration. Note that imgcache and imgurl are two parameters. Note that they are associated with the apache configuration. If the configuration is not good, the image cannot be displayed when the web is opened;
The second part is the alarm configuration;
The third part is Database RRD Database configuration. The parameters step and pings must be configured before starting smokeping. If you configure these parameters after starting smokeping, you must delete the original rrd file and then start smokeping. Therefore, you must configure this item first. The default value is step = 300 pings = 20. The ping action is performed 20 times per s;
Part 4 Presentation refers to some configurations and explanations about the network status and does not need to be changed;
The fifth part is the Porbes pointer configuration. We generally only use fping, so we only need the following configuration to determine whether the path is correct. Here we can also set the fping package size. The parameter is packetsize;
The slave server configuration in the Slaves master-slave relationship in the sixth branch. The slave server in smokeping only needs to be installed. No configuration is required. All the configurations of smokeping are set on the master node. Set the secrets password file and slave server;
Part 7 Targets target configuration. You can configure the monitoring status of a single server Here. The configuration that needs to be set from the slave server is also configured here. I have already explained it clearly with annotations. Pay attention to this. + Indicates that the top-level Menu + the following ++ inherits the top-level + and becomes the second-level menu. There can also be multiple level-1 menus and level-2 menus.
Config configuration example:
# Cat config
* ** 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 =/opt/smokeping/cache
Imgurl = cache
Datadir =/opt/smokeping/data
Piddir =/opt/smokeping/var
# Cgiurl = http: // 192.168.0.110/smokeping. cgi
Cgiurl = http: // 192.168.0.110/smokeping. fcgi // This address is very important.
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
Step = 60
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
Charset = utf-8
+ 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 = 10 h
+ Detail
Width = 600
Height = 200
Unison_tolerance = 2
"Last 3 Hours" 3 h
"Last 30 Hours" 30 h
"Last 10 Days" 10d
"Last 400 Days" 400d
# + Hierarchies
# ++ Owner
# Title = Host Owner
# ++ Location
# Title = Location
* ** Probes ***
+ FPing
Binary =/usr/sbin/fping
# $ Packetsize = 2000
* ** 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 = 111cn.net smokeping test
Title = test the O & M path
# Parents = owner:/Test/James location :/
++ 361way
Menu = 361
Title = 111cn.net
Alerts = someloss
Host = www.111cn.net
++ 102 Host
Menu = 102
Title = host102
Host = 192.168.0.102
++ 200 Host
Menu = 200
Title = host200
Host = 192.168.0.200
++ 201 Host
Menu = 201
Title = host201
Host = 192.168.0.201
+ AllHost
Menu = allhost
Title = All Host In One Graph
Host =/Test/102 Host/Test/200 Host/Test/201 Host
IV. nginx Reverse proxy smokping cgi page
The integration of nginx and smokping requires a plug-in spawn-fcgi run by cgi. This package can be downloaded and installed by using the epel source, and directly run yum-y install spawn-fcgi.
1. Create the smokeping-fastcgi startup script
[Root @ 361way smokeping] # cat/opt/smokeping-fastcgi
#! /Bin/sh
/Usr/bin/spawn-fcgi-a 127.0.0.1-p 9007-P/var/run/smokeping-fastcgi.pid-u www-f/opt/smokeping/htdocs/smokeping. fcgi
2. Configure the smokeping-fastcgi automatic startup script
[Root @ 361way ~] # Cat/etc/init. d/smokeping-fastcgi
#! /Bin/bash
FCGI_SCRIPT =/opt/smokeping-fastcgi
FASTCGI_USER = www
PIDFILE =/var/run/smokeping-fastcgi.pid
RETVAL = 0
Case "$1" in
Start)
$ FCGI_SCRIPT
RETVAL =$?
;;
Stop)
PID = 'cat $ pidfile'
Kill-9 $ PID $ (pgrep-P $ PID)
RETVAL =$?
;;
Restart)
PID = 'cat $ pidfile'
Kill-9 $ PID $ (pgrep-P $ PID)
$ FCGI_SCRIPT
RETVAL =$?
;;
*)
Echo "Usage: smokeping-fastcgi {start | stop | restart }"
Exit 1
;;
Esac
Exit $ RETVAL
3. nginx configuration file
If you have a domain name, you can replace localhost with the corresponding domain name.
Server {
Listen 80;
Server_name localhost;
Location /{
Root/opt/smokeping/htdocs /;
Index index.html index.htm index. cgi;
}
Location ~ . * \. Fcgi $ {
Root/opt/smokeping/htdocs /;
Fastcgi_pass 127.0.0.1: 9007;
Include/opt/nginx/conf/fastcgi_params;
}
}
4. Start nginx and smokeping-fastcgi
#/Etc/init. d/smokeping-fastcgi start
#/Opt/nginx/sbin/nginx
One problem found during the test: every time the somkeping program is restarted, smokeping-fastcgi exits and needs to be restarted. Therefore, it is best to enable a daemon for smokeping-fastcgi, or add the smokeping-fastcgi restart action in the smokeping script.
In this case, open http: // ip/smokeping. fcgi and you can see the content similar to the following: