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,52 @@
|
||||
//go:build windows
|
||||
|
||||
// Package collector 提供 Windows 逻辑磁盘使用率采集能力。 // Logan.Li
|
||||
package collector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"ezops/agent/model"
|
||||
)
|
||||
|
||||
type DiskCollector struct{}
|
||||
|
||||
func NewDiskCollector() *DiskCollector {
|
||||
return &DiskCollector{}
|
||||
}
|
||||
|
||||
func (d *DiskCollector) Collect() ([]model.DiskStat, error) {
|
||||
mask, _, err := syscall.NewLazyDLL("kernel32.dll").NewProc("GetLogicalDrives").Call()
|
||||
if mask == 0 {
|
||||
return nil, fmt.Errorf("GetLogicalDrives 失败: %w", err)
|
||||
}
|
||||
var disks []model.DiskStat
|
||||
for i := 0; i < 26; i++ {
|
||||
if mask&(1<<uint(i)) == 0 {
|
||||
continue
|
||||
}
|
||||
root := string(rune('A'+i)) + `:\`
|
||||
var freeAvail, totalBytes, totalFree uint64
|
||||
pathPtr, _ := syscall.UTF16PtrFromString(root)
|
||||
ret, _, _ := syscall.NewLazyDLL("kernel32.dll").NewProc("GetDiskFreeSpaceExW").Call(
|
||||
uintptr(unsafe.Pointer(pathPtr)),
|
||||
uintptr(unsafe.Pointer(&freeAvail)),
|
||||
uintptr(unsafe.Pointer(&totalBytes)),
|
||||
uintptr(unsafe.Pointer(&totalFree)),
|
||||
)
|
||||
if ret == 0 || totalBytes == 0 {
|
||||
continue
|
||||
}
|
||||
used := totalBytes - totalFree
|
||||
disks = append(disks, model.DiskStat{
|
||||
Mount: root,
|
||||
Device: root,
|
||||
TotalGB: bytesToGB(totalBytes),
|
||||
UsedGB: bytesToGB(used),
|
||||
UsagePercent: float64(used) / float64(totalBytes) * 100.0,
|
||||
})
|
||||
}
|
||||
return disks, nil
|
||||
}
|
||||
Reference in new issue
Block a user