开发者 brvier 发布了一款名为 Gjallar 的轻量级监控工具 1。该工具仅需一个 Go 二进制文件、一个 YAML 配置文件和一个 SQLite 数据库,即可实现对 HTTP 端点以及 PostgreSQL、Oracle、Redis、Elasticsearch 等多种服务的监控与告警 1。该项目代码量约 3,400 行,采用纯 Go 语言编写,并以 MIT 协议在 GitHub(github.com/brvier/Gjallar)上开源 1。
在技术实现上,Gjallar 采用零 CGO 设计,支持跨平台编译与简单部署 1。通过特定命令(CGO_ENABLED=0 go build -trimpath -ldflags "-s -w")编译出的单个二进制文件大小约为 36 MB 1。为了保持纯 Go 特性,该工具使用 pgx 替代 libpq 连接 PostgreSQL,采用 go-ora 替代 Oracle Instant Client 连接 Oracle,并利用 modernc.org/sqlite 作为 SQLite 的纯 Go 实现 1。此外,Redis 检查直接通过 TCP 协议实现,无需驱动 1。该工具的告警管道采用单消费者 goroutine 模式,实现了无锁设计 1。通知发送异步执行,且超时时间设为 15 秒 1。在运维与数据管理方面,Gjallar 支持通过 SIGHUP 信号热重载配置,并默认保留 30 天的历史数据 1。
A developer known as brvier has created and open-sourced Gjallar, a lightweight monitoring tool designed to track and alert on various services, including HTTP endpoints, PostgreSQL, Oracle, Redis, and Elasticsearch 1. The project consists of approximately 3,400 lines of Go code and is released under the MIT license 1. The tool operates using a single Go binary, a single YAML configuration file, and a single SQLite database, enabling simple deployment and cross-platform compilation 1.
To achieve a pure Go implementation with zero CGO dependencies, the developer utilized specific libraries and protocols for database and service connections 1. For PostgreSQL, the tool uses pgx instead of libpq, while go-ora replaces the Oracle Instant Client for Oracle connections 1. The SQLite database is powered by modernc.org/sqlite, a pure Go implementation, and Redis checks are performed directly via the TCP protocol without requiring an external driver 1. The resulting single binary file is approximately 36 MB in size and can be compiled using the command CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" 1.
Gjallar features a lock-free alerting pipeline built on a single-consumer goroutine model, along with asynchronous notification dispatch that enforces a 15-second timeout 1. The tool also supports configuration hot-reloading via the SIGHUP signal and retains historical data for a default period of 30 days 1. The complete source code for the project is available in the GitHub repository at github.com/brvier/Gjallar 1.
评论
还没有评论,欢迎留下第一条。