Skip to content

Add operating system from vsphere to 'os' field #12391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Keep `etcd` followers members from reporting `leader` metricset events {pull}12004[12004]
- Add overview dashboard to Consul module {pull}10665[10665]
- New fields were added in the mysql/status metricset. {pull}12227[12227]
- Add Vsphere Virtual Machine operating system to `os` field in Vsphere virtualmachine module. {pull}12391[12391]

*Packetbeat*

Expand Down
10 changes: 10 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27194,6 +27194,16 @@ type: keyword
Virtual Machine name


--

*`vsphere.virtualmachine.os`*::
+
--
type: keyword

Virtual Machine Operating System name


--

*`vsphere.virtualmachine.cpu.used.mhz`*::
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions metricbeat/module/vsphere/virtualmachine/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
type: keyword
description: >
Virtual Machine name
- name: os
type: keyword
description: >
Virtual Machine Operating System name
- name: cpu.used.mhz
type: long
description: >
Expand Down
38 changes: 29 additions & 9 deletions metricbeat/module/vsphere/virtualmachine/virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,37 @@ func (m *MetricSet) Fetch(reporter mb.ReporterV2) error {
}

for _, vm := range vmt {

freeMemory := (int64(vm.Summary.Config.MemorySizeMB) * 1024 * 1024) - (int64(vm.Summary.QuickStats.GuestMemoryUsage) * 1024 * 1024)

event := common.MapStr{}

event["name"] = vm.Summary.Config.Name
event.Put("cpu.used.mhz", vm.Summary.QuickStats.OverallCpuUsage)
event.Put("memory.used.guest.bytes", int64(vm.Summary.QuickStats.GuestMemoryUsage)*1024*1024)
event.Put("memory.used.host.bytes", int64(vm.Summary.QuickStats.HostMemoryUsage)*1024*1024)
event.Put("memory.total.guest.bytes", int64(vm.Summary.Config.MemorySizeMB)*1024*1024)
event.Put("memory.free.guest.bytes", freeMemory)
event := common.MapStr{
"name": vm.Summary.Config.Name,
"os": vm.Summary.Config.GuestFullName,
"cpu": common.MapStr{
"used": common.MapStr{
"mhz": vm.Summary.QuickStats.OverallCpuUsage,
},
},
"memory": common.MapStr{
"used": common.MapStr{
"guest": common.MapStr{
"bytes": (int64(vm.Summary.QuickStats.GuestMemoryUsage) * 1024 * 1024),
},
"host": common.MapStr{
"bytes": (int64(vm.Summary.QuickStats.HostMemoryUsage) * 1024 * 1024),
},
},
"total": common.MapStr{
"guest": common.MapStr{
"bytes": (int64(vm.Summary.Config.MemorySizeMB) * 1024 * 1024),
},
},
"free": common.MapStr{
"guest": common.MapStr{
"bytes": freeMemory,
},
},
},
}

if vm.Summary.Runtime.Host != nil {
event["host"] = vm.Summary.Runtime.Host.Value
Expand Down