当前位置:网站首页>使用 Blackbox Exporter 测试网络连通性
使用 Blackbox Exporter 测试网络连通性
2022-06-27 06:39:00 【陈少文的网站】
如果你需要监控两个主机、主机与外部服务之间的网络状况,那么就可以试一试本文提到的 Blackbox Exporter。
1. 安装 Blackbox
- 下载二进制包
| |
- 清理安装包
| |
- 新建 Systemd 服务
| |
新增如下内容:
[Unit]Description=blackbox_exporterAfter=network.target[Service]Restart=on-failureExecStart=/usr/bin/blackbox_exporter \ --config.file=/etc/prometheus/blackbox.ymlRestart=on-failure[Install]WantedBy=multi-user.target- 启动服务
| |
- 查看运行状态
| |
2. 测试主机对外访问连通性
blackbox_exporter 默认在本地 9115 端口暴露服务。
实际上,通过拼接 URL 的方式,我们就可以实现主机对任意服务的连通测试,下面是一个实例,只需要提供 target、module 参数即可,其中 target 表示测试的目标,module 表示测试用的模块:
浏览器访问 http://BLACKBOX_HOST_IP:9115/probe?target=google.com&module=http_2xx,需要将 BLACKBOX_HOST_IP 替换为主机 IP。
| |
在注释中,对这些指标有着很详尽的描述,DNS 延时、响应、协议等。
3. Prometheus 配置
接着,我们可以让 Prometheus 定时抓取 blackbox 的指标。下面是相关的配置文件,需要将 BLACKBOX_HOST_IP 替换为 blackbox_exporter 部署主机的 IP 地址。
| |
4. 配置 Grafana 面板
这里采用的是 https://grafana.com/grafana/dashboards/13587 面板。
稍微进行了调整,最终看起来如下图:

5. 可能遇到的问题
5.1 probe_http_status_code 状态码一直为 0
blackbox_exporter 默认使用的是 ipv6 栈,需要手动指定为 ipv4。
编辑配置文件 /etc/prometheus/blackbox.yml 指定 ipv4 栈。
| |
然后,重启服务:
| |
5.2 Grafana 找不到 grafana-piechart-panel
- 安装插件
| |
- 在配置文件中指定插件的路径
vim /usr/local/grafana/conf/defaults.ini[plugin.piechart]path = /var/lib/grafana/plugins/grafana-piechart-panel- 重启 Grafana
| |
边栏推荐
- 分数阶PID控制
- Optimistic and pessimistic affairs
- NoViableAltException([email protected][2389:1: columnNameTypeOrConstraint : ( ( tableConstraint ) | ( columnNameT
- The number of query results of maxcompute SQL is limited to 1W
- SQL injection bypass (I)
- 2022 cisp-pte (I) document contains
- Once spark reported an error: failed to allocate a page (67108864 bytes), try again
- 面试官:你天天用 Lombok,说说它什么原理?我竟然答不上来…
- 网关状态检测 echo request/reply
- Thesis reading skills
猜你喜欢
随机推荐
Spark SQL common time functions
Some settings about postfix completion code template in idea
ORA-00909: 参数个数无效,concat引起
Cloud-Native Database Systems at Alibaba: Opportunities and Challenges
An Empirical Evaluation of In-Memory Multi-Version Concurrency Control
SQL考勤查询间隔一小时
HTAP 深入探索指南
Fractional Order PID control
Unrecognized VM option ‘‘
Ora-00909: invalid number of parameters, caused by concat
大学数据库mysql
thrift
Visual studio vs shortcut key usage
mssql如何使用语句导出并删除多表数据
On gpu: historical development and structure
The number of query results of maxcompute SQL is limited to 1W
一线大厂面试官问:你真的懂电商订单开发吗?
View functions in tidb
聊聊领域驱动设计
One year's experience of technical personnel in Entrepreneurship








