Skip to content
This repository was archived by the owner on Dec 23, 2017. It is now read-only.

Commit 104143e

Browse files
author
Jochen Schalanda
committed
Check CPU, memmory, and swap separately in ElasticsearchCollector
1 parent 1bb48d8 commit 104143e

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/main/java/org/graylog/plugins/usagestatistics/collectors/ElasticsearchCollector.java

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,18 @@ public Set<ElasticsearchNodeInfo> getNodeInfos() {
6969
continue;
7070
}
7171

72-
final HostInfo.Cpu cpu;
73-
final HostInfo.Memory memory;
74-
final HostInfo.Memory swap;
75-
if (info.getOs() != null) {
76-
cpu = HostInfo.Cpu.create(
77-
info.getOs().cpu().model(),
78-
info.getOs().cpu().vendor(),
79-
info.getOs().cpu().mhz(),
80-
info.getOs().cpu().totalCores(),
81-
info.getOs().cpu().totalSockets(),
82-
info.getOs().cpu().coresPerSocket(),
83-
info.getOs().cpu().cacheSize().bytes()
84-
);
85-
memory = HostInfo.Memory.create(info.getOs().mem().total().bytes());
86-
swap = HostInfo.Memory.create(info.getOs().swap().total().bytes());
87-
88-
} else {
89-
cpu = null;
90-
memory = null;
91-
swap = null;
92-
}
93-
9472
final MacAddress macAddress = info.getNetwork() == null ? MacAddress.EMPTY : MacAddress.create(info.getNetwork().primaryInterface().macAddress());
73+
final HostInfo.Cpu cpu = info.getOs().cpu() == null ? null : HostInfo.Cpu.create(
74+
info.getOs().cpu().model(),
75+
info.getOs().cpu().vendor(),
76+
info.getOs().cpu().mhz(),
77+
info.getOs().cpu().totalCores(),
78+
info.getOs().cpu().totalSockets(),
79+
info.getOs().cpu().coresPerSocket(),
80+
info.getOs().cpu().cacheSize().bytes()
81+
);
82+
final HostInfo.Memory memory = info.getOs().mem() == null ? null : HostInfo.Memory.create(info.getOs().mem().total().bytes());
83+
final HostInfo.Memory swap = info.getOs().swap() == null ? null : HostInfo.Memory.create(info.getOs().swap().total().bytes());
9584
final HostInfo hostInfo = HostInfo.create(macAddress, cpu, memory, swap);
9685

9786
final List<String> garbageCollectors;

0 commit comments

Comments
 (0)