3

使用speedtest-exporter测试家中网速

 2 years ago
source link: https://www.bboy.app/2021/09/24/%E4%BD%BF%E7%94%A8speedtest-exporter%E6%B5%8B%E8%AF%95%E5%AE%B6%E4%B8%AD%E7%BD%91%E9%80%9F/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用speedtest-exporter测试家中网速

发表于

2021-09-24 分类于 linux

202109241401365.png

今天看到了这个东西

https://github.com/geerlingguy/internet-pi

然后看到了它测速使用的是speedtest-exporter

所以就打算操作下

下面是他的github地址

https://github.com/MiguelNdeCarvalho/speedtest-exporter

最主要包含下面几个数值

你可以使用docker去搭建

docker run -d \
--name=speedtest-exporter \
-p 9798:9798 \
-e SPEEDTEST_PORT=<speedtest-port> #optional \
-e SPEEDTEST_SERVER=<speedtest-serverid> #optional \
--restart unless-stopped \
miguelndecarvalho/speedtest-exporter

解释下两个环境变量

  • SPEEDTEST_PORT 这个当然是端口,最好加下
  • SPEEDTEST_SERVER 这个是测速服务器,没多大需求的话就不要加,默认是最好的服务器

当然,我还是直接扔到了k8s里面

apiVersion: apps/v1
kind: Deployment
metadata:
name: speedtest
namespace: monitoring
spec:
selector:
matchLabels:
app.kubernetes.io/name: speedtest
template:
metadata:
labels:
app.kubernetes.io/name: speedtest
spec:
imagePullSecrets:
- name: regcred
containers:
- name: speedtest
image: registry.bboysoul.cn/miguelndecarvalho/speedtest-exporter:v3.3.2
env:
- name: SPEEDTEST_PORT
value: '9798'
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 9798
---
apiVersion: v1
kind: Service
metadata:
name: speedtest
namespace: monitoring
labels:
app.kubernetes.io/name: speedtest
spec:
selector:
app.kubernetes.io/name: speedtest
ports:
- port: 9798
targetPort: 9798
name: speedtest
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app.kubernetes.io/name: speedtest
name: speedtest
namespace: monitoring
spec:
endpoints:
- interval: 1h
scrapeTimeout: 5m
port: speedtest
scheme: http
selector:
matchLabels:
app.kubernetes.io/name: speedtest

一个deployment,一个service,一个ServiceMonitor

值得注意的是如果你直接添加到k8s里面的,使用下面

- job_name: 'speedtest-exporter'
scrape_interval: 1h
scrape_timeout: 1m
static_configs:
- targets: ['speedtest-exporter:9798']

scrape_interval表示多久抓取一次数据,最好配置的大一点,不然影响网速,因为每一次抓取都代表着一次测速
scrape_timeout表示抓取的超时时间,最好也大一点,不然速度还没测试完,你就超时了,会导致抓取不到数据

grafana dashboard可以看下面

https://github.com/MiguelNdeCarvalho/speedtest-exporter/blob/main/Dashboard/Speedtest%20Dashboard-1609529464845.json

当然你也可以看我的dashboard

https://grafana.bboysoul.cn/d/LTUPm_ink/jian-kong-da-ping?orgId=1&refresh=5s&kiosk

欢迎关注我的博客www.bboy.app

Have Fun


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK