CentOS 6.5下Smokeping配置 - 基础文章 -(文章二)

前面教了大家SmokePing的安装,今天教大家如何配置Smokeping并监控主机或者服务器等。

首先教大家认识一下Smokeping默认的config文件。

下面开始讲解,整个config文件只有#是注释

第一部分*** General ***部分,这里面都是一些基础配置,值得注意的地方有imgcache和imgurl这两个参数,如果配置不好,打开web的时候图片会显示不出来。

*** General ***

owner    = Linux - me 监控系统          //这个是主人名称
contact  = some@address.nowhere        //这个是联系人邮箱
mailhost = my.mail.host                //这里是邮箱主机,比如mail.163.com
sendmail = /usr/sbin/sendmail          //这里是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
cgiurl   = http://192.168.1.10/smokeping.cgi  //这个是做主从分布式系统的时候需要用到
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 ***报警配置,这个我也没有用过,因为主要是监控全国网络,我也没有使用报警,以后再看看吧.

*** 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 RRD数据库配置,step和ping参数需要在smokeping启动前配置好,默认是step=300 ping=20,意思是300s内执行20次ping,这里我改成60s执行20次ping。

*** Database ***
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 是关于网络状态的一些配置和解释,基本不需要更改,如果smokeping启动后乱码的话在下面添加红色部分。

*** Presentation ***
template = /usr/local/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 = 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的路径。

*** Probes ***
+ FPing
binary = /usr/sbin/fping
#binary = /usr/local/sbin/fping

第六部分是Slaves 主从关系里面的从服务器相关配置

*** Slaves ***
secrets=/usr/local/smokeping/etc/smokeping_secrets.dist
+boomer
display_name=boomer
color=0000ff

+slave2
display_name=another
color=00ff00

最后就是Targets 目标配置,在这里可以配置单独一台服务器监控情况,也可以配置多台服务器监控情况,就是主从模式,这里要注意以下:+代表一级目录 +下面的++继承上面的+成为二级目录.并且可以有多个一级菜单和二级菜单。

*** 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= Targets
#parents = owner:/Test/James location:/
++ James
menu = James
title =James
alerts = someloss
slaves = boomer slave2
host = james.address

好了下面我就教大家监控一台服务器吧.这里监控的主机可以是域名,同时也可以是IP地址,我这里直接监控www.qq.com给大家做演示

+ test1
menu = 测试一级目录
title = 测试一级目录

++test1-1
menu = 测试二级目录-1
title = 测试二级目录腾讯
host = www.qq.com

++test1-2
menu = 测试二级目录-2
title = 测试二级目录百度
host = www.baidu.com

修改完配置文件后记得需要重启Smokeping.

[root@localhost etc]# ps -ef | grep smokeping
root       1568      1  0 10:53 ?        00:00:00 /usr/local/smokeping/bin/smokeping [FPing]
root       2158   1434  0 12:05 pts/0    00:00:00 grep smokeping
[root@localhost etc]# kill 1568
[root@localhost etc]# /usr/local/smokeping/bin/smokeping &
Note: logging to syslog as local0/info.
Daemonizing /usr/local/smokeping/bin/smokeping ...

然后我们访问网页看看。刚开始肯定没数据,需要等一下

CentOS 6.5下Smokeping配置 – 基础文章 -(文章二)-Linux-me

Smokping目录测试