三:配置
1,配置smokpeing
General是基本配置。(imgcache和imgurl两个参数,和NGINX配置相关联,如果没有配置好, smokeping web页面图片显示不出来。)
root@debian:/etc/smokeping/config.d# vi /etc/smokeping/config.d/General
*** General ***
# Please edit this to suit your installation
owner = rui.tong@wushen.com (联系邮箱)
contact = rui.tong@wushen.com
cgiurl = http://10.0.0.1:50032/smokeping.fcgi
imgcache = /usr/share/smokeping/www/cache (手动自己创建smokpeing缓存目录)
imgurl = cache
datadir = /usr/share/smokeping/www/var (手动自己创建)
piddir = /usr/share/smokeping/www/var (手动自己创建)
mailhost = gls
smokemail = /usr/share/smokeping/etc/smokemail.dist
tmail = /usr/share/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是报警配置,这个目前没有用到,所以没有测试。
Database是RRD数据库配置,Step和pings这两个参数要在启动smokeping之前配置好,如果在smokeping启动后再配置这两个参数,需要把原来的rrd文件都删除,然后再启动smokeping才可以。所以这个一定要先配置好。默认是step=300 pings=20 应该是每300s内执行20次ping的动作。这里默认配置就可以了。
*** Database ***
step = 300
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是网络状态的一些配置,默认就OK了。
Probes是指针的配置,我用的是Fping,确定一下路劲是否正确?
*** Probes ***
+ FPing
binary = /usr/bin/fping
Slaves是主从配置,很重要,这里我就简单配置两台、
# *** Slaves ***
#
## make sure this is not world-readable!
## secrets=/etc/smokeping/slave-secrets
#
# display_name=slave_name
# color=0000ff
*** Slaves ***
secrets=/usr/share/smokeping/etc/smokeping_secrets.dist (这个文件要手动创建)
+ 10.0.0.1
display_name = 10.0.0.1
color = 0000ff (color设置页面上监控rrdtool流量图的颜色,后面参数代码任意配置)
+ 10.0.0.2
display_name = 10.0.0.2
color = 00ff00
+ 10.0.0.3
display_name = 10.0.0.3
color = ff0000
手动创建smokeping_secrets.dist文件,格式一定要如下!Slave端的IP,"root"是主从关联的密码,这个随意写。
vi /usr/share/smokeping/etc/smokeping_secrets.dist
10.0.0.1:root
10.0.0.2:root
Targets是目标的配置,从slave服务器上取值的配置在这里配置,如果不是做主从的话,单独配置几台服务器的监控情况也在这里配置。(这里跟slaves目标主机要对应起来!!)
root@debian:/etc/smokeping/config.d# vi Targets
*** Targets ***
probe = FPing
# You have to edit and uncomment all what you want below this.
# # Please, refer to smokeping_config man page for more info
# # The given adresses aren't real to avoid DoS.
menu = Top
title = Network Latency Grapher
remark = 欢迎使用武神smokeping
+ Local
+ Slaves
menu = 全国各数据中心
title = 运维Smokeping
++ beijing
menu = 北京XX
title = Host 北京XX Monitor From Slaves
slaves = 10.0.0.2
host = 10.0.0.1
++ nanjing
menu = 杭州XX
title = Host 杭州XX Monitor From Slaves
slaves = 10.0.0.1
host = 10.0.0.2
相关的smokeping都配置完了
主/从 做分布式监控的时候有几点需要注意
1.主从服务器上面的密码文件权限必须为600 而且主服务器上面的密码文件的属主必须为NGINX的启动用户
2.从服务器上面的密码文件只需要一个密码就行,也就是主上面为它配置的那个密码。同样从服务器上面的密码文件的属主必须为smokeping的启动用户
2:启动smokeping
root@debian:~# /etc/init.d/smokeping restart
3:配置从服务器
从服务器的配置参照上面主服务器的配置,NGINX不用配置,smokeping也不需要配置,因为slaves不需要config的配置!
手动创建smokeping_secrets.dist(密码!)
root@debian:~# vi /usr/share/smokeping/etc/smokeping_secrets.dist
root
Slave端以slave方式启动!前提是master端上的smokeping已经启动,这样slave启动是才能获取到master的数据,不然slave启动时会报错。
root@debian:~# /usr/sbin/smokeping --master-url=http://10.0.0.1:80/smokeping.fcgi --cache-dir=/usr/share/smokeping/www/cache --shared-secret=/usr/share/smokeping/etc/smokeping_secrets.dist --slave-name=10.0.0.2 (cache手动创建)
全部安装配置完,访问页面http://10.0.0.1:80/smokeping.fcgi (此图)
如果数据获取不到,在master端smokeping路径下cache和var下是否有文件生成,如果没有,查看smokeping目录下的权限是否正确,并结合smokeping debug log 和 NGINX error log 来排查问题!

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里
php脚本解析nginx日志 http://www.linuxidc.com/Linux/2013-02/78921.htm
Nginx日志切割和记录cookie http://www.linuxidc.com/Linux/2013-01/77392.htm
用cronolog分割Nginx日志 http://www.linuxidc.com/Linux/2012-11/75154.htm
Linux下每天自动备份Nginx日志 http://www.linuxidc.com/Linux/2011-09/44184.htm
