## 我写的分布式c/s ping & http 探测代码
## 地址 [https://github.com/ning1875/xprober](https://github.com/ning1875/xprober)
## xprober特点
– 基于公有混合云ec2的ping监控,可以得到不同region之间的网络延迟
– 可以从不同region对http接口发起探测,可以trace 一个http请求的各个stage的耗时
– icmp target可由 存活agent上报 / 可以在配置文件中指定
– http target 在配置文件中指定
## 预览图
### http 探测结果
### 互ping 结果
# 项目说明
xprober
是分布式c / s架构接口检测框架:
- Ping监控:基于不同区域之间的公共云混合云ec2检测
- Ping监视:根据代理启动来建立目标池,可以获取两个区域的Ping结果作为彼此的源和目标
- 目标源:同时,它还支持服务器端配置文件以指定目标
- Http监视:它可以获取从不同区域到目标接口在不同http阶段花费的时间
服务器端逻辑
- * RPC接收代理agent IP报告
* 定时器将探测目标池刷新到本地缓存中
* server 根据agent rpc信息返回给其探测目标池
* rpc接收数据
* 更新到本地缓存
* 定时器数据处理
* 公开prome http指标
建造
$ git clone https://github.com/ning1875/xprober.git# build agent$ cd xprober/pkg/cmd/agent && go build -o xprober-agent main.go # build server$ cd ../server/ && go build -o xprober-server main.go`
启动服务
# for server xprober-server --config.file=xprober.yml# for agent xprober-agent --grpc.server-address=$server_rpc_ip:6001
与promtheus集成
将以下文本添加到promtheus.yaml的scrape_configs部分
scrape_configs: - job_name: net_monitor honor_labels: true honor_timestamps: true scrape_interval: 10s scrape_timeout: 5s metrics_path: /metrics scheme: http static_configs: - targets: - $server_rpc_ip:6002
与grafana集成
在common / metrics.go中查看指标名称并将其添加到grafana仪表板
文章来源:智云一二三科技
文章标题:xprober 分布式c/s ping & http框架
文章地址:https://www.zhihuclub.com/6609.shtml