--- title: "网络性能监控工具Smokeping-CSDN博客" source: "https://blog.csdn.net/wbsu2004/article/details/120315178" author: - "[[成就一亿技术人!]]" - "[[hope_wisdom 发出的红包]]" published: created: 2025-10-12 description: "文章浏览阅读9.9k次,点赞3次,收藏16次。本文介绍了如何使用开源软件Smokeping监控网络状态,包括延时和丢包率,并详细说明了在群晖系统上通过Docker安装配置的过程。通过配置邮件报警,当网络状况异常时,系统会自动发送通知。文章还提供了配置文件的修改示例,如监控目标、报警条件和邮件设置。" tags: - "clippings" --- 本文介绍了如何使用开源软件Smokeping监控网络状态,包括延时和丢包率,并详细说明了在群晖系统上通过Docker安装配置的过程。通过配置邮件报警,当网络状况异常时,系统会自动发送通知。文章还提供了配置文件的修改示例,如监控目标、报警条件和邮件设置。 ![](https://i-blog.csdnimg.cn/blog_migrate/7658622e23c39d172b0a23ad73d751f5.png) **什么是 Smokeping ?** > `SmokePing` 是一款监控网络状态和稳定性的开源软件(它是 `RRDTool` 的作者开发的),通过它可以监控如延时,丢包率,是否 `BGP` 多线等网络状况;`smokeping` 会向目标设备和系统发送各种类型的测试数据包,测量、记录,并通过图形化地展示网络的时延情况,进而能够清楚的判断出网络的即时通信情况; 可以用于监控群晖主机的网络状态,也可以用于监控多台 `vps` 的运行状态,支持通过邮件报警。 ## 安装 在群晖上以 Docker 方式安装。 在注册表中搜索 `smokeping` ,选择第一个 `linuxserver/smokeping`,版本选择 `latest`。 ![](https://i-blog.csdnimg.cn/blog_migrate/d6de2ece54059678d3e9c965f60b35f4.png) ### 卷 在 `docker` 文件夹中,创建一个新文件夹,并将其命名为 `smokeping`,并在 `smokeping` 中建两个子目录,分别命名为 `config` 和 `data`。 ![](https://i-blog.csdnimg.cn/blog_migrate/983070a93230cd813d173d80e007b051.png) | 文件夹 | 装载路径 | 备注 | | --- | --- | --- | | `/docker/smokeping/data` | `/data` | 数据库和应用数据目录 | | `/docker/smokeping/config` | `/config` | 配置文件目录 | ![](https://i-blog.csdnimg.cn/blog_migrate/6ae7fa56c4427c48491905b67a7287e1.png) ### 端口 端口不能冲突 | 本地端口 | 容器端口 | 类型 | | --- | --- | --- | | 8580 | 80 | TCP | ![](https://i-blog.csdnimg.cn/blog_migrate/ce3edfc578167d1f9550321d519d8f83.png) ### 环境 | 可变 | 值 | | --- | --- | | TZ | 设置为 `Asia/Shanghai` | | PGID | `` 设为 `1000` | | PUID | `` 设为 `1000` | ![](https://i-blog.csdnimg.cn/blog_migrate/6ad9a6da6200ba7bf0a0bc698d1fba48.png) ## 运行 在浏览器中输入 `http://群晖IP:8580`,就能看到主界面了 ![](https://i-blog.csdnimg.cn/blog_migrate/871a6d324b6a4853e425b3efb1a1c3da.png) ### 配置文件 配置文件在 `/docker/smokeping/config` 目录中,知道了用途可以方便后面的修改 | 文件 | 用途 | | --- | --- | | `Alerts` | 报警设置 | | `Database` | 采样频率设置 | | `General` | 常规设置 | | `httpd.conf` | Apache Web 服务器设置 | | `pathnames` | 路径设置 | | `Presentation` | 模板文件 | | `Probes` | 探针设置 | | `Slaves` | 主从模式时,从机设置 | | `ssmtp.conf` | 邮件服务器设置 | | `Targets` | 监控目标设置 | ![](https://i-blog.csdnimg.cn/blog_migrate/507997e50a9cec3565f4471d1722f7af.png) ### Database 打开 `smokeping/config/Database` 文件,全部采用了默认值,也就是 300 秒(5 分钟)ping 20 次 ![](https://i-blog.csdnimg.cn/blog_migrate/d205e15b6c6c32cc4920e837f3507ee9.png) ### Probes 编辑 `smokeping/config/Probes` 文件,将 dns 中的 `google.com` 改为了 `baidu.com`,其他都是默认的 ![](https://i-blog.csdnimg.cn/blog_migrate/2fc1bd1bc9db0705f19ba4d583ef5f19.png) ### 邮件报警 第一步、编辑 `ssmtp.conf` > 配置生效需要重启容器 ![](https://i-blog.csdnimg.cn/blog_migrate/0bcb66d71a210e89b27c7de0bc5ceb70.png) 除了密码都在下面👇 ``` Debug=YES # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. root=wbsu2003@88.com # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com mailhub=smtp.88.com:465 AuthUser=wbsu2003@88.com AuthPass=88邮箱设置的专用密码 UseSTARTTLS=NO UseTLS=YES # Where will the mail seem to come from? rewriteDomain=88.com # The full hostname hostname=linuxserver-smokeping1 # Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address FromLineOverride=YES ``` 老苏用的是 `88` 邮箱,相关参数可以在 `设置` 中找到 ![](https://i-blog.csdnimg.cn/blog_migrate/c1f1c88f013edaf6c09e4403a31a806d.png) 设置完成后,可以通过 『终端机』 进入容器内进行 `Email` 发送调试,命令行下输入 `ssmtp -v wbsu2003@hotmail.com` ,再依次输入: ``` To: wbsu2003@hotmail.com From: wbsu2003@88.com Subject: alert <回车2次> test123 ``` ![](https://i-blog.csdnimg.cn/blog_migrate/2261136346323d9c3a5db29dd5bbfa25.png) 去收件箱查看邮件 ![](https://i-blog.csdnimg.cn/blog_migrate/00d48f0fbe6b21551ce1951e6d778acd.png) 第二步、编辑 `Alerts` ![](https://i-blog.csdnimg.cn/blog_migrate/da08ec993ef2af95590ac61ea2917460.png) 修改红框部分 - `to`:接收报警的邮箱,也可以是自定义脚本; - `from`:发送报警信息的邮箱,也就是上一步在 `ssmtp.conf` 中设置的邮箱; 下面是报警触发的条件 > 设的比较低是想更容易触发报警,实际应用延时可以设在 `200ms` ``` *** Alerts *** to = wbsu2003@hotmail.com from = wbsu2003@88.com +rttdetect type = rtt pattern = <20,<20,<20,<20,<20,>20,>20,>20 comment = 连续3次延时20以上 +lossdetect type = loss pattern = ==0%,==0%,==0%,==0%,==0%,>0%,>0%,>0% comment = 突然有丢包 ``` ![](https://i-blog.csdnimg.cn/blog_migrate/c24521b2539bff2e997046005c861a6e.png) ### Targets `Internet Sites` 基本上是我们正常无法访问的站点,所以需要进行修改,不然会没有数据 ![](https://i-blog.csdnimg.cn/blog_migrate/f57a1ad3ea2784526b1059927953f0bf.png) 编辑 `smokeping/config/Targets` 文件 > 编辑之前请先做好备份 ![](https://i-blog.csdnimg.cn/blog_migrate/fa2629b929ae432f933b2c30ec5d3f1c.png) 格式一目了然,采用了是分层结构,用+表示,例如第一层“+”,第二层“++”一次类推可以增加也可以修改 ![](https://i-blog.csdnimg.cn/blog_migrate/6ff43dc560ca071c65d43d2122e0736a.png) 下面👇这段来自 [https://wzfou.com/smokeping/](https://wzfou.com/smokeping/),但根据我们前面设置的 `Probes` 和 `Alerts`进行了微调 ``` + Other menu = 三大网络监控 title = 监控统计 probe = FPing ++ dianxin menu = 电信网络监控 title = 电信网络监控列表 host = /Other/dianxin/dianxin-bj /Other/dianxin/dianxin-hlj /Other/dianxin/dianxin-tj /Other/dianxin/dianxin-sc /Other/dianxin/dianxin-sh /Other/dianxin/dianxin-gz +++ dianxin-bj menu = 北京电信 title = 北京电信 host = 202.96.199.133 alerts = rttdetect,lossdetect +++ dianxin-hlj menu = 黑龙江电信 title = 黑龙江电信 host = 219.147.198.242 alerts = rttdetect,lossdetect +++ dianxin-tj menu = 天津电信 title = 天津电信 host = 219.150.32.132 alerts = rttdetect,lossdetect +++ dianxin-sc menu = 四川电信 title = 四川电信 host = 61.139.2.69 alerts = rttdetect,lossdetect +++ dianxin-sh menu = 上海电信 title = 上海电信 host = 116.228.111.118 alerts = rttdetect,lossdetect +++ dianxin-gz menu = 广东电信 title = 广东电信 host = 113.111.211.22 alerts = rttdetect,lossdetect ++ liantong menu = 联通网络监控 title = 联通网络监控列表 host = /Other/liantong/liantong-bj /Other/liantong/liantong-hlj /Other/liantong/liantong-tj /Other/liantong/liantong-sc /Other/liantong/liantong-sh /Other/liantong/liantong-gz +++ liantong-bj menu = 北京联通 title = 北京联通 host = 61.135.169.121 alerts = rttdetect,lossdetect +++ liantong-hlj menu = 黑龙江联通 title = 黑龙江联通 host = 202.97.224.69 alerts = rttdetect,lossdetect +++ liantong-tj menu = 天津联通 title = 天津联通 host = 202.99.96.68 alerts = rttdetect,lossdetect +++ liantong-sc menu = 四川联通 title = 四川联通 host = 119.6.6.6 alerts = rttdetect,lossdetect +++ liantong-sh menu = 上海联通 title = 上海联通 host = 210.22.84.3 alerts = rttdetect,lossdetect +++ liantong-gz menu = 广东联通 title = 广东联通 host = 221.5.88.88 alerts = rttdetect,lossdetect ++ yidong menu = 移动网络监控 title = 移动网络监控列表 host = /Other/yidong/yidong-bj /Other/yidong/yidong-hlj /Other/yidong/yidong-tj /Other/yidong/yidong-sc /Other/yidong/yidong-sh /Other/yidong/yidong-gz +++ yidong-bj menu = 北京移动 title = 北京移动 host = 221.130.33.52 alerts = rttdetect,lossdetect +++ yidong-hlj menu = 黑龙江移动 title = 黑龙江移动 host = 211.137.241.35 alerts = rttdetect,lossdetect +++ yidong-tj menu = 天津移动 title = 天津移动 host = 211.137.160.5 alerts = rttdetect,lossdetect +++ yidong-sc menu = 四川移动 title = 四川移动 host = 218.201.4.3 alerts = rttdetect,lossdetect +++ yidong-sh menu = 上海移动 title = 上海移动 host = 117.131.19.23 alerts = rttdetect,lossdetect +++ yidong-gz menu = 广东移动 title = 广东移动 host = 211.136.192.6 alerts = rttdetect,lossdetect ``` 因为有中文,要使用 `utf-8` 格式 > 配置生效需要重启容器 ![](https://i-blog.csdnimg.cn/blog_migrate/c8697748324f3cd49a3442ad4936758e.png) 如果是用默认的 `GB18030` 编码保存,中文会乱码 ![](https://i-blog.csdnimg.cn/blog_migrate/ac80337ab8634db07f55b0f6d70e2bdc.png) 而正常显示应该是这样的 ![](https://i-blog.csdnimg.cn/blog_migrate/97fcd765901bcdda511f02c5ad7af1fd.png) 随着时间的推移,逐步会产生数据 ![](https://i-blog.csdnimg.cn/blog_migrate/55e4ebc1aa44d4e88c4f2da7c7137ed4.png) 当触发了设定的延迟( `rttdetect` )或者丢包( `lossdetect` )条件时,会收到邮件提醒 ![](https://i-blog.csdnimg.cn/blog_migrate/46594405cb838e00be152400a8fbeba4.png) 而如果邮件设置有问题,会在 `config` 目录中生成 `dead.letter` 文件,用于记录触发过的报警 ![](https://i-blog.csdnimg.cn/blog_migrate/2e72eb952ddc4dfbccba7676c811cc3b.png) 下载之后打开文件内容是下面👇这样的 ![](https://i-blog.csdnimg.cn/blog_migrate/08c1a5e52caf528cd6d2ba11ece9a576.png) ## 参考文档 > oetiker/SmokePing: The Active Monitoring System > 地址:[https://github.com/oetiker/SmokePing](https://github.com/oetiker/SmokePing) > > SmokePing - About SmokePing > 地址:[https://oss.oetiker.ch/smokeping/](https://oss.oetiker.ch/smokeping/) > > How to install SmokePing – sleeplessbeastie’s notes > 地址:[https://sleeplessbeastie.eu/2020/06/19/how-to-install-smokeping/](https://sleeplessbeastie.eu/2020/06/19/how-to-install-smokeping/) > > Smokeping安装与配置-免费开源网络性能监控工具可视化主/从部署 - 挖站否-挖掘建站的乐趣 > 地址:[https://wzfou.com/smokeping/](https://wzfou.com/smokeping/) > > ssmtp-命令行发送邮件 | Hom > 地址:[https://gohom.win/2016/10/07/ssmtp/](https://gohom.win/2016/10/07/ssmtp/) [![](https://profile-avatar.csdnimg.cn/6b52c23951f14455bc6415ace9975757_wbsu2004.jpg!1) 杨浦老苏](https://laosu.blog.csdn.net/) [关注](https://blog.csdn.net/wbsu2004/article/details/) -