Smokeping安裝與配置-免費(fèi)開源網(wǎng)絡(luò)性能監(jiān)控工具可視化主/從部署

在購買VPS主機(jī)之前,我一般都會(huì)先查看一下別人使用該VPS主機(jī)的評(píng)價(jià),尤其是VPS主機(jī)的線路是我最關(guān)心的地方。因?yàn)閲獾腣PS主機(jī)商非常多,但是真正從國內(nèi)訪問速度快的機(jī)房也就是那么幾個(gè)。線路不好,速度慢的VPS,并不適合搭建中文網(wǎng)站。

同時(shí),我也發(fā)現(xiàn)了另一個(gè)問題,那就是某一個(gè)VPS主機(jī)在最開始測試時(shí)線路質(zhì)量很好,但是隨著用戶的增多VPS主機(jī)訪問也越來越不穩(wěn)定了,這是最開始使用VPS主機(jī)沒有想到的。所以,迫切需要一個(gè)國外VPS主機(jī)線路監(jiān)控報(bào)告,能夠直觀地了解VPS主機(jī)線路的變化。

滿足上面要求的,恐怕只有Smokeping了。Smokeping是一個(gè)開源免費(fèi)的網(wǎng)絡(luò)性能監(jiān)控工具,主要用于監(jiān)視網(wǎng)絡(luò)性能,包括常規(guī)的 ping,dig,echoping,curl等,可以 監(jiān)視 www 服務(wù)器性能,監(jiān)視 dns 查詢性能,監(jiān)視 s-s-h 性能等。最重要的是Smokeping的圖表非常直觀。

Smokeping采用rrdtool做支持,生成的網(wǎng)絡(luò)延遲數(shù)據(jù)轉(zhuǎn)化圖表非常漂亮,支持交互式圖形瀏覽,你可以查看任意時(shí)間段的監(jiān)控?cái)?shù)據(jù)。Smokeping也可以部署主/從分布式測量,即用一臺(tái)服務(wù)器作為“主”,其它的服務(wù)器作為“從”并向“主”服務(wù)器傳輸數(shù)據(jù),最后匯總形成系統(tǒng)監(jiān)控?cái)?shù)據(jù)圖表。

Smokeping安裝與配置-免費(fèi)開源的網(wǎng)絡(luò)性能監(jiān)控工具可視化圖表主/從分布式測量

本篇文章就來分享一下Smokeping安裝與配置方法,你也可以自己按照下面的方法來給VPS主機(jī)作一個(gè)“體檢”:

一、Smokeping安裝前準(zhǔn)備

Smokeping官網(wǎng):

  1. https://oss.oetiker.ch/smokeping/index.en.html
  2. https://github.com/oetiker/SmokePing

Smokeping需要以下組件依賴(有optional為可選項(xiàng)):

RRDtool 1.2.x or later

FPing (optional)

EchoPing (Optional)

Curl (Optional)

dig (Optional)

S-S-H (Optional)

Webserver

Perl 5.8.8 or later(對應(yīng)的模塊如下)

FCGI

CGI, CGI::Fast

Config::Grammar

LWP

Socket6 (optional)

Net::Telnet (optional)

Net::OpenS-S-H (optional)

Net::.DNS (optional)

Net::LDAP (optional)

IO::Socket::SSL (optional)

Authen::Radius (optional)

Smokeping官網(wǎng)推薦用Apache來運(yùn)行,當(dāng)然也可以使用Nginx,但是你需要配置好Nginx FCGI才行。本篇文章測試的環(huán)境是:CentOS 6.8+Apache。執(zhí)行以下命令安裝相關(guān)組件依賴:

#臨時(shí)修改hostname
sudo hostname ping.wzfou.com
#查看是否成功
hostname
#永久修改Hostname
vi  /etc/sysconfig/network
#修改原h(huán)ostname為
ping.wzfou.com
#查看是否成功
hostname

#禁用SELinux
vi /etc/selinux/config
SELINUX = disabled

