Merge pull request #1199 from bluewave-labs/feat/fe/infra-monitor-temp

feat/fe/infra monitor temp
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-11-26 18:05:05 -08:00
commit 698bf2ba3e
9 files changed
+545 -207

No files matched your search

+2 -1
View File
@@ -4,7 +4,7 @@ const cpuSchema = mongoose.Schema({
physical_core: { type: Number, default: 0 },
logical_core: { type: Number, default: 0 },
frequency: { type: Number, default: 0 },
temperature: { type: Number, default: 0 },
temperature: { type: [Number], default: [] },
free_percent: { type: Number, default: 0 },
usage_percent: { type: Number, default: 0 },
});
@@ -54,6 +54,7 @@ const HardwareCheckSchema = mongoose.Schema(
type: hostSchema,
default: () => ({}),
},
errors: {
type: [errorSchema],
default: () => [],
+33
View File
@@ -38,9 +38,42 @@ const NotificationSchema = mongoose.Schema(
return this.alertThreshold;
},
},
tempAlertThreshold: {
type: Number,
default: function () {
return this.alertThreshold;
},
},
},
{
timestamps: true,
}
);
NotificationSchema.pre("save", function (next) {
if (!this.cpuAlertThreshold || this.isModified("alertThreshold")) {
this.cpuAlertThreshold = this.alertThreshold;
}
if (!this.memoryAlertThreshold || this.isModified("alertThreshold")) {
this.memoryAlertThreshold = this.alertThreshold;
}
if (!this.diskAlertThreshold || this.isModified("alertThreshold")) {
this.diskAlertThreshold = this.alertThreshold;
}
if (!this.tempAlertThreshold || this.isModified("alertThreshold")) {
this.tempAlertThreshold = this.alertThreshold;
}
next();
});
NotificationSchema.pre("findOneAndUpdate", function (next) {
const update = this.getUpdate();
if (update.alertThreshold) {
update.cpuAlertThreshold = update.alertThreshold;
update.memoryAlertThreshold = update.alertThreshold;
update.diskAlertThreshold = update.alertThreshold;
update.tempAlertThreshold = update.alertThreshold;
}
next();
});
export default mongoose.model("Notification", NotificationSchema);
+1
View File
@@ -205,6 +205,7 @@ const createMonitorBodyValidation = joi.object({
usage_cpu: joi.number(),
usage_memory: joi.number(),
usage_disk: joi.number(),
usage_temperature: joi.number(),
}),
notifications: joi.array().items(joi.object()),
secret: joi.string(),