SmokePing 延迟监控工具教程
SmokePing 是由 RRDtool 作者 Tobias Oetiker 开发的网络延迟监控工具,它通过持续发送探测包来测量网络延迟和丢包率,并生成标志性的烟雾状(Smoke)延迟分布图。这种可视化方式可以直观地展示网络质量的稳定性:烟雾越浓说明延迟抖动越大,颜色越深说明丢包越严重。SmokePing 非常适合在搬瓦工 VPS 上部署,用于长期监控到各地的网络质量。
一、安装 SmokePing
1.1 在 Ubuntu/Debian 上安装
apt update
apt install smokeping apache2 -y
安装过程中会自动配置 Apache 和 CGI 模块。安装完成后,SmokePing 会自动启动并开始采集数据。
1.2 启动服务
systemctl enable smokeping
systemctl start smokeping
systemctl status smokeping
# 启用 Apache CGI 模块
a2enmod cgi
systemctl restart apache2
1.3 验证安装
打开浏览器访问 http://你的服务器IP/smokeping/smokeping.cgi 即可看到 SmokePing 的 Web 界面。
二、配置监控目标
SmokePing 的主配置文件位于 /etc/smokeping/config.d/ 目录下,采用模块化配置。
2.1 配置基本信息
# 编辑通用配置
nano /etc/smokeping/config.d/General
# 主要修改项:
# owner = Your Name
# contact = admin@example.com
# mailhost = localhost
# cgiurl = http://your-server-ip/smokeping/smokeping.cgi
2.2 添加监控目标
# 编辑目标配置
nano /etc/smokeping/config.d/Targets
配置示例:
*** Targets ***
probe = FPing
menu = Top
title = SmokePing 网络延迟监控
remark = 搬瓦工 VPS 网络质量监控平台
+ InternetSites
menu = 互联网站点
title = 常用互联网站点
++ Google
menu = Google DNS
title = Google DNS (8.8.8.8)
host = 8.8.8.8
++ Cloudflare
menu = Cloudflare DNS
title = Cloudflare DNS (1.1.1.1)
host = 1.1.1.1
++ AliDNS
menu = 阿里 DNS
title = 阿里公共 DNS (223.5.5.5)
host = 223.5.5.5
+ ChinaISP
menu = 中国运营商
title = 中国三大运营商
++ ChinaTelecom
menu = 中国电信
title = 中国电信
host = 202.96.209.133
++ ChinaUnicom
menu = 中国联通
title = 中国联通
host = 221.6.4.66
++ ChinaMobile
menu = 中国移动
title = 中国移动
host = 221.179.155.161
+ Datacenters
menu = 数据中心
title = 各地数据中心
++ Tokyo
menu = 东京
title = 东京数据中心
host = 103.6.84.1
++ Singapore
menu = 新加坡
title = 新加坡数据中心
host = 103.6.85.1
2.3 重启 SmokePing
systemctl restart smokeping
三、配置探测方式
3.1 FPing 探测(默认)
# 编辑探测器配置
nano /etc/smokeping/config.d/Probes
*** Probes ***
+ FPing
binary = /usr/bin/fping
blazemode = true
packetsize = 56
3.2 添加 DNS 探测
+ DNS
binary = /usr/bin/dig
lookup = google.com
pings = 5
step = 300
3.3 添加 HTTP 探测
+ Curl
binary = /usr/bin/curl
step = 300
urlformat = http://%host%/
pings = 5
四、配置告警
# 编辑告警配置
nano /etc/smokeping/config.d/Alerts
*** Alerts ***
to = admin@example.com
from = smokeping@example.com
+ lossy
type = loss
pattern = >0%,*12*,>0%,*12*,>0%
comment = 持续丢包告警
+ highlatency
type = rtt
pattern = >200,>200,>200
comment = 高延迟告警(连续 3 次超过 200ms)
+ someloss
type = loss
pattern = >10%
comment = 丢包率超过 10%
五、使用 Docker 部署
# 使用 Docker 一键部署 SmokePing
docker run -d \
--name=smokeping \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Asia/Shanghai \
-p 8080:80 \
-v /opt/smokeping/config:/config \
-v /opt/smokeping/data:/data \
--restart unless-stopped \
lscr.io/linuxserver/smokeping:latest
Docker 版本的配置文件位于 /opt/smokeping/config/ 目录中,修改方式与原生安装相同。
六、自定义图表样式
# 编辑展示配置
nano /etc/smokeping/config.d/Presentation
*** Presentation ***
template = /etc/smokeping/basepage.html
+ charts
menu = 图表
title = 延迟最高的目标
++ stddev
sorter = StdDev(entries=>4)
title = 抖动最大
menu = 抖动排行
format = 标准差 %f
++ max
sorter = Max(entries=>5)
title = 延迟最高
menu = 延迟排行
format = 最大延迟 %f
++ loss
sorter = Loss(entries=>5)
title = 丢包最多
menu = 丢包排行
format = 丢包率 %f
七、Nginx 反向代理配置
server {
listen 80;
server_name smokeping.example.com;
location /smokeping/ {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location = /smokeping/smokeping.cgi {
fastcgi_pass unix:/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/smokeping.cgi;
include fastcgi_params;
}
}
八、常见问题
8.1 图表不显示数据
SmokePing 需要运行一段时间后才会有足够的数据生成图表。通常需要等待 5-10 分钟才能看到第一批数据。检查 RRD 数据文件是否正常生成:
ls -la /var/lib/smokeping/
8.2 fping 权限问题
# 设置 fping 的 setuid 权限
chmod u+s /usr/bin/fping
总结
SmokePing 是长期监控网络延迟质量的最佳工具之一,它独特的烟雾图可以直观展示网络稳定性。在搬瓦工 VPS 上部署 SmokePing 可以帮助你持续追踪到各地的网络质量变化。更全面的网络监控方案可以参考 LibreNMS 网络监控教程。选购搬瓦工 VPS 请参考 全部方案,购买时使用优惠码 NODESEEK2026 可享受 6.77% 的优惠,通过 bwh81.net 进入官网购买。