天天看點

安裝和使用Smokeping(一)

一)簡介

smokeping是對IDC網絡品質,穩定性等最好的檢測工具,包括正常的 ping,dig,echoping,curl等,可以監視www伺服器性能,監視dns查詢性能,監視ssh性能等。底層也是 rrdtool 做支援,特點是畫的圖非常漂亮,網絡丢包和延遲用顔色和陰影來表示。

smokeping的優點:

最佳的畫圖功能,延遲和丢包用顔色和陰影表示很直覺。

免費和開源,作者是MRTG和RRDtool作者。

支援主從的分布式模式。

可以自定義報警功能。

smokeping架構元件:

smokeping 是一個用 perl 寫的程式,是以不需要安裝,但是他需要使用一些工具。Smokeping 有以下元件組成:RRDtool、Fping、Echoping、Curl、Dig、SSh、Perl 子產品,Perl、FCGI、Apache 等。

Smokeping環境:

CentOS7.4 +Smokeping2.6.11

(二)安裝

1,關閉selinux

2,安裝相關依賴的包

<code>[root@localhost tmp]# yum install -y rrdtool wqy* fping gcc echoping curl bind-utils httpd httpd-devel perl perl-FCGI perl-CGI perl-CGI-SpeedyCGI perl-CGI-SpeedyCGI perl-libwww-perl perl-Socket6 perl-Net-Telnet perl-Net-OpenSSH perl-Net-DNS perl-LDAP perl-IO-Socket-SSL perl-ExtUtils-MakeMaker rrdtool-perl perl-Sys-Syslog perl-RadiusPerl perl-Time-HiRes perl-RRD-Simple libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi</code>

4,編譯安裝smokeping

5,配置smokeping

5.1,建立相應的目錄并賦予權限

5.2,備份fcgi檔案與config檔案

*( smokeping七大元件:general(普通設定) 、alerts(警報設定)、Datebase(資料庫參數)、presentation(網絡自定義)、slaves(從smokeping定義)、targets(目标設定——“含插件定義”))

5.4,Alerts和database配置

5.5,presentation配置,添加utf-8字元集和在detail部分,修改曆史資料展示的時間

6,修改賬号檔案權限

[root@localhost smokeping]# chmod 600 /usr/local/smokeping/etc/smokeping_secrets.dist

7,建立登入賬号和密碼

7,設定httpd的通路路徑

8,關閉防火牆

9.設定開機啟動

