mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
⚡️ 进一步提供选项降低 agent 占用
This commit is contained in:
@@ -35,6 +35,7 @@ type AgentConfig struct {
|
||||
Debug bool
|
||||
Server string
|
||||
ClientSecret string
|
||||
ReportDelay int
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -71,6 +72,7 @@ func main() {
|
||||
flag.BoolVarP(&agentConf.Debug, "debug", "d", false, "开启调试信息")
|
||||
flag.StringVarP(&agentConf.Server, "server", "s", "localhost:5555", "管理面板RPC端口")
|
||||
flag.StringVarP(&agentConf.ClientSecret, "password", "p", "", "Agent连接Secret")
|
||||
flag.IntVar(&agentConf.ReportDelay, "report-delay", 1, "系统状态上报间隔")
|
||||
flag.BoolVar(&agentConf.SkipConnectionCount, "skip-conn", false, "不监控连接数")
|
||||
flag.BoolVar(&agentConf.SkipProcsCount, "skip-procs", false, "不监控进程数")
|
||||
flag.BoolVar(&agentConf.DisableAutoUpdate, "disable-auto-update", false, "禁用自动升级")
|
||||
@@ -81,6 +83,11 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
if agentConf.ReportDelay < 0 || agentConf.ReportDelay > 4 {
|
||||
println("report-delay 的区间为 1-4")
|
||||
return
|
||||
}
|
||||
|
||||
run()
|
||||
}
|
||||
|
||||
@@ -221,7 +228,7 @@ func reportState() {
|
||||
client.ReportSystemInfo(context.Background(), monitor.GetHost().PB())
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
time.Sleep(time.Second * time.Duration(agentConf.ReportDelay))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user