Use the smokeping Monitoring Network

Source: Internet
Author: User
Tags rrd rrdtool smokeping

This article can be freely reproduced, but please follow the "signature-non-commercial use-consistent" Creative sharing agreement. Permanent Link: joecen's nest
-----------------------------


I. Introduction

Smokeping is the work of Tobi oetiker by rrdtool. Therefore, it has great advantages in graphic display and is also a very characteristic opensource tool:

Multiple detection methods, including fping, echoping, dig, and curl;
Easy to use and scalable plug-ins;
Master/Slave, which can collect data from the same monitoring site on multiple nodes;
Alert settings are quite distinctive, not just a simple set of thresholds;

The current version of smokeping is 2.4.2. This article is based on this version.

Ii. Installation

Download Page: http://oss.oetiker.ch/smokeping/pub/

1. preparations:

Smokeping is a program written in Perl, so it does not need to be installed. However, he needs to use some tools and Perl modules, such as rrdtool, fping, and echoping, which must be installed in advance.

If Debian is used, you can directly use apt to install it:

Aptitude install rrdtool apache2 fping echoping libapache2-mod-speedycgi libwww-perl libsocket6-perl Libnet-Telnet-perl Libnet-DNS-perl Libnet-LDAP-perl libio-socket-SSL-perl libauthen-radius-perl libcgi- perl librrds-perl librrdp-perl

For other Linux releases, you can use CPAN to install the Perl module.

When smokeping is started, it will also check whether the program to be used can be found.

2. settings:
In the smokeping subdirectory, you will find many files named "*. Dist". Change these files to "*" and configure them.

Bin/smokeping
The main program runs in the background.
In this file, we need to modify the path of the first two lib and the config file.
The two lib libraries are the Lib of smokeping and the Lib of rrdtool respectively.

My smokeping is installed in the/usr/local/directory, so my settings are as follows:

Use lib QW (/usr/lib/perl5 /);
Use lib QW (/usr/local/smokeping/LIB );

Smokeping: Main ("/usr/local/smokeping/etc/config ");

Htdocs/smokeping. cgi
Displays pages, images, and Slave Data Transmission interfaces. The setting method is similar to "bin/smokeping.
However, the path of speedy in the first line may need to be modified. Otherwise, only a white page is displayed in the browser.

