mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-01-06 22:55:46 +08:00
first
This commit is contained in:
30
scheudler/mytask.go
Normal file
30
scheudler/mytask.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"github.com/siddontang/go/log"
|
||||
"mayfly-go/base"
|
||||
"mayfly-go/base/utils"
|
||||
"mayfly-go/machine"
|
||||
"mayfly-go/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
SaveMachineMonitor()
|
||||
}
|
||||
|
||||
func SaveMachineMonitor() {
|
||||
AddFun("@every 60s", func() {
|
||||
for _, m := range *models.GetNeedMonitorMachine() {
|
||||
m := m
|
||||
go func() {
|
||||
mm := machine.GetMonitorInfo(machine.GetCli(uint64(utils.GetInt4Map(m, "id"))))
|
||||
if mm != nil {
|
||||
err := base.Insert(mm)
|
||||
if err != nil {
|
||||
log.Error("保存机器监控信息失败: %s", err.Error())
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user