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

Added more variables from the CyberPower MIB #1982

Merged
merged 6 commits into from
Aug 14, 2023
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
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ as part of https://github.com/networkupstools/nut/issues/1410 solution.
of valid outlet status values [#1871]
* `cyberpower-mib.c` subdriver: support devices which report the shorter
Vendor OID as their sysOID, e.g. "CyberPower PowerPanel Personal" [#1997]
and support more data points including hardware status alarms [#1982]

- The `bestfortress` driver shutdown handling was fixed to use a non-trivial
default timeout [#1820]
Expand Down
45 changes: 44 additions & 1 deletion drivers/cyberpower-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "cyberpower-mib.h"

#define CYBERPOWER_MIB_VERSION "0.53"
#define CYBERPOWER_MIB_VERSION "0.54"
#define CYBERPOWER_OID_MODEL_NAME ".1.3.6.1.4.1.3808.1.1.1.1.1.1.0"

/* CPS-MIB::ups */
Expand Down Expand Up @@ -75,6 +75,29 @@ static info_lkp_t cyberpower_battrepl_status[] = {
{ 0, NULL, NULL, NULL }
};

static info_lkp_t cyberpower_ups_alarm_info[] = {
{ 1, "", NULL, NULL }, /* Normal */
{ 2, "Temperature too high!", NULL, NULL }, /* Overheat */
{ 3, "Internal UPS fault!", NULL, NULL }, /* Hardware Fault */
{ 0, NULL, NULL, NULL }
};

static info_lkp_t cyberpower_transfer_reasons[] = {
{ 1, "noTransfer", NULL, NULL },
{ 2, "highLineVoltage", NULL, NULL },
{ 3, "brownout", NULL, NULL },
{ 4, "selfTest", NULL, NULL },
{ 0, NULL, NULL, NULL }
};

static info_lkp_t cyberpower_testdiag_results[] = {
{ 1, "Ok", NULL, NULL },
{ 2, "Failed", NULL, NULL },
{ 3, "InvalidTest", NULL, NULL },
{ 4, "TestInProgress", NULL, NULL },
{ 0, NULL, NULL, NULL }
};

/* Snmp2NUT lookup table for CyberPower MIB */
static snmp_info_t cyberpower_mib[] = {

Expand All @@ -91,6 +114,8 @@ static snmp_info_t cyberpower_mib[] = {
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, CYBERPOWER_OID_MODEL_NAME,
"CyberPower", SU_FLAG_STATIC, NULL },
{ "ups.id", ST_FLAG_STRING | ST_FLAG_RW, 8, ".1.3.6.1.4.1.3808.1.1.1.1.1.2.0",
"", SU_FLAG_OK | SU_FLAG_STATIC, NULL },

{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.3808.1.1.1.1.2.3.0",
"", SU_FLAG_STATIC, NULL },
Expand All @@ -110,6 +135,11 @@ static snmp_info_t cyberpower_mib[] = {
{ "ups.load", 0, 1.0, ".1.3.6.1.4.1.3808.1.1.1.4.2.3.0", "",
0, NULL },

{ "ups.temperature", 0, 1, ".1.3.6.1.4.1.3808.1.1.1.10.2.0", "", SU_FLAG_OK, NULL },

{ "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.3808.1.1.1.10.1.0", "",
SU_FLAG_OK, &cyberpower_ups_alarm_info[0] },

/* Battery runtime is expressed in seconds */
{ "battery.runtime", 0, 1.0, ".1.3.6.1.4.1.3808.1.1.1.2.2.4.0", "",
0, NULL },
Expand All @@ -133,11 +163,17 @@ static snmp_info_t cyberpower_mib[] = {
0, NULL },
{ "battery.temperature", 0, 1.0, ".1.3.6.1.4.1.3808.1.1.1.2.2.3.0", "",
0, NULL },
/* upsBaseBatteryLastReplaceDate */
{ "battery.date", ST_FLAG_STRING, 8, ".1.3.6.1.4.1.3808.1.1.1.2.1.3.0", "",
SU_FLAG_OK | SU_FLAG_SEMI_STATIC, NULL },

{ "input.voltage", 0, 0.1, ".1.3.6.1.4.1.3808.1.1.1.3.2.1.0", "",
0, NULL },
{ "input.frequency", 0, 0.1, ".1.3.6.1.4.1.3808.1.1.1.3.2.4.0", "",
0, NULL },
/* upsAdvanceInputLineFailCause */
{ "input.transfer.reason", ST_FLAG_STRING, 1, ".1.3.6.1.4.1.3808.1.1.1.3.2.5.0", "",
SU_TYPE_INT | SU_FLAG_OK, &cyberpower_transfer_reasons[0] },

{ "output.voltage", 0, 0.1, ".1.3.6.1.4.1.3808.1.1.1.4.2.1.0", "",
0, NULL },
Expand Down Expand Up @@ -176,6 +212,13 @@ static snmp_info_t cyberpower_mib[] = {
{ "calibrate.start", 0, 2, ".1.3.6.1.4.1.3808.1.1.1.7.2.6.0", NULL, SU_TYPE_CMD | SU_FLAG_OK, NULL },
{ "calibrate.stop", 0, 3, ".1.3.6.1.4.1.3808.1.1.1.7.2.6.0", NULL, SU_TYPE_CMD | SU_FLAG_OK, NULL },

/* upsAdvanceTestLastDiagnosticsDate */
{ "ups.test.date", ST_FLAG_STRING, 8, ".1.3.6.1.4.1.3808.1.1.1.7.2.4.0", "",
SU_FLAG_OK | SU_FLAG_SEMI_STATIC, NULL },
/* upsAdvanceTestDiagnosticsResults */
{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.3808.1.1.1.7.2.3.0", "",
SU_FLAG_OK, &cyberpower_testdiag_results[0] },

/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL }
} ;
Expand Down