
10分钟上手uos-tc-exporter从安装到获取TC指标的快速教程【免费下载链接】uos-tc-exporterA Prometheus exporter for tc stats via netlink.项目地址: https://gitcode.com/openeuler/uos-tc-exporter前往项目官网免费下载https://ar.openeuler.org/ar/uos-tc-exporter是一款基于Prometheus的Linux流量控制(TC)指标导出器能够通过netlink接口高效收集队列规则(qdisc)和类(class)的统计信息为网络流量监控提供关键数据支持。本教程将帮助你在10分钟内完成从安装到获取指标的全过程轻松掌握网络流量监控的核心工具。为什么选择uos-tc-exporteruos-tc-exporter作为openEuler社区的开源项目具备以下核心优势全面监控能力支持HTB、CBQ、FQ、CODEL等多种队列规则和类的监控高效数据收集基于netlink接口与内核TC子系统直接通信性能优异Prometheus兼容提供标准Prometheus指标格式无缝集成监控生态灵活配置选项通过YAML配置文件自定义监控参数和服务设置网络命名空间支持可监控不同网络命名空间中的TC配置内置保护机制包含请求限流功能保障服务稳定运行快速安装指南准备工作在开始安装前请确保你的系统满足以下要求Linux内核版本3.10或更高Go 1.20或更高版本用于编译Git工具具有sudo权限的用户一键安装步骤# 克隆仓库 git clone https://gitcode.com/openeuler/uos-tc-exporter cd uos-tc-exporter # 编译项目 make build # 安装到系统 sudo make install简单配置方法uos-tc-exporter的配置文件采用YAML格式默认位置为/etc/uos-exporter/tc-exporter.yaml。以下是基础配置示例# 服务监听配置 address: 127.0.0.1 port: 9062 metricsPath: /metrics # 日志配置 log: level: info logPath: /var/log/tc-exporter.log maxSize: 10MB maxAge: 168h # 7天 # 服务器配置 server: shutdownTimeout: 30s你可以根据实际需求修改配置参数如更改监听地址、端口或调整日志级别。启动服务的两种方式直接运行sudo ./tc-exporter作为systemd服务运行推荐# 启动服务 sudo systemctl start uos-tc-exporter # 设置开机自启 sudo systemctl enable uos-tc-exporter # 查看服务状态 sudo systemctl status uos-tc-exporter获取TC指标数据服务启动后你可以通过以下方式获取TC指标使用curl命令curl http://localhost:9062/metrics示例指标展示uos-tc-exporter提供的指标包括但不限于# Qdisc指标 tc_qdisc_bytes_total{deviceeth0,qdischtb} 6789012 tc_qdisc_packets_total{deviceeth0,qdischtb} 12345 tc_qdisc_drops_total{deviceeth0,qdischtb} 0 # Class指标 tc_class_bytes_total{deviceeth0,classhtb} 3456789 tc_class_packets_total{deviceeth0,classhtb} 5432这些指标涵盖了流量字节数、数据包数量、丢包数等关键网络性能参数。集成Prometheus监控要将uos-tc-exporter集成到Prometheus监控系统中只需在Prometheus配置文件中添加以下内容scrape_configs: - job_name: tc-exporter static_configs: - targets: [localhost:9062] scrape_interval: 15s支持的队列规则类型uos-tc-exporter支持多种常见的Linux TC队列规则包括HTB(Hierarchical Token Bucket)CBQ(Class Based Queueing)HFSC(Hierarchical Fair Service Curve)FQ(Fair Queue)FQ_CODEL(Fair Queue with Controlled Delay)CODEL(Controlled Delay)PIE(Proportional Integral controller Enhanced)RED(Random Early Detection)CHOKE(CHOose and Keep for responsive flows)完整的支持列表和技术细节可参考项目的设计文档。常见问题解决权限问题如果启动时遇到权限不足的错误请使用sudo运行或为二进制文件设置适当的capabilitiessudo setcap CAP_NET_ADMINep /usr/bin/uos-tc-exporter端口冲突若提示端口被占用可修改配置文件中的port参数选择未被使用的端口。调试模式如需排查问题可启用调试日志export LOG_LEVELdebug sudo -E tc-exporter深入学习资源项目源代码uos-tc-exporter设计文档docs/design.md配置示例config/tc-exporter.yaml指标收集实现internal/metrics/TC客户端代码internal/tc/通过本教程你已经掌握了uos-tc-exporter的基本安装、配置和使用方法。这个强大的工具将帮助你深入了解Linux系统的网络流量控制情况为网络性能优化和故障排查提供有力支持。开始你的TC指标监控之旅吧【免费下载链接】uos-tc-exporterA Prometheus exporter for tc stats via netlink.项目地址: https://gitcode.com/openeuler/uos-tc-exporter创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考