2024-10-15 11:57:37 +08:00
|
|
|
import mongoose from "mongoose";
|
2024-07-30 12:54:35 -07:00
|
|
|
const NotificationSchema = mongoose.Schema(
|
2024-10-17 12:07:30 +08:00
|
|
|
{
|
|
|
|
|
monitorId: {
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: "Monitor",
|
|
|
|
|
immutable: true,
|
|
|
|
|
},
|
|
|
|
|
type: {
|
|
|
|
|
type: String,
|
|
|
|
|
enum: ["email", "sms"],
|
|
|
|
|
},
|
|
|
|
|
address: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
phone: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2024-11-22 11:52:32 +08:00
|
|
|
alertThreshold: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 5,
|
|
|
|
|
},
|
|
|
|
|
cpuAlertThreshold: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: function () {
|
|
|
|
|
return this.alertThreshold;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
memoryAlertThreshold: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: function () {
|
|
|
|
|
return this.alertThreshold;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
diskAlertThreshold: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: function () {
|
|
|
|
|
return this.alertThreshold;
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-10-17 12:07:30 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
timestamps: true,
|
|
|
|
|
}
|
2024-07-30 12:54:35 -07:00
|
|
|
);
|
2024-10-15 11:57:37 +08:00
|
|
|
export default mongoose.model("Notification", NotificationSchema);
|