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

upsmon: ALARM status should be handled/handleable #2657

Open
desertwitch opened this issue Oct 14, 2024 · 1 comment · May be fixed by #2658
Open

upsmon: ALARM status should be handled/handleable #2657

desertwitch opened this issue Oct 14, 2024 · 1 comment · May be fixed by #2658

Comments

@desertwitch
Copy link
Contributor

desertwitch commented Oct 14, 2024

This is more of an enhancement request, but I think it's also a bit of an issue considering alarms can have consequences.

In the current codebase various drivers utilize ups.alarm for raising device-/manufacturer-specific alarms. There is additional common code in dstate.c, evaluating if such ups.alarm variables are preset and, if so, set a status ALARM:

nut/drivers/dstate.c

Lines 1696 to 1700 in 539d970

if (alarm_active) {
dstate_setinfo("ups.status", "ALARM %s", status_buf);
} else {
dstate_setinfo("ups.status", "%s", status_buf);
}

Right now, in an unattended setting, specifically checking the UPS status and UPS variables for active alarms seems needed. This is because at present upsmon seems to have no specific code handling an ALARM status and hence it cannot be acted on with upssched or other means of notification processing. As the drivers seem to already be handling alarms one way or another, and this is unified by dstate.c with a status ALARM as common denominator, uspmon code seems to be the remaining piece of the puzzle to actively be able to handle and act on alarms and an associated ALARM status of the UPS.

We should introduce upsmon code with a flag ST_ALARM and associated NOTIFY_ALARM & NOTIFY_NOALARM for the user to be able to act on ALARM. Such code residing in upsmon would make sense to process an ALARM status (as set by dstate.c) as a common denominator for different ways of handling alarms within the UPS drivers themselves. UPS alarms can raise potentially grave issues of the UPS and users should be able to configure e.g. upssched tasks or notifiers accordingly:

NOTIFYFLAG ALARM EXEC
NOTIFYFLAG NOTALARM EXEC

ALARM being when the ALARM status is set on the UPS
NOTALARM being when the ALARM status is no longer set on the UPS

Ideally this could be accompanied by respective SYSLOG warning messages with the specific alarm message, both when set and later removed again by the UPS driver, although this might require more advanced tracking of the individual alarms and is possibly overkill as opposed to handling a simple if (flag_isset(ups->status, ST_ALARM).

UPS %s is now in status ALARM (first-time) with message: %s.
UPS %s is no longer in status ALARM, all alarms have cleared.
@desertwitch
Copy link
Contributor Author

P.S. I'm currently working on this and will be submitting a pull request once I have something semi-functional. 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants