https://github.com/jkstack/example-agent
agent示例
https://github.com/jkstack/example-agent
agent example go
Last synced: 3 months ago
JSON representation
agent示例
- Host: GitHub
- URL: https://github.com/jkstack/example-agent
- Owner: jkstack
- License: mit
- Created: 2022-08-11T09:46:23.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-08T04:00:30.000Z (almost 3 years ago)
- Last Synced: 2025-01-09T11:35:33.785Z (about 1 year ago)
- Topics: agent, example, go
- Language: Go
- Homepage: https://jkstack.github.io/docs/agents/example-agent/
- Size: 303 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# example-agent
[](https://github.com/jkstack/example-agent/releases/latest)
[](https://goreportcard.com/report/github.com/jkstack/example-agent)
[](https://github.com/jkstack/example-agent)
[](https://opensource.org/licenses/MIT)

这是一个agent的示例,用于展示agent开发
## agent开发
1. 创建项目并导入[libagent](github.com/jkstack/libagent)库
```
go get github.com/jkstack/libagent
```
2. 定义一个结构体并实现[App](https://pkg.go.dev/github.com/jkstack/libagent#App)接口
3. 在main函数中添加RegisterService、UnregisterService和Run等libagent库中的接口调用
```go
switch *act {
case "install":
agent.RegisterService(app)
case "uninstall":
agent.UnregisterService(app)
default:
agent.Run(app)
}
```
## 更多示例
1. [metrics-agent](https://github.com/jkstack/metrics-agent): 监控数据采集
2. [exec-agent](https://github.com/jkstack/exec-agent): 远程执行脚本,文件分发
## 开源社区
文档知识库:https://jkstack.github.io/
