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

Add nut server monitor #3967

Closed
wants to merge 15 commits into from

Conversation

johnelliott
Copy link

@johnelliott johnelliott commented Oct 30, 2023

Description

Resolves #3932

Hello and thank you to @CommanderStorm for on-boarding me to the project in #3932

This is my first PR to the project. I read the contributions guide and I think I'm going about the style correctly.

Some questions I had were regarding the database schema,

Otherwise I added a separate file for the monitor as Frank suggested, used the new Knex migrations, and modeled the data after the way MQTT worked since the authentication of NUT isn't http basic auth.

Some shortcomings of this patch are that I wasn't sure how to deal with isImportant and the current patch creates some noise with the toasts popping up for each ping. I'd appreciate any help that can point me in towards solving that.

Type of change

New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)

Most of the added code is anonymous functions and doesn't ad library code for other code to use, so I didn't add extra documentation

  • My changes generate no new warnings

I do see a warning I would like help with:

WARN: The ping is not effective when the status is DOWN

Screenshots

Edit Monitor

image

@@ -0,0 +1,20 @@
exports.up = function (knex) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the description you mentioned the following, what are your questions?

Some questions I had were regarding the database schema,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to know if these column names are OK and in keeping with the conventions, I think I did the right thing based on what else I saw.


const nut = new Nut(monitor.port, monitor.hostname);

nut.on("ready", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be me not knowing js enough, but I think this function is racable (have not debugged this, just a hunch)

  • First observation is, that none of the functions which are called are actually blocking (): https://www.npmjs.com/package/node-nut?activeTab=code
  • if Nut does not immediatly become ready, heartbeat being set might be missed as the event loop has already exited this function

I think this might be why you are seeing

WARN: The ping is not effective when the status is DOWN

I think the following code looks more promissing:
https://github.com/skarcha/node-nut/blob/2729b2f3a6d1bb9d9105c68c0b1cdc62933c0f81/examples/polling.js

/**
* @inheritdoc
*/
async check(monitor, heartbeat, _server) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node-nut does not seem to include a timeout function.
Given that this is doing network calls, adding such an option would be a nice touch.

@@ -166,6 +166,7 @@
"favico.js": "~0.3.10",
"jest": "~29.6.1",
"marked": "~4.2.5",
"node-nut": "^1.0.3",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this library is a good idea…
skarcha/node-nut#9 (comment)

server/monitor-types/nut.js Outdated Show resolved Hide resolved

<div class="my-3">
<label for="nutPassword" class="form-label">{{ $t("Password") }}</label>
<input id="nutPassword" v-model="monitor.nutPassword" type="password" class="form-control">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you utilise the HiddenInput component instead for all secret fields?

src/pages/EditMonitor.vue Show resolved Hide resolved
<!-- For NUT Type -->
<template v-if="monitor.type === 'nut'">
<div class="my-3">
<label for="upsName" class="form-label">UPS {{ $t("Name") }}</label>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a description on where to obtain the correct ups name might be worth it to prevent other users spending excessive time on this field

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I agree, do you think it makes sense to add it on the field description? If it's too long, where would that sort of documentation go?

Screenshot as an example of where it could live:
image

<!-- For NUT Type -->
<template v-if="monitor.type === 'nut'">
<div class="my-3">
<label for="upsName" class="form-label">UPS {{ $t("Name") }}</label>
Copy link
Collaborator

@CommanderStorm CommanderStorm Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unshure if a longer name like name of the uninterruptible power supply might be clearer and more importantly translate better.
In any case, I think it would be better if the word order ups name is correct in all languages (some are rtl) => It might be saver to include this in the translated string
Thoughts?

src/pages/EditMonitor.vue Outdated Show resolved Hide resolved
Use template string suggestion

Co-authored-by: Frank Elsinga <frank@elsinga.de>
@louislam

This comment was marked as off-topic.

@CommanderStorm
Copy link
Collaborator

CommanderStorm commented Oct 31, 2023

Another (a bit more permananet) solution might be to store the monior config as a json string.
Thoughts?

@chakflying

This comment was marked as off-topic.

Use searchable name

Co-authored-by: Frank Elsinga <frank@elsinga.de>
@johnelliott

This comment was marked as off-topic.

@louislam louislam added this to the 2.1.0 milestone Nov 1, 2023
@louislam

This comment was marked as off-topic.

@chakflying chakflying added the area:monitor Everything related to monitors label Dec 2, 2023
@dn4hc

This comment was marked as spam.

@CommanderStorm

This comment was marked as resolved.

@CommanderStorm CommanderStorm added question Further information is requested pr:needs review this PR needs a review by maintainers or other community members pr:please address review comments this PR needs a bit more work to be mergable labels May 19, 2024
@github-actions github-actions bot added the pr:please resolve merge conflict A merge-conflict needs to be addressed before reviewing makes sense again label May 19, 2024
@github-actions github-actions bot added pr:please resolve merge conflict A merge-conflict needs to be addressed before reviewing makes sense again and removed pr:please resolve merge conflict A merge-conflict needs to be addressed before reviewing makes sense again labels May 19, 2024
@CommanderStorm
Copy link
Collaborator

@johnelliott
Thanks for your work.
I am going to close the PR as there has not been any progress in nearly a year (see my review from october ^^). The PR has too many things that would have to be fixed by maintainers otherwise (which I don't have the capacity for).
Most importantly, the work that would be required due to skarcha/node-nut#9 (comment) (forking and maintaining that fork) is not something that I can do.
If you/someone else wants to fix this PR up and most importanlt there is a solution to skarcha/node-nut#9 (comment), we can reopen the PR or discuss this in a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:monitor Everything related to monitors needs:resolve-merge-conflict pr:needs review this PR needs a review by maintainers or other community members pr:please address review comments this PR needs a bit more work to be mergable pr:please resolve merge conflict A merge-conflict needs to be addressed before reviewing makes sense again question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding NUT (Network UPS Tools) Monitor Type
5 participants