#同步時(shí)間
yum -y install ntpdate
ntpdate times.aliyun.com

#安裝epel源
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
#備用地址:https://www.ucblog.net/wzfou/epel-release-6-8.noarch.rpm

#安裝rrdtool與依賴庫
yum -y install perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping  httpd httpd-devel gcc make  wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi mod_ssl git bind-utils fping

#安裝中文字體
yum -y install wqy-zenhei-fonts #DNS需要用到TCPPing命令,安裝方法如下: 首先安裝tcptraceroute: yum install tcptraceroute 然后下載: wget http://www.vdberg.org/~richard/tcpping 賦予權(quán)限后移動(dòng)到/usr/bin目錄下即可使用: chmod 755 tcpping mv tcpping /usr/bin/ 經(jīng)過測試,發(fā)現(xiàn)tcpping的IP必須要有80服務(wù)才行

安裝過程中可能會(huì)出現(xiàn)某個(gè)依賴找不到情況,一般影響不大,你只要在下面的操作中能夠正常進(jìn)行就可以了。

Smokeping成功安裝

二、下載Smokeping安裝并配置

執(zhí)行以下命令開始安裝Smokeping:

wget http://oss.oetiker.ch/smokeping/pub/smokeping-2.6.9.tar.gz
tar zxvf smokeping-2.6.9.tar.gz
cd smokeping-2.6.9
./configure --prefix=/usr/local/smokeping
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
#備用地址:https://www.ucblog.net/wzfou/smokeping-2.6.9.tar.gz

安裝過程中,可能會(huì)出現(xiàn)下面的提示:
** 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 /usr/local/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

#這是因?yàn)槿鄙傧鄳?yīng)的perl模塊,直接按照提示執(zhí)行:
./setup/build-perl-modules.sh /usr/local/smokeping/thirdparty
#繼續(xù)執(zhí)行操作:
./configure --prefix=/usr/local/smokeping
/usr/bin/gmake install

執(zhí)行以下命令開始配置Smokeping:

#創(chuàng)建 cache、data、var 數(shù)據(jù)目錄
cd /usr/local/smokeping
mkdir cache data var

#創(chuàng)建日志
touch /var/log/smokeping.log

#授權(quán)
chown apache:apache cache data var
chown apache:apache /var/log/smokeping.log

#修改配置文件
cd /usr/local/smokeping/htdocs/
mv smokeping.fcgi.dist smokeping.fcgi
cd /usr/local/smokeping/etc
mv config.dist config

#vim config
#cgiurl = http://some.url/smokeping.cgi
...
#step = 300
#ping = 5

你可以用Vim打開config文件,或者自己使用SFTP登錄用編輯器打開config文件,此處你需要修改一下cgiurl,替換成你的IP或者域名,詳細(xì)的config請看下一部分。

Smokeping修改域名地址

最后,給密碼文件賦予權(quán)限:

chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

三、安裝Apache并配置Smokeping

剛才我們通過Yum的方法已經(jīng)安裝好了Apache,這里我們需要修改Apache的配置文件,將IP或者域名調(diào)整訪問到Smokeping路徑,命令如下:

vim /etc/httpd/conf/httpd.conf
#在最后添加以下內(nèi)容
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
Order allow,deny
Allow from all
DirectoryIndex smokeping.fcgi
</Directory>

#######################################################
#如果你想讓你的Smokeping訪問不公開,你可以設(shè)置訪問密碼
vim /etc/httpd/conf/httpd.conf
Alias /cache "/usr/local/smokeping/cache/"
Alias /cropper "/usr/local/smokeping/htdocs/cropper/"
Alias /smokeping "/usr/local/smokeping/htdocs/smokeping.fcgi"
<Directory "/usr/local/smokeping">
AllowOverride None
Options All
AddHandler cgi-script .fcgi .cgi
AllowOverride AuthConfig
Order allow,deny
Allow from all
AuthName "Smokeping"
AuthType Basic
AuthUserFile /usr/local/smokeping/htdocs/htpasswd
Require valid-user
DirectoryIndex smokeping.fcgi
</Directory>
#再執(zhí)行設(shè)置密碼
htpasswd -c /usr/local/smokeping/htdocs/htpasswd admin