Htdocs/Cropper /*
This tool is used to zoom in and out page images.

ETC/config
The main configuration file is very important.
It uses the Perl config: grammar module.
For more detailed configuration, click here.

In section:

* ** General ***

Here I mainly configure several paths:

Imgcache =/home/temp/smokeping/Cache
Imgurl = https: // smokeping/smokepingcache
Datadir =/home/temp/smokeping/Data
Piddir =/home/temp/smokeping/var
Cgiurl = https: // smokeping/smokeping. cgi (I used SSL)

To display Chinese characters on the page, go to section:

* ** Presentation ***

, Add:

Charset = gb2312

However, the rrdtool image still does not display Chinese characters.

ETC/basepage.html
Displays the main frame of the page. You just need to configure the location of "htdocs/Cropper.

3. Configure Apache:

<Directory/usr/local/smokeping/htdocs/>
AllowOverride none
Addhandler CGI-script CGI
Options execcgi
</Directory>

Alias/smokeping/"/usr/local/smokeping/htdocs /"
Alias/smokepingcache/"/home/temp/smokeping/Cache /"

Iii. Common Use
1. Start Using
The smokeping configuration file "ETC/config" uses the config file in the form of config: grammar and uses "+" as the starting symbol of the layer.
For example:

+ Layer1
Menu = layer1
Title = layer1

++ Site1
Menu = Layer2
Title = Layer2

++ Myhost1
Menu = layer3
Title = layer3
Host = myhost.com

++ Myhost2
Menu = layer4
Title = layer4
Host = yourhost.com
...

Myhost1 and myhost2 belong to Site1, while Site1 belongs to layer1. In addition, the sub-layer "menu" and "title" are not required.

After configuration, you can start smokeping:

./Bin/smokeping

If there is an error, debug it:

./Bin/smokeping -- debug

2. Multi-graph function

That is, to draw the values of multiple monitoring points in a graph, it is very simple:

++ Multi
Menu = multi
Title = My multi
Host =/layer1/Site1/myhost1/layer1/Site1/myhost2

All others are the same. The difference is that in "host", you can specify the path of the host to be put together (the previously configured host is required.

Iv. smoketrace
I personally think the new features added by the author in version 2.4 are of little use.
Here is a detailed installation method. If you use the "htdocs" directory as the CGI directory, you do not need to change anything. You only need to set "htdocs/TR. CGI. the Dist file is renamed "tr. cgi ", and configure the Lib path.

Finally, in section:

* ** Targets ***

Add:

Menuextra = <a target = '_ blank' href}'tr.html {Host} 'class =' {class }'/
Onclick = "Publish publish open(this.href,this.tar get ,/
'Width = 800, Height = 500, toolbar = No, location = No,
Status = No, scrollbars = no ');/
Return false; "> * </a>

You can see that each host on the left of the page is followed by a "*" number. Click this "*" number to bring up the trace page.
This trace is similar to the trace result of "MTR". Why is it useless? Because the returned results are relatively slow, and only the "master" machine can be used for trace.

V. Master/Slave Mode
The following describes the master and slave modes. For more information, see here.

[Slave 1] [slave 2] [slave 3]
|
+ ------- + | + -------- +
|
V v
+ --------------- +
| Master |
+ --------------- +

As shown in the figure, the Server Load balancer host checks the monitoring metrics (loss and RTT) and submits the values to the master host (through smokeping. cgi ).
It is worth noting that the slave does not need the config file. After each slave commits data, it will ask the master if its own configuration file has been modified. If there is any modification, the slave will be updated.

The configuration method is as follows:
Set slave information:

* ** Slaves ***
Secrets =/usr/local/smokeping/etc/slavesecrets. conf

+ Slave1
Display_name = bjcnc
Location = China
Color = ff0000

Note that the "slave1" name must be set to the hostname of the slave host and written in the "slavesecrets. Con" file, for example:

Server Load balancer 1: 12345

If you do not want to use the hostname of the slave host, you must use "-- slave-name" to specify your own name when the slave host starts the smokeping service.

* ** Targets ***
Slaves = slave1 slave2
...
+ Dest1
Slaves =
...
+ Dest2
Slaves = slave1
...
+ Dest3
...

In Section

* ** Targets ***

Specify the Server Load balancer instance that the host needs to use for detection. The lower layer inherits the upper layer configuration. If the lower layer is not inherited, you can configure "Slaves =" to avoid using slave.

After the settings, restart the master server:

./Bin/smokeping -- restart

Start slave:

./Bin/smokeping -- master-url = http: // smokeping/smokeping. cgi/
-- Cache-Dir =/var/tmp/smokeping //
-- Shared-secret =/usr/local/smokeping/secret.txt/
-- Slave-name = slave1

Secret.txt records the Server Load balancer password corresponding to the Server Load balancer. conf file of the master (only the password, no Server Load balancer name ).
The file permissions of slavesecrets.confand secret.txt files are "600.

In Master/Slave Mode, both the master and slave images are displayed on the same page. If you do not want to display the master image, you can use

Nomasterpoll = Yes

Parameters.
Note that the "smokeping" process started on the master must be consistent with that of the Apache process. Because the RRD file is created by the "smokeping" process, and the data update is performed by "smokeping. cgi", that is, Apache users. If they are inconsistent, the RRD file cannot be updated. This problem cannot be seen even if debug is performed on the slave host. The specific phenomenon is that the master image shows data on the page, but the slave image remains blank, and the data is displayed as "Nan ".

6. Alert settings
The alert settings of smokeping are a bit complicated, but they are easy to use and well considered.
By default, it can use emails for alert, or directly call external programs for im alarms. That is to say, you only need to write a simple script, in this way, you can implement the smokeping of MSN, Gtalk, fetion, and other IM and SMS alarms.

Example:

* ** Alerts ***
To = |/usr/local/smokeping/bin/alert. Sh
From = Joe @ somehost

"To" option. By default, you need to enter an email address, but you only need to add "|" after "=", followed by the path of your custom script, you can call your own script to perform alert.
The script reads five or six parameters: name-of-alert, target, loss-pattern, RTT-pattern, hostname, [raise].
Select the alert parameter.

+ Someloss
Type = loss
# In percent
Pattern => 0%, * 12 *,> 0%, * 12 *,> 0%
Comment = loss 3 times in a row

+ Rttbad
Type = RTT
# In milliseconds
Pattern = s,> 50,> 50
Comment = route

+ Rttdetect
Type = RTT
# In milliseconds
Pattern = <10, <10, <10, <10, <10, <100,> 100,> 100
Comment = routing messed up again?

Alert types are mainly "loss" and "RTT" (more and more complex types, of course ). The two alert settings above mean:
Someloss:
If three packet loss occurs during 12 checks (no matter how many packets are lost), perform alert;

Rttbad:
If two consecutive latencies of more than 50 milliseconds occur, perform alert;

Rrtdetect:
The latency of the previous five checks is less than 10 milliseconds, and the latency of the first six checks is less than 100 milliseconds. If the latency of the first three consecutive checks is greater than 7th milliseconds, alert is performed.

As can be seen from the above, smokeping's alert is very comprehensive and careful, not like other tools, using a threshold value for warning.

Finally, add the following to the target you want to execute alert:

Alerts = rttbad, someloss

You can.
Like "slaves", it also inherits upwards. The method to avoid inheritance is also "alerts =", making an empty alerts.

Refer:
Smokeping documentation http://oss.oetiker.ch/smokeping/doc/index.en.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.