天天看点

安装和使用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

继续阅读