以上你可以用Vim命令,也可以自己用編輯器將配置文件下載到本地進(jìn)行編輯。

Smokeping重新編輯

設(shè)置 Smokeping、Apache 開機(jī)啟動(dòng):

echo "/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log 2>&1 &" >> /etc/rc.local
chkconfig httpd on

四、 Smokeping啟動(dòng)和遇到的問題

執(zhí)行以下命令即啟動(dòng) Smokeping:

/etc/init.d/httpd start
/usr/local/smokeping/bin/smokeping --logfile=/var/log/smokeping.log2>&1&

打開你的瀏覽器訪問:ip或者域名/smokeping,你就可以看到Smokeping默認(rèn)的界面了。

Smokeping默認(rèn)界面

4.1? Smokeping支持中文問題

默認(rèn)的Smokeping顯示中文會(huì)亂碼,我們剛剛在上面給Linux安裝了中文字體,現(xiàn)在執(zhí)行:vim /usr/local/smokeping/lib/Smokeping/Graphs.pm,在'--end', $tasks[0][2],增加一行字體配置部分('--font', "TITLE:20:WenQuanYi Zen Hei Mono",),如下:

...
    if ($mode =~ /[anc]/){
        my $val = 0;
        for my $host (@hosts){
            my ($graphret,$xs,$ys) = RRDs::graph
            ("dummy",
            '--start', $tasks[0][1],
            '--end', $tasks[0][2],
            '--font', "TITLE:20:WenQuanYi Zen Hei Mono",
            "DEF:maxping=$cfg->{General}{datadir}${host}.rrd:median:AVERAGE",
            'PRINT:maxping:MAX:%le' );
            my $ERROR = RRDs::error();
            return "RRDtool did not understand your input: $ERROR." if $ERROR;
            $val = $graphret->[0] if $val < $graphret->[0];
        }
        $val = 1e-6 if $val =~ /nan/i;
        $max = { $tasks[0][1] => $val * 1.5 };
    }
...

如下圖設(shè)置:

Smokeping支持中文

然后,執(zhí)行:vim /usr/local/smokeping/etc/config,增加一行代碼charset= utf-8,如下:

...
***Presentation ***
charset= utf-8
template = /usr/local/smokeping/etc/basepage.html.dist
...

4.2? Smokeping域名訪問及SSL證書

如果你不想讓Smokeping訪問時(shí)帶上/Smokeping這么一個(gè)尾巴,你可在Apache配置中修改如下:

Alias / "/usr/local/smokeping/htdocs/smokeping.fcgi" 

給域名添加SSL證書也很簡單,首先為你的域名申請一個(gè)SSL證書,阿里云、騰訊云等都提供了免費(fèi)一年的SSL證書可供申請。傲盾互聯(lián)的虛擬主機(jī)都有免費(fèi)的SSL證書。

Smokeping申請免費(fèi)SSL

剛才我們已經(jīng)通過Yum的方式安裝了mod_ssl,現(xiàn)在你可以進(jìn)入到:/etc/httpd/conf.d,然后替換你的Key、CRT、CA路徑,找到如下代碼(注意你的證書路徑):

#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/domain.crt

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/certs/domain.key

#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
#   certificates for client authentication or alternatively one
#   huge file containing all of them (file must be PEM encoded)
SSLCACertificateFile /etc/pki/tls/certs/domainca.crt

請將你下載下來的CA根證書、CRT域名證書和密鑰Key上傳到/etc/pki/tls/certs/目錄,然后將上面的三個(gè)路徑進(jìn)行替換。最后重啟Apache,就可以看到SSL證書生效了。

Smokeping證書生效

4.3? Smokeping不顯示數(shù)據(jù)的問題

