# uos-time-exporter **Repository Path**: openeuler/uos-time-exporter ## Basic Information - **Project Name**: uos-time-exporter - **Description**: A Prometheus exporter for covering all possible timesync and time services - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-08-06 - **Last Updated**: 2025-10-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: sig-ops ## README // SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. // SPDX-License-Identifier: MIT # uos-time-exporter `uos-time-exporter` 是一个 Prometheus Exporter,用于采集常见时间同步组件(chrony、NTP、timex、系统时间)的运行状态指标,可作为独立服务运行,也可以结合 systemd 进行托管。 ## 功能特性 - 采集 chrony 的 tracking、sources、sourcestats 指标 - 通过 `github.com/beevik/ntp` 查询远端 NTP 服务器状态 - 暴露 timex 内核统计与系统时间信息 - 支持在配置文件中按需开启/关闭采集器 - 内置 `/healthz` 健康检查接口 ## 快速开始 ### 本地编译 ```bash make fmt # 可选:go fmt 格式化 make test # 可选:运行 go test ./... make build # 输出 build/bin/time-exporter ``` ### systemd 安装 ```bash sudo make install PREFIX=/usr/local sudo systemctl daemon-reload sudo systemctl enable --now uos-time-exporter.service ``` 默认服务会启动 `/usr/local/bin/time-exporter`,并读取 `/etc/uos-exporter/time-exporter.yaml` 配置文件。 ### 配置示例 ```yaml address: "0.0.0.0" port: 9085 metricsPath: "/metrics" log: level: "debug" collectors: chrony: true time: true timex: true ntp: true ntp_config: ntp_server: pool.ntp.org ntp_protocol_version: 4 ntp_server_is_local: false ntp_ip_ttl: 1 chrony_config: chrony_address: pool.ntp.org chrony_port: 323 ``` 如需停用某类采集器,将对应布尔值改为 `false` 即可。`log` 字段支持扩展 `max_size`、`max_age` 等日志滚动参数。 ## 采集端点 | 路径 | 说明 | |------------|---------------------| | `/metrics` | Prometheus 指标输出 | | `/healthz` | 健康检查(JSON) | ## 开发指引 - `make fmt`:格式化 Go 代码 - `make test`:执行 `go test ./...` - `make deps`:整理 `go.mod/go.sum`