# bondman
**Repository Path**: leonscript/bondman
## Basic Information
- **Project Name**: bondman
- **Description**: Who will read the files and report the dangerous information to the headquarters。
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-01-18
- **Last Updated**: 2026-03-25
## Categories & Tags
**Categories**: Uncategorized
**Tags**: tail, 告警, 短信
## README
# bondman
🕶️Who will read the files and report the dangerous information to the headquarters?
## 工具介绍
这是一个用于监控指定日志文件的工具,当发现文件中出现错误级别日志时,会推送错误短信给指定手机号(阿里云短信),支持日志文件滚动。
其原理是:tail -f + 阿里云短信。
## 日志格式
工具要求日志必须以json的格式输出,如:
```json
{
"caller": "",
"level": "error",
"msg": "strconv.ParseFloat: parsing \"null\": invalid syntax",
"time": "2024-02-21",
"traceID": 944766297932046336
}
```
下面几个字段,是日志json中必须包含的:
| 字段名 | 枚举值 | 类型 | 说明 |
|:--------|:--------------------------:|-------:|:-------------------------|
| level | error:错误;fatal:致命错误(panic) | string | 日志等级 |
| msg | / | string | 日志详细内容 |
| time | / | string | 输出时间 |
| traceID | / | int64 | 链路追踪ID,用于方便追踪日志的上下文,建议使用 |
- **如果启用了traceID字段,短信内容会使用traceID,如果没启用,短信内容会截取msg中的前30个字符。**
## 短信格式
目前工具中对接的是阿里云短信,你可以自定义短信的内容,但是短信中关键的“自定义变量”必须存在:
| 变量名 | 说明 |
|:--------|:---------:|
| project | 项目名称+环境 |
| content | 短信包含的日志内容 |
- **阿里云短信的配置,可参考config.yaml文件**