這個(gè)問題一般是由于目錄權(quán)限導(dǎo)致的,你可以查看Apache日志錯(cuò)誤提示,同時(shí)保持cache data var這三個(gè)文件夾里面生成的文件屬性為可讀寫且擁有者為:apache:apache。

Smokeping讀寫權(quán)限

五、Smokeping模板及Config配置詳解

Smokeping模板文件basepage.html.dist。在basepage.html.dist里你可以修改Smokeping的CSS樣式、增加Html內(nèi)容(包括圖片、文字)、修改標(biāo)題鏈接等等。

Smokeping修改模板

Smokeping Config配置文件詳解,相關(guān)的中文說明如下:


*** General ***                                               ##全局配置
owner    = charlie.cui@zerounix.com                           ##聯(lián)系人(顯示在網(wǎng)頁上)
contact  = charlie.cui@zerounix.com                           ##聯(lián)系人郵箱
mailhost = mail.zerounix.com                                  ##郵件服務(wù)主機(jī)
sendmail = /usr/sbin/sendmail                                 ##發(fā)送郵件件的二進(jìn)制可執(zhí)行程序
# 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 = /usr/local/smokeping/cache                         ##生成圖片的緩存
imgurl   = cache                                              ##cache 定義cgi程序顯示圖片的url目錄
datadir  = /usr/local/smokeping/data                          ##rrd文件的位置
piddir  = /usr/local/smokeping/var
cgiurl   = http://some.url/smokeping.cgi                      ##smokeping訪問地址
smokemail = /usr/local/smokeping/etc/smokemail                ##發(fā)送郵件的郵件內(nèi)容模板
tmail = /usr/local/smokeping/etc/tmail                        ##HTML郵件模板的路徑
# specify this to get syslog logging
syslogfacility = local0                                       ##syslog日志記錄的設(shè)備編號(hào)
# each probe is now run in its own process
# disable this to revert to the old behaviour
# concurrentprobes = no

*** Alerts ***                                                ##報(bào)警配置
to =  monitor@zerounix.com                                    
from = mon@zerounix.com

+網(wǎng)絡(luò)中斷
type = rtt
pattern = !=U,==U
comment = 網(wǎng)絡(luò)中斷
priority = 1

+中斷恢復(fù)
type = rtt
pattern = ==U,!=U,!=U
comment = 中斷恢復(fù)
priority = 2

+嚴(yán)重丟包
type = loss
pattern = >50%
comment = 丟包大于50%
priority = 3

+丟包報(bào)警
type = loss
pattern = >10%,>10%,>10%
comment = 連續(xù)3次丟包10%以上
priority = 4

+網(wǎng)絡(luò)延遲
type = rtt
pattern = >180,>180,>180
comment = 連續(xù)3次延時(shí)180以上
priority = 5

*** Database ***
step     = 60
pings    = 10

# 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 = /tmp/smokeping-31631-build/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/local/sbin/fping

+ DNS
binary = /usr/bin/dig
lookup = name.example
*** Slaves ***   ##“從”服務(wù)器設(shè)置
secrets=/usr/local/smokeping/etc/smokeping_secrets
+boomer
display_name=boomer
color=0000ff

+slave2
display_name=another
color=00ff00

*** Targets ***   ##監(jiān)控目標(biāo)

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

添加監(jiān)控目標(biāo)。*** Targets ***監(jiān)控主機(jī)是分層結(jié)構(gòu),用+表示,例如第一層“+”,第二層“++”一次類推。這里給出一個(gè)從本地Ping到三大網(wǎng)絡(luò)并返回?cái)?shù)據(jù)的示例代碼:

+ Other
menu = 三大網(wǎng)絡(luò)監(jiān)控
title = 監(jiān)控統(tǒng)計(jì)
++ dianxin
menu = 電信網(wǎng)絡(luò)監(jiān)控
title = 電信網(wǎng)絡(luò)監(jiān)控列表
host = /Other/dianxin/dianxin-bj /Other/dianxin/dianxin-hlj /Other/dianxin/dianxin-tj /Other/dianxin/dianxin-sc /Other/dianxin/dianxin-sh /Other/dianxin/dianxin-gz
+++ dianxin-bj
menu = 北京電信
title = 北京電信
alerts = someloss
host = 202.96.199.133

