saveCUrrentSystemInfo improvements

This commit is contained in:
YevhenBondarenko 2023-03-16 10:21:40 +01:00
parent 118fc1554a
commit d13a458eb0

View File

@ -111,12 +111,22 @@ public class DefaultSystemInfoService implements SystemInfoService {
return systemInfo;
}
private void saveCurrentSystemInfo() {
protected void saveCurrentSystemInfo() {
long ts = System.currentTimeMillis();
List<TsKvEntry> tsList = new ArrayList<>();
tsList.add(new BasicTsKvEntry(ts, new LongDataEntry("memoryUsage", getMemoryUsage())));
tsList.add(new BasicTsKvEntry(ts, new DoubleDataEntry("cpuUsage", getCpuUsage())));
tsList.add(new BasicTsKvEntry(ts, new LongDataEntry("freeDiscSpace", getFreeDiscSpace())));
Long memoryUsage = getMemoryUsage();
if (memoryUsage != null) {
tsList.add(new BasicTsKvEntry(ts, new LongDataEntry("memoryUsage", memoryUsage)));
}
Double cpuUsage = getCpuUsage();
if (cpuUsage != null) {
tsList.add(new BasicTsKvEntry(ts, new DoubleDataEntry("cpuUsage", cpuUsage)));
}
Long freeDiscSpace = getFreeDiscSpace();
if (freeDiscSpace != null) {
tsList.add(new BasicTsKvEntry(ts, new LongDataEntry("freeDiscSpace", freeDiscSpace)));
}
telemetryService.saveAndNotifyInternal(TenantId.SYS_TENANT_ID, TenantId.SYS_TENANT_ID, tsList, CALLBACK);
}