`[root@localhost smokeping]# echo "/usr/local/smokeping/bin/smokeping &amp;"&gt;&gt; /etc/rc.local``

10,把smokeping做成服務

[root@localhost ~]#chkconfig --add smokeping

[root@localhost ~]#chkconfig smokeping on

[root@localhost ~]# chkconfig --list

Note: This output shows SysV services only and does not include native

systemd services. SysV configuration data might be overridden by native

systemd configuration.

netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off

network 0:off 1:off 2:on 3:on 4:on 5:on 6:off

smokeping 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@localhost ~]# /etc/init.d/smokeping start

Starting smokeping (via systemctl): Warning: smokeping.service changed on disk. Run 'systemctl daemon-reload' to reload units.

[ OK ]

[root@localhost ~]# /etc/init.d/smokeping status

● smokeping.service - SYSV: Smokeping init.d script

Loaded: loaded (/etc/rc.d/init.d/smokeping; bad; vendor preset: disabled)

Active: active (running) since Mon 2018-01-22 11:35:53 CST; 1s ago

Docs: man:systemd-sysv-generator(8)

Process: 31355 ExecStop=/etc/rc.d/init.d/smokeping stop (code=exited, status=0/SUCCESS)

Process: 31386 ExecStart=/etc/rc.d/init.d/smokeping start (code=exited, status=0/SUCCESS)

CGroup: /system.slice/smokeping.service

└─31393 /usr/local/smokeping/bin/smokeping [FPing]

Jan 22 11:35:53 localhost.localdomain systemd[1]: Starting SYSV: Smokeping init.d script...

Jan 22 11:35:53 localhost.localdomain smokeping[31389]: Starting syslog logging

Jan 22 11:35:53 localhost.localdomain smokeping[31393]: Smokeping version 2.006011 successfully launched.

Jan 22 11:35:53 localhost.localdomain smokeping[31393]: Not entering multiprocess mode for just a single probe.

Jan 22 11:35:53 localhost.localdomain smokeping[31393]: FPing: probing 5 targets with step 120 s and offset 110 s.

Jan 22 11:35:53 localhost.localdomain smokeping[31386]: Starting Smokeping: [ OK ]

Jan 22 11:35:53 localhost.localdomain systemd[1]: Started SYSV: Smokeping init.d script.

Warning: smokeping.service changed on disk. Run 'systemctl daemon-reload' to reload units.

備注,以下是常用的配置檔案和使用腳本

############smokeping配置檔案##########

[root@localhost ~]# cat /usr/local/smokeping/etc/config

** General ***

owner = lqb

contact = [email protected]

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 = /usr/local/smokeping/cache

imgurl = cache

datadir = /usr/local/smokeping/data

piddir = /usr/local/smokeping/var

smokemail = /usr/local/smokeping/etc/smokemail.dist

tmail = /usr/local/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 = [email protected]

from = [email protected]

+someloss

type = loss

in percent

pattern = &gt;0%,12,&gt;0%,12,&gt;0%

comment = loss 3 times in a row

新增rtt監測機制

+rttdetect

type = rtt

in milliseconds

pattern = &lt;55,&lt;55,&lt;55,&gt;55,&gt;55,&gt;55

comment = 每次發出60個包,連續3次輪詢檢查延時超過55毫秒

** Database ***

step = 120

pings = 30

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 ***

添加UTF-8中文字元集

charset = utf-8

template = /usr/local/smokeping/etc/basepage.html.dist

charts

menu = Charts

title = The most interesting destinations

++ stddev

sorter = StdDev(entries=&gt;4)

title = Top Standard Deviation

menu = Std Deviation

format = Standard Deviation %f

++ max

sorter = Max(entries=&gt;5)

title = Top Max Roundtrip Time

menu = by Max

format = Max Roundtrip Time %f seconds

++ loss

sorter = Loss(entries=&gt;5)

title = Top Packet Loss

menu = Loss

format = Packets Lost %f

++ median

sorter = Median(entries=&gt;5)

title = Top Median Roundtrip Time

menu = by Median

format = Median RTT %f seconds

overview

width = 600

height = 50

range = 10h

detail

height = 200

unison_tolerance = 2

"Last 2 Minutes" 2m

"Last 30 Minutes" 30m

"Last 4 Hours" 4h

"Last 12 Hours" 12h

"Last 1 Days" 24h

"Last 3 Days" 3d

"Last 1 Weeks" 7d

"Last 1 Mouths" 30d

"Last Half years" 180d

"Last 1 years" 365d 

"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=/usr/local/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 ppdai Company. \

Here you will learn all about the latency of our network.

Test

menu= Targets

parents = owner:/Test/James location:/

++Localhost

menu = Localhost

title = Localhost

alerts = someloss

slaves = boomer slave2

host = 192.168.99.98

Other 

menu = 全國網絡監控

title = 監控統計 

++ dianxin 

menu = 電信網絡監控 

title = 電信網絡監控清單 

host = /Other/dianxin/dianxin-wx /Other/dianxin/dianxin-hf 

+++ dianxin-wx

menu = 無錫監控 

title = 無錫監控 

alerts = someloss 

host = 192.168.15.99

+++ dianxin-hf

menu = 合肥監控

title = 合肥監控

host = 172.21.24.99

+++ dianxin-cs

menu = 長沙監控

title = 長沙監控

host = 172.21.100.12

+++ dianxin-shanghai

menu = 上海監控

title = 上海監控

host = 172.20.66.110

#########smokeping,啟動腳本檔案#########

[root@localhost ~]# cat /etc/init.d/smokeping 

#!/bin/bash

chkconfig: 2345 80 05

Description: Smokeping init.d script

Get function from functions library

. /etc/init.d/functions

Start the service Smokeping

start() {

echo -n "Starting Smokeping: "

/usr/local/smokeping/bin/smokeping &gt;/dev/null 2&gt;&amp;1

Create the lock file ###

touch /var/lock/subsys/smokeping

success $"Smokeping startup"

echo

}

Restart the service Smokeping

stop() {

echo -n "Stopping Smokeping: "

kill -9 <code>ps ax | grep "/usr/local/smokeping/bin/smokeping" | grep -v grep | awk '{ print $1 }'</code> &gt;/dev/null 2&gt;&amp;1

Now, delete the lock file ###

rm -f /var/lock/subsys/smokeping

success $"Smokeping shutdown"

main logic ###

case "$1" in

start)

start

;;

stop)

stop

status)

status smokeping

restart|reload|condrestart)

)

echo $"Usage: $0 {start|stop|restart|reload|status}"

exit 1

esac

exit 0

本文轉自 lqbyz 51CTO部落格,原文連結:http://blog.51cto.com/liqingbiao/2062604

繼續閱讀