+++ dianxin-hlj
menu = 黑龍江電信
title = 黑龍江電信
alerts = someloss
host = 219.147.198.242

+++ dianxin-tj
menu = 天津電信
title = 天津電信
alerts = someloss
host = 219.150.32.132

+++ dianxin-sc
menu = 四川電信
title = 四川電信
alerts = someloss
host = 61.139.2.69

+++ dianxin-sh
menu = 上海電信
title = 上海電信
alerts = someloss
host = 116.228.111.118

+++ dianxin-gz
menu = 廣東電信
title = 廣東電信
alerts = someloss
host = 113.111.211.22

++ liantong
menu = 聯(lián)通網(wǎng)絡(luò)監(jiān)控
title = 聯(lián)通網(wǎng)絡(luò)監(jiān)控列表
host = /Other/liantong/liantong-bj /Other/liantong/liantong-hlj /Other/liantong/liantong-tj /Other/liantong/liantong-sc /Other/liantong/liantong-sh /Other/liantong/liantong-gz

+++ liantong-bj
menu = 北京聯(lián)通
title = 北京聯(lián)通
alerts = someloss
host = 61.135.169.121

+++ liantong-hlj
menu = 黑龍江聯(lián)通
title = 黑龍江聯(lián)通
alerts = someloss
host = 202.97.224.69

+++ liantong-tj
menu = 天津聯(lián)通
title = 天津聯(lián)通
alerts = someloss
host = 202.99.96.68

+++ liantong-sc
menu = 四川聯(lián)通
title = 四川聯(lián)通
alerts = someloss
host = 119.6.6.6

+++ liantong-sh
menu = 上海聯(lián)通
title = 上海聯(lián)通
alerts = someloss
host = 210.22.84.3

+++ liantong-gz
menu = 廣東聯(lián)通
title = 廣東聯(lián)通
alerts = someloss
host = 221.5.88.88

++ yidong
menu = 移動(dòng)網(wǎng)絡(luò)監(jiān)控
title = 移動(dòng)網(wǎng)絡(luò)監(jiān)控列表
host = /Other/yidong/yidong-bj /Other/yidong/yidong-hlj /Other/yidong/yidong-tj /Other/yidong/yidong-sc /Other/yidong/yidong-sh /Other/yidong/yidong-gz 

+++ yidong-bj
menu = 北京移動(dòng)
title = 北京移動(dòng)
alerts = someloss
host = 221.130.33.52

+++ yidong-hlj
menu = 黑龍江移動(dòng)
title = 黑龍江移動(dòng)
alerts = someloss
host = 211.137.241.35

+++ yidong-tj
menu = 天津移動(dòng)
title = 天津移動(dòng)
alerts = someloss
host = 211.137.160.5

+++ yidong-sc
menu = 四川移動(dòng)
title = 四川移動(dòng)
alerts = someloss
host = 218.201.4.3

+++ yidong-sh
menu = 上海移動(dòng)
title = 上海移動(dòng)
alerts = someloss
host = 117.131.19.23

+++ yidong-gz
menu = 廣東移動(dòng)
title = 廣東移動(dòng)
alerts = someloss
host = 211.136.192.6

六、Smokeping主從服務(wù)器分布式部署

上面我們在配置文件中看到了:*** Slaves *** ,這就是部署主從服務(wù)器用的。說明如下:

*** Slaves ***
secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
# 定義通信用的秘鑰文件,里面包含slave的名字以及對應(yīng)密碼
+ wzfou # slave的名字
display_name=挖站否 # slave的別名
location=杭州電信機(jī)房 # 這個(gè)字段用來定義slave主機(jī)的位置,類似于description
color=0000ff # slave收集的數(shù)據(jù)在圖像中顯示的顏色

