Skip to content

Commit

Permalink
Merge pull request #996 from bluewave-labs/feat/be/hardware-monitorin…
Browse files Browse the repository at this point in the history
…g-model

feat/be/hardware-checks-model references #985
  • Loading branch information
ajhollid authored Oct 22, 2024
2 parents 62c5087 + 433dbf1 commit 9be1441
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions Server/db/models/HardwareCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import mongoose from "mongoose";

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 },
free_percent: { type: Number, default: 0 },
usage_percent: { type: Number, default: 0 },
});

const memorySchema = mongoose.Schema({
total_bytes: { type: Number, default: 0 },
available_bytes: { type: Number, default: 0 },
used_bytes: { type: Number, default: 0 },
usage_percent: { type: Number, default: 0 },
});

const discSchema = mongoose.Schema({
read_speed_bytes: { type: Number, default: 0 },
write_speed_bytes: { type: Number, default: 0 },
total_bytes: { type: Number, default: 0 },
free_bytes: { type: Number, default: 0 },
usage_percent: { type: Number, default: 0 },
});

const hostSchema = mongoose.Schema({
os: { type: String, default: "" },
platform: { type: String, default: "" },
kernel_version: { type: String, default: "" },
});

const HardwareCheckSchema = mongoose.Schema(
{
monitorId: {
type: mongoose.Schema.Types.ObjectId,
ref: "Monitor",
immutable: true,
},
cpu: {
type: cpuSchema,
default: () => ({}),
},
memory: {
type: memorySchema,
default: () => ({}),
},
disk: {
type: [discSchema],
default: () => [],
},
host: {
type: hostSchema,
default: () => ({}),
},
},
{ timestamps: true }
);

export default mongoose.model("HardwareCheck", HardwareCheckSchema);

0 comments on commit 9be1441

Please sign in to comment.