feat: 完善堡垒机与 Agent 智能运维能力
- 支持 Windows Agent 构建、安装脚本和统一上报协议 - 增强 RDP 剪贴板、虚拟盘和文件传输能力 - 新增 AIOps 上下文工具、告警 RCA trace 落库和回放接口 - 重构 docs 模块文档并补充终端、堡垒机、监控、AI Agent 设计
This commit is contained in:
1 parent
a9513c2056
commit
e0d652d211
169 files changed
+12192
-9116
No files matched your search
@@ -0,0 +1,56 @@
|
||||
//go:build windows
|
||||
|
||||
// Package collector 提供 Windows 内存指标采集能力。 // Logan.Li
|
||||
package collector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"ezops/agent/model"
|
||||
)
|
||||
|
||||
type memoryStatusEx struct {
|
||||
Length uint32
|
||||
MemoryLoad uint32
|
||||
TotalPhys uint64
|
||||
AvailPhys uint64
|
||||
TotalPageFile uint64
|
||||
AvailPageFile uint64
|
||||
TotalVirtual uint64
|
||||
AvailVirtual uint64
|
||||
AvailExtendedVirtual uint64
|
||||
}
|
||||
|
||||
type MemCollector struct{}
|
||||
|
||||
func NewMemCollector() *MemCollector {
|
||||
return &MemCollector{}
|
||||
}
|
||||
|
||||
func (m *MemCollector) Collect() (model.MemoryStat, error) {
|
||||
var ms memoryStatusEx
|
||||
ms.Length = uint32(unsafe.Sizeof(ms))
|
||||
ret, _, err := syscall.NewLazyDLL("kernel32.dll").NewProc("GlobalMemoryStatusEx").Call(uintptr(unsafe.Pointer(&ms)))
|
||||
if ret == 0 {
|
||||
return model.MemoryStat{}, fmt.Errorf("GlobalMemoryStatusEx 失败: %w", err)
|
||||
}
|
||||
total := ms.TotalPhys
|
||||
avail := ms.AvailPhys
|
||||
used := total - avail
|
||||
swapTotal := ms.TotalPageFile
|
||||
swapAvail := ms.AvailPageFile
|
||||
swapUsed := uint64(0)
|
||||
if swapTotal > swapAvail {
|
||||
swapUsed = swapTotal - swapAvail
|
||||
}
|
||||
stat := model.MemoryStat{
|
||||
TotalGB: bytesToGB(total),
|
||||
UsedGB: bytesToGB(used),
|
||||
AvailableGB: bytesToGB(avail),
|
||||
SwapUsedGB: bytesToGB(swapUsed),
|
||||
UsagePercent: float64(ms.MemoryLoad),
|
||||
}
|
||||
return stat, nil
|
||||
}
|
||||
Reference in new issue
Block a user