Merge pull request #1137 from bluewave-labs/feat/be/hardware-monitor-update

feat/be/hardware monitor update
This commit is contained in:
Alexander Holliday
2024-11-11 15:17:34 -08:00
committed by GitHub
2 changed files with 18 additions and 4 deletions
+9
View File
@@ -30,6 +30,11 @@ const hostSchema = mongoose.Schema({
kernel_version: { type: String, default: "" },
});
const errorSchema = mongoose.Schema({
metric: { type: [String], default: [] },
err: { type: String, default: "" },
});
const HardwareCheckSchema = mongoose.Schema(
{
...BaseCheckSchema.obj,
@@ -49,6 +54,10 @@ const HardwareCheckSchema = mongoose.Schema(
type: hostSchema,
default: () => ({}),
},
errors: {
type: [errorSchema],
default: () => [],
},
},
{ timestamps: true }
);
+9 -4
View File
@@ -83,6 +83,7 @@ class StatusService {
responseTime,
message,
};
if (type === "pagespeed") {
const categories = payload.lighthouseResult?.categories;
const audits = payload.lighthouseResult?.audits;
@@ -101,10 +102,13 @@ class StatusService {
}
if (type === "hardware") {
check.cpu = payload?.cpu ?? {};
check.memory = payload?.memory ?? {};
check.disk = payload?.disk ?? {};
check.host = payload?.host ?? {};
const { cpu, memory, disk, host } = payload?.data ?? {};
const { errors } = payload;
check.cpu = cpu ?? {};
check.memory = memory ?? {};
check.disk = disk ?? {};
check.host = host ?? {};
check.errors = errors ?? [];
}
return check;
};
@@ -131,6 +135,7 @@ class StatusService {
hardware: this.db.createHardwareCheck,
};
const operation = operationMap[networkResponse.type];
const check = this.buildCheck(networkResponse);
await operation(check);
} catch (error) {