1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
data.go 987 Bytes
一键复制 编辑 原始数据 按行查看 历史
package host
import (
"github.com/elastic/beats/libbeat/common"
"github.com/vmware/govmomi/vim25/mo"
)
func eventMapping(hs mo.HostSystem) common.MapStr {
totalCpu := int64(hs.Summary.Hardware.CpuMhz) * int64(hs.Summary.Hardware.NumCpuCores)
freeCpu := int64(totalCpu) - int64(hs.Summary.QuickStats.OverallCpuUsage)
usedMemory := int64(hs.Summary.QuickStats.OverallMemoryUsage) * 1024 * 1024
freeMemory := int64(hs.Summary.Hardware.MemorySize) - usedMemory
event := common.MapStr{
"name": hs.Summary.Config.Name,
"cpu": common.MapStr{
"used": common.MapStr{
"mhz": hs.Summary.QuickStats.OverallCpuUsage,
},
"total": common.MapStr{
"mhz": totalCpu,
},
"free": common.MapStr{
"mhz": freeCpu,
},
},
"memory": common.MapStr{
"used": common.MapStr{
"bytes": usedMemory,
},
"total": common.MapStr{
"bytes": hs.Summary.Hardware.MemorySize,
},
"free": common.MapStr{
"bytes": freeMemory,
},
},
}
return event
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v6.2.3

搜索帮助