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,53 @@
|
||||
//go:build windows
|
||||
|
||||
// Package collector 提供 Windows 网络连接基础采集能力。 // Logan.Li
|
||||
package collector
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"ezops/agent/model"
|
||||
)
|
||||
|
||||
type NetworkCollector struct{}
|
||||
|
||||
func NewNetworkCollector() *NetworkCollector {
|
||||
return &NetworkCollector{}
|
||||
}
|
||||
|
||||
func (c *NetworkCollector) Collect() (model.NetworkStat, error) {
|
||||
stat := model.NetworkStat{NicName: firstWindowsNIC()}
|
||||
out, err := exec.Command("netstat", "-ano", "-p", "tcp").Output()
|
||||
if err != nil {
|
||||
return stat, nil
|
||||
}
|
||||
for _, line := range strings.Split(string(out), "\n") {
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) < 4 || strings.ToUpper(fields[0]) != "TCP" {
|
||||
continue
|
||||
}
|
||||
state := strings.ToUpper(fields[3])
|
||||
switch state {
|
||||
case "ESTABLISHED":
|
||||
stat.TCPEstablished++
|
||||
case "TIME_WAIT":
|
||||
stat.TCPTimeWait++
|
||||
case "CLOSE_WAIT":
|
||||
stat.TCPCloseWait++
|
||||
}
|
||||
stat.TCPTotal++
|
||||
}
|
||||
return stat, nil
|
||||
}
|
||||
|
||||
func firstWindowsNIC() string {
|
||||
out, err := exec.Command("powershell.exe", "-NoProfile", "-Command", "Get-NetAdapter | Where-Object {$_.Status -eq 'Up'} | Select-Object -First 1 -ExpandProperty Name").Output()
|
||||
if err == nil {
|
||||
if name := strings.TrimSpace(string(bytes.TrimSpace(out))); name != "" {
|
||||
return name
|
||||
}
|
||||
}
|
||||
return "Ethernet"
|
||||
}
|
||||
Reference in new issue
Block a user