写在前面
- 原以为不会再用到
smokeping
,结果我错了。 - 据上次使用约半年,平常都是1次性用、这次又要用,完全忘干净了。
那么开始
安装
apt-get -y install smokeping
配置服务
- Web服务器的配置参考前面写的 用Nginx跑Shell脚本。
- 探测服务建议将
/etc/init.d/smokeping
里配置的启动用户和Nginx
保持一致,以www-data
为例:
# /etc/init.d/smokeping DAEMON_USER=www-data
- 跑出来的效果大概如下:

数据配置
- 页面模板
/etc/smokeping/basepage.html
,其中的变量来自/etc/smokeping/config.d/General
。 - 数据文件存放路径在
/etc/smokeping/config.d/pathnames
,改路径记得修正目录权限。
# /etc/smokeping/config.d/pathnames sendmail = /usr/sbin/sendmail imgcache = /data/smokeping/htdocs/images imgurl = images datadir = /data/smokeping/libdata piddir = /var/run/smokeping smokemail = /etc/smokeping/smokemail tmail = /etc/smokeping/tmail
- 主配置文件
/etc/smokeping/config
里指定了所引用的配置,如下添加了 HTTP、Ping 的监测任务:
# /etc/smokeping/config @include /etc/smokeping/config.d/General @include /etc/smokeping/config.d/Alerts @include /etc/smokeping/config.d/Database @include /etc/smokeping/config.d/Presentation @include /etc/smokeping/config.d/Probes @include /etc/smokeping/config.d/Slaves @include /etc/smokeping/config.d/Targets @include /etc/smokeping/config.d/HTTP @include /etc/smokeping/config.d/Ping
- 添加一个Ping的探测
/etc/smokeping/config.d/Ping
:
+ demo-intranet-fping probe = FPing menu = 核心机房Fping内网 title = 机房内网Ping ++ demo-bfs-01 menu = demo-bfs-01 title = demo-ops-lvs-02 -> 192.168.1.1 host = 192.168.1.1 ++ demo-cache-01 menu = demo-cache-01 title = demo-ops-lvs-02 -> 192.168.1.5 host = 192.168.1.5 ++ demo-k8s-master-01 menu = demo-k8s-master-01 title = demo-ops-lvs-02 -> 192.168.1.32 host = 192.168.1.32
- 添加一个独立的HTTP监控,
/etc/smokeping/config.d/HTTP
:
+ kisjd-http-curl probe = Curl menu = 监控HTTP响应时间 title = 测试出网的HTTP访问速度 ++ baidu menu = baidu.com title = www.baidu.com host = www.baidu.com ++ bilibili menu = bilibili.com title = www.bilibili.com host = www.bilibili.com ++ youku menu = youku.com title = www.youku.com host = www.youku.com ++ iqiyi menu = iqiyi.com title = www.iqiyi.com host = www.iqiyi.com
- 配置文件
/etc/smokeping/config.d/Probes
中指定了探测方法,示例:
*** Probes *** + AnotherSSH forks = 24 offset = 90% greeting = SSH-2.0-OpenSSH_Smokeping interval = complete mininterval = 0.8 + Curl binary = /usr/bin/curl forks = 24 offset = 90% agent = User-Agent: Smokeping/2.6.9 expect = OK extraargs = -4 --head extrare = / / follow_redirects = no include_redirects = no insecure_ssl = 1 interface = bond0 timeout = 20 urlformat = http://%host%/ + FPing binary = /usr/bin/fping blazemode = true hostinterval = 1.5 mininterval = 0.001 offset = 50% packetsize = 5000 pings = 20 sourceaddress = 10.130.1.73 step = 300 timeout = 1.5 tos = 0x20 usestdout = true
- 默认概览在配置文件
/etc/smokeping/config.d/Presentation
中设定,如下添加了各多维度的数据供参考:
# /etc/smokeping/config.d/Presentation *** Presentation *** template = /etc/smokeping/basepage.html charset = utf-8 + charts menu = 质量排行榜 title = 质量最差的排行榜 ++ stddev sorter = StdDev(entries=>4) title = 响应时间方差排行 - top4 menu = 响应时间方差 format = Standard Deviation %f ++ max sorter = Max(entries=>5) title = 最大响应时间排行 - top5 menu = 最大响应时间 format = Max Roundtrip Time %f seconds ++ loss sorter = Loss(entries=>5) title = 稳定性最差的排行 - top5 menu = 稳定性 format = Packets Lost %f ++ median sorter = Median(entries=>5) title = 平均响应时间最差的排行 - top5 menu = 平均响应时间 format = Median RTT %f seconds + overview width = 800 height = 50 range = 24h + detail width = 800 height = 200 unison_tolerance = 2 "Last 5 minutes" 5m "Last 10 minutes" 10m "Last 30 minutes" 30m "Last 1 Hours" 1h "Last 3 Hours" 3h "Last 12 Hours" 12h "Last 1 Days" 1d "Last 7 Days" 7d "Last 30 Days" 30d