6.1? Smokeping主服務(wù)器設(shè)置

先按照上面的方法部署好主服務(wù)器Smokeping,然后修改smokeping_secrets.dist里面的內(nèi)容,如下圖設(shè)置好Slave名稱和密碼:

Smokeping設(shè)置好密碼

通信用的秘鑰文件內(nèi)容為“slave的名字:密碼”,這里需要注意秘鑰文件的權(quán)限,由于smokeping的master/slave是通過smokeping程序進(jìn)行驗(yàn)證的,所以這個(gè)秘鑰文件owner必須是smokeping進(jìn)程的運(yùn)行用戶身份,并且權(quán)限為600。命令如下:

chown apache:apache /usr/local/smokeping/etc/smokeping_secrets.dist
chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

接著,將定義的Slave節(jié)點(diǎn)分配給你需要監(jiān)控的主機(jī),如下說明:

*** Targets ***
++ changzhou ## 一級(jí)菜單,這個(gè)值將會(huì)作為data下的一個(gè)目錄名被創(chuàng)建 
menu = 常州機(jī)房 ## 定義web上顯示的菜單名
title = 常州機(jī)房  ## 標(biāo)題名稱

+++ dianxin ## 監(jiān)控主機(jī),數(shù)據(jù)將會(huì)被存放在 data/changzhou/dianxin目錄下
menu = 電信機(jī)房 ## web上顯示的名稱 
title = 電信機(jī)房監(jiān)控  ##網(wǎng)頁標(biāo)題
alerts = someloss ## 報(bào)警
slaves = wzfou ## slave節(jié)點(diǎn) 
host = wzfou.com  ## 被監(jiān)控的主機(jī)IP或者域名 

從上面的配置我們可以看出關(guān)鍵地方是要在*** Targets *** 中添加一行:slaves = wzfou ## slave節(jié)點(diǎn),表示slaves 會(huì)像主服務(wù)器一樣在此目標(biāo)展開監(jiān)控。

6.2? Smokeping從服務(wù)器設(shè)置

請按照上文的方法在從服務(wù)器中配置好Smokeping,不需要任何配置,也不需要修改Apache配置,只要保證Smokeping正常安裝并運(yùn)行即可。Smokeping啟動(dòng)從服務(wù)器有幾個(gè)參數(shù)需要了解:

–master-url:當(dāng)smokeping運(yùn)行在slave模式下,使用該項(xiàng)指定master的訪問url(web接口,用以通信)

–slave-name:默認(rèn)情況下,不指定此項(xiàng)時(shí),slave連接到master后,master會(huì)以slave的hostname作為slavename,如果不希望這樣做,就需要手動(dòng)指定改選項(xiàng)

–shared-secret:和master通信認(rèn)證的密碼文件

–cache-dir:當(dāng)smokeping運(yùn)行在slave模式下,臨時(shí)數(shù)據(jù)存放在master上的目錄路徑

–pid-dir:slave模式下,其pid存放的目錄路徑。可選參數(shù),默認(rèn)繼承–cache-dir參數(shù)的值

同樣的,確保你的Smokeping從服務(wù)器的smokeping_secrets.dist文件owner是smokeping進(jìn)程的運(yùn)行用戶身份,并且權(quán)限為600,且從服務(wù)器的smokeping_secrets.dist中只要寫密碼,這一點(diǎn)和主服務(wù)器不同。

這是我的Smokeping從服務(wù)器啟動(dòng)命令示例(需要注意的就是替換slave的名稱):

/usr/local/smokeping/bin/smokeping --master-url=https://ping.wzfou.com/ --cache-dir=/usr/local/smokeping/cache/ --shared-secret=/usr/local/smokeping/etc/smokeping_secrets.dist --slave-name=wzfou --logfile=/var/log/smokeping_slave.logCopy

七、總結(jié)

