实现监控节点在线状态

This commit is contained in:
刘祥超
2020-10-25 18:26:46 +08:00
parent 022aa174a4
commit 6a25cce772
7 changed files with 163 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"time"
)
@@ -26,3 +27,15 @@ func (this *Node) DecodeInstallStatus() (*NodeInstallStatus, error) {
return status, nil
}
// 节点状态
func (this *Node) DecodeStatus() (*nodeconfigs.NodeStatus, error) {
if len(this.Status) == 0 || this.Status == "null" {
return nil, nil
}
status := &nodeconfigs.NodeStatus{}
err := json.Unmarshal([]byte(this.Status), status)
if err != nil {
return nil, err
}
return status, nil
}