Merge pull request #1137 from bluewave-labs/feat/be/hardware-monitor-update
feat/be/hardware monitor update
This commit is contained in:
2 files changed
+18
-4
No files matched your search
@@ -30,6 +30,11 @@ const hostSchema = mongoose.Schema({
|
|||||||
kernel_version: { type: String, default: "" },
|
kernel_version: { type: String, default: "" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const errorSchema = mongoose.Schema({
|
||||||
|
metric: { type: [String], default: [] },
|
||||||
|
err: { type: String, default: "" },
|
||||||
|
});
|
||||||
|
|
||||||
const HardwareCheckSchema = mongoose.Schema(
|
const HardwareCheckSchema = mongoose.Schema(
|
||||||
{
|
{
|
||||||
...BaseCheckSchema.obj,
|
...BaseCheckSchema.obj,
|
||||||
@@ -49,6 +54,10 @@ const HardwareCheckSchema = mongoose.Schema(
|
|||||||
type: hostSchema,
|
type: hostSchema,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
|
errors: {
|
||||||
|
type: [errorSchema],
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ class StatusService {
|
|||||||
responseTime,
|
responseTime,
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (type === "pagespeed") {
|
if (type === "pagespeed") {
|
||||||
const categories = payload.lighthouseResult?.categories;
|
const categories = payload.lighthouseResult?.categories;
|
||||||
const audits = payload.lighthouseResult?.audits;
|
const audits = payload.lighthouseResult?.audits;
|
||||||
@@ -101,10 +102,13 @@ class StatusService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === "hardware") {
|
if (type === "hardware") {
|
||||||
check.cpu = payload?.cpu ?? {};
|
const { cpu, memory, disk, host } = payload?.data ?? {};
|
||||||
check.memory = payload?.memory ?? {};
|
const { errors } = payload;
|
||||||
check.disk = payload?.disk ?? {};
|
check.cpu = cpu ?? {};
|
||||||
check.host = payload?.host ?? {};
|
check.memory = memory ?? {};
|
||||||
|
check.disk = disk ?? {};
|
||||||
|
check.host = host ?? {};
|
||||||
|
check.errors = errors ?? [];
|
||||||
}
|
}
|
||||||
return check;
|
return check;
|
||||||
};
|
};
|
||||||
@@ -131,6 +135,7 @@ class StatusService {
|
|||||||
hardware: this.db.createHardwareCheck,
|
hardware: this.db.createHardwareCheck,
|
||||||
};
|
};
|
||||||
const operation = operationMap[networkResponse.type];
|
const operation = operationMap[networkResponse.type];
|
||||||
|
|
||||||
const check = this.buildCheck(networkResponse);
|
const check = this.buildCheck(networkResponse);
|
||||||
await operation(check);
|
await operation(check);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in new issue
Block a user