Smokeping真的是一個(gè)非常強(qiáng)大的網(wǎng)絡(luò)性能監(jiān)控工具,效果可以查看:ping.wzfou.com。Smokeping還有不少的探針可供使用,例如Ping、DNS、Curl、Https、SMTP、FTP、TCP、LDAP等,甚至還有不少的插件可以自己安裝并開發(fā)。(點(diǎn)擊放大)

Smokeping演示效果

這是Smokeping的圖表,非常直觀,且容易看懂。(點(diǎn)擊放大)

Smokeping直觀圖表

文件權(quán)限問題。這是一個(gè)很容易出現(xiàn)問題的地方,修改了config文件后都會(huì)在data\cache\var中產(chǎn)生數(shù)據(jù),如果文件權(quán)限不是apache將直接導(dǎo)致rrd文件不更新,web頁面沒有圖像,或者web頁面有圖像但沒有數(shù)據(jù)。

Smokeping沒有數(shù)據(jù)返回

你可以在在服務(wù)器執(zhí)行以下命令解決問題:

pkill smokeping
chown -R apache:apache /usr/local/smokeping/data
chown -R apache:apache /usr/local/smokeping/cache

/etc/init.d/httpd restart  ##重啟Apache
/usr/local/smokeping/bin/smokeping --reload 

重啟smokeping。每次修改配置文件后需要重啟smokeping進(jìn)程,否則會(huì)出現(xiàn)各種問題。重啟smokeping命令如下:

/usr/local/smokeping/bin/smokeping --restart

或

/usr/local/smokeping/bin/smokeping --reload

或

pkill smokeping
/usr/local/smokeping/bin/smokeping

master/slave服務(wù)器沒有數(shù)據(jù)。對于master/slave的架構(gòu),首先確保slave-name和master配置文件中配置的slave節(jié)點(diǎn)名以及密鑰文件中的節(jié)點(diǎn)名相對應(yīng)。再查看一下master的密鑰文件(包含slave節(jié)點(diǎn)名和密碼)與slave的密碼文件(只有密碼)是否對應(yīng)。最后就是密鑰屬性權(quán)限一定要是600。

PS:2017年11月11日更新,Smokeping在服務(wù)器網(wǎng)絡(luò)監(jiān)控方面比較出色,但是如果想要對整個(gè)服務(wù)器的內(nèi)存、CPU、連接等指數(shù)進(jìn)行詳細(xì)的監(jiān)控,可以試試企業(yè)級(jí)的Zabbix:Zabbix安裝與使用-強(qiáng)大的服務(wù)器性能監(jiān)控工具掌控服務(wù)器軟硬件資源。

文章出自:挖站否?https://wzfou.com/smokeping/,部分內(nèi)容參考自yufei.im、Ken Lai?版權(quán)所有。本站文章除注明出處外,皆為作者原創(chuàng)文章,可自由引用,但請注明來源。

贊(0)
版權(quán)聲明:本文采用知識(shí)共享 署名4.0國際許可協(xié)議 [BY-NC-SA] 進(jìn)行授權(quán), 轉(zhuǎn)載請注明出處。
文章名稱:《Smokeping安裝與配置-免費(fèi)開源網(wǎng)絡(luò)性能監(jiān)控工具可視化主/從部署》
文章鏈接:http://www.lrracing.com/2711.html
【聲明】:國外主機(jī)測評(píng)僅分享信息,不參與任何交易,也非中介,所有內(nèi)容僅代表個(gè)人觀點(diǎn),均不作直接、間接、法定、約定的保證,讀者購買風(fēng)險(xiǎn)自擔(dān)。一旦您訪問國外主機(jī)測評(píng),即表示您已經(jīng)知曉并接受了此聲明通告。
【關(guān)于安全】:任何 IDC商家都有倒閉和跑路的可能,備份永遠(yuǎn)是最佳選擇,服務(wù)器也是機(jī)器,不勤備份是對自己極不負(fù)責(zé)的表現(xiàn),請保持良好的備份習(xí)慣。