Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arista-switch: add check for power supply #205

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/modules/arista-switch/container/services/status-checkpower.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

const StatusItem = require("@core/StatusItem");
const mongoSingle = require("@core/mongo-single");

module.exports = async () => {
const power = await mongoSingle.get("power");
const statusItems = [];

for (const [key, value] of Object.entries(power)) {
if (value.state === "powerLoss") {
statusItems.push(
new StatusItem({
key: `power${key}`,
message: [`Power supply ${key} has failed`],
type: "warning",
})
);
}
}

return statusItems;
};
4 changes: 3 additions & 1 deletion src/modules/arista-switch/container/services/status-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const statusCheckCollection = require("@core/status-checkcollection");
const statusCheckPending = require("@services/status-checkpending");
const statusCheckInterfaceStatus = require("@services/status-checkinterfacestatus");
const statusCheckSfps = require("@services/status-checksfps");
const statusCheckPower = require("@services/status-checkpower");

module.exports = async () => {
return [].concat(
Expand All @@ -28,6 +29,7 @@ module.exports = async () => {
}),
await statusCheckPending(),
await statusCheckInterfaceStatus(),
await statusCheckSfps()
await statusCheckSfps(),
await statusCheckPower()
);
};
15 changes: 13 additions & 2 deletions src/modules/arista-switch/container/workers/worker-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const main = async () => {

while (true) {
try {
const result = await aristaApi({
const systemResult = await aristaApi({
host: workerData.address,
protocol: "https",
port: 443,
Expand All @@ -31,7 +31,18 @@ const main = async () => {
commands: ["show version"],
});

await mongoSingle.set("system", result, 120);
await mongoSingle.set("system", systemResult, 120);

const powerResult = await aristaApi({
host: workerData.address,
protocol: "https",
port: 443,
username: workerData.username,
password: workerData.password,
commands: ["show system environment power"],
});

await mongoSingle.set("power", powerResult?.["powerSupplies"], 120);
} catch (error) {}
await delay(10000);
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/arista-switch/module.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arista-switch",
"longname": "Arista Switch",
"version": "1.0.3",
"version": "1.1.0",
"description": "Monitoring and control of Arista switches",
"capabilities": ["network-switch"],
"icon": "SettingsEthernet",
Expand Down
Loading