mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-12 14:30:54 +08:00
显示SSH认证相关集群、节点
This commit is contained in:
@@ -1,26 +0,0 @@
|
|||||||
package nodes
|
|
||||||
|
|
||||||
// 节点状态
|
|
||||||
type NodeStatus struct {
|
|
||||||
BuildVersion string `json:"buildVersion"` // 编译版本
|
|
||||||
ConfigVersion int64 `json:"configVersion"` // 节点配置版本
|
|
||||||
|
|
||||||
Hostname string `json:"hostname"`
|
|
||||||
HostIP string `json:"hostIP"`
|
|
||||||
CPUUsage float64 `json:"cpuUsage"`
|
|
||||||
CPULogicalCount int `json:"cpuLogicalCount"`
|
|
||||||
CPUPhysicalCount int `json:"cpuPhysicalCount"`
|
|
||||||
MemoryUsage float64 `json:"memoryUsage"`
|
|
||||||
MemoryTotal uint64 `json:"memoryTotal"`
|
|
||||||
DiskUsage float64 `json:"diskUsage"`
|
|
||||||
DiskMaxUsage float64 `json:"diskMaxUsage"`
|
|
||||||
DiskMaxUsagePartition string `json:"diskMaxUsagePartition"`
|
|
||||||
DiskTotal uint64 `json:"diskTotal"`
|
|
||||||
UpdatedAt int64 `json:"updatedAt"`
|
|
||||||
Load1m float64 `json:"load1m"`
|
|
||||||
Load5m float64 `json:"load5m"`
|
|
||||||
Load15m float64 `json:"load15m"`
|
|
||||||
|
|
||||||
IsActive bool `json:"isActive"`
|
|
||||||
Error string `json:"error"`
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package nodes
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/logs"
|
"github.com/TeaOSLab/EdgeNode/internal/logs"
|
||||||
@@ -45,7 +46,7 @@ func (this *NodeStatusExecutor) update() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
status := &NodeStatus{}
|
status := &nodeconfigs.NodeStatus{}
|
||||||
status.BuildVersion = teaconst.Version
|
status.BuildVersion = teaconst.Version
|
||||||
status.ConfigVersion = sharedNodeConfig.Version
|
status.ConfigVersion = sharedNodeConfig.Version
|
||||||
status.IsActive = true
|
status.IsActive = true
|
||||||
@@ -80,7 +81,7 @@ func (this *NodeStatusExecutor) update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新CPU
|
// 更新CPU
|
||||||
func (this *NodeStatusExecutor) updateCPU(status *NodeStatus) {
|
func (this *NodeStatusExecutor) updateCPU(status *nodeconfigs.NodeStatus) {
|
||||||
duration := time.Duration(0)
|
duration := time.Duration(0)
|
||||||
if this.isFirstTime {
|
if this.isFirstTime {
|
||||||
duration = 100 * time.Millisecond
|
duration = 100 * time.Millisecond
|
||||||
@@ -117,7 +118,7 @@ func (this *NodeStatusExecutor) updateCPU(status *NodeStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新硬盘
|
// 更新硬盘
|
||||||
func (this *NodeStatusExecutor) updateDisk(status *NodeStatus) {
|
func (this *NodeStatusExecutor) updateDisk(status *nodeconfigs.NodeStatus) {
|
||||||
partitions, err := disk.Partitions(false)
|
partitions, err := disk.Partitions(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("NODE_STATUS", err.Error())
|
logs.Error("NODE_STATUS", err.Error())
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
package nodes
|
package nodes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/shirou/gopsutil/load"
|
"github.com/shirou/gopsutil/load"
|
||||||
"github.com/shirou/gopsutil/mem"
|
"github.com/shirou/gopsutil/mem"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 更新内存
|
// 更新内存
|
||||||
func (this *NodeStatusExecutor) updateMem(status *NodeStatus) {
|
func (this *NodeStatusExecutor) updateMem(status *nodeconfigs.NodeStatus) {
|
||||||
stat, err := mem.VirtualMemory()
|
stat, err := mem.VirtualMemory()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -24,7 +25,7 @@ func (this *NodeStatusExecutor) updateMem(status *NodeStatus) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 更新负载
|
// 更新负载
|
||||||
func (this *NodeStatusExecutor) updateLoad(status *NodeStatus) {
|
func (this *NodeStatusExecutor) updateLoad(status *nodeconfigs.NodeStatus) {
|
||||||
stat, err := load.Avg()
|
stat, err := load.Avg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
status.Error = err.Error()
|
status.Error = err.Error()
|
||||||
|
|||||||
Reference in New Issue
Block a user