Added net to be returned from api in backend for infra.
This commit is contained in:
1 parent
729f107af2
commit
5c147562b3
3 files changed
+103
-1
No files matched your search
@@ -40,6 +40,20 @@ const captureSchema = mongoose.Schema({
|
|||||||
mode: { type: String, default: "" },
|
mode: { type: String, default: "" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const networkInterfaceSchema = mongoose.Schema({
|
||||||
|
name: { type: String, required: true },
|
||||||
|
bytes_sent: { type: Number, default: 0 },
|
||||||
|
bytes_recv: { type: Number, default: 0 },
|
||||||
|
packets_sent: { type: Number, default: 0 },
|
||||||
|
packets_recv: { type: Number, default: 0 },
|
||||||
|
err_in: { type: Number, default: 0 },
|
||||||
|
err_out: { type: Number, default: 0 },
|
||||||
|
drop_in: { type: Number, default: 0 },
|
||||||
|
drop_out: { type: Number, default: 0 },
|
||||||
|
fifo_in: { type: Number, default: 0 },
|
||||||
|
fifo_out: { type: Number, default: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
const HardwareCheckSchema = mongoose.Schema(
|
const HardwareCheckSchema = mongoose.Schema(
|
||||||
{
|
{
|
||||||
...BaseCheckSchema.obj,
|
...BaseCheckSchema.obj,
|
||||||
@@ -69,6 +83,11 @@ const HardwareCheckSchema = mongoose.Schema(
|
|||||||
type: captureSchema,
|
type: captureSchema,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
net: {
|
||||||
|
type: [networkInterfaceSchema],
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
|
|||||||
diskCount: {
|
diskCount: {
|
||||||
$size: "$disk",
|
$size: "$disk",
|
||||||
},
|
},
|
||||||
|
netCount: { $size: "$net" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -227,6 +228,7 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
|
|||||||
from: "hardwarechecks",
|
from: "hardwarechecks",
|
||||||
let: {
|
let: {
|
||||||
diskCount: "$diskCount",
|
diskCount: "$diskCount",
|
||||||
|
netCount: "$netCount",
|
||||||
},
|
},
|
||||||
pipeline: [
|
pipeline: [
|
||||||
{
|
{
|
||||||
@@ -258,6 +260,9 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
|
|||||||
disks: {
|
disks: {
|
||||||
$push: "$disk",
|
$push: "$disk",
|
||||||
},
|
},
|
||||||
|
net: {
|
||||||
|
$push: "$net",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -371,6 +376,83 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
net: {
|
||||||
|
$map: {
|
||||||
|
input: { $range: [0, "$$netCount"] },
|
||||||
|
as: "netIndex",
|
||||||
|
in: {
|
||||||
|
name: {
|
||||||
|
$concat: ["net", { $toString: "$$netIndex" }],
|
||||||
|
},
|
||||||
|
bytesSent: {
|
||||||
|
$avg: {
|
||||||
|
$map: {
|
||||||
|
input: "$net",
|
||||||
|
as: "netArray",
|
||||||
|
in: {
|
||||||
|
$arrayElemAt: ["$$netArray.bytes_sent", "$$netIndex"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
bytesRecv: {
|
||||||
|
$avg: {
|
||||||
|
$map: {
|
||||||
|
input: "$net",
|
||||||
|
as: "netArray",
|
||||||
|
in: {
|
||||||
|
$arrayElemAt: ["$$netArray.bytes_recv", "$$netIndex"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
packetsSent: {
|
||||||
|
$avg: {
|
||||||
|
$map: {
|
||||||
|
input: "$net",
|
||||||
|
as: "netArray",
|
||||||
|
in: {
|
||||||
|
$arrayElemAt: ["$$netArray.packets_sent", "$$netIndex"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
packetsRecv: {
|
||||||
|
$avg: {
|
||||||
|
$map: {
|
||||||
|
input: "$net",
|
||||||
|
as: "netArray",
|
||||||
|
in: {
|
||||||
|
$arrayElemAt: ["$$netArray.packets_recv", "$$netIndex"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
errIn: {
|
||||||
|
$avg: {
|
||||||
|
$map: {
|
||||||
|
input: "$net",
|
||||||
|
as: "netArray",
|
||||||
|
in: {
|
||||||
|
$arrayElemAt: ["$$netArray.errin", "$$netIndex"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
errOut: {
|
||||||
|
$avg: {
|
||||||
|
$map: {
|
||||||
|
input: "$net",
|
||||||
|
as: "netArray",
|
||||||
|
in: {
|
||||||
|
$arrayElemAt: ["$$netArray.errout", "$$netIndex"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ class StatusService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === "hardware") {
|
if (type === "hardware") {
|
||||||
const { cpu, memory, disk, host } = payload?.data ?? {};
|
const { cpu, memory, disk, host, net } = payload?.data ?? {};
|
||||||
const { errors } = payload?.errors ?? [];
|
const { errors } = payload?.errors ?? [];
|
||||||
check.cpu = cpu ?? {};
|
check.cpu = cpu ?? {};
|
||||||
check.memory = memory ?? {};
|
check.memory = memory ?? {};
|
||||||
@@ -240,6 +240,7 @@ class StatusService {
|
|||||||
check.host = host ?? {};
|
check.host = host ?? {};
|
||||||
check.errors = errors ?? [];
|
check.errors = errors ?? [];
|
||||||
check.capture = payload?.capture ?? {};
|
check.capture = payload?.capture ?? {};
|
||||||
|
check.net = net ?? {};
|
||||||
}
|
}
|
||||||
return check;
|
return check;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user