From dca9db106f0e822d27507efdc9adecd2705ba9d8 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 11 Oct 2017 03:24:09 +0200 Subject: [PATCH 01/75] snmp-ups.[ch] : introduce SU_FLAG_SEMI_STATIC --- drivers/snmp-ups.c | 29 +++++++++++++++++++++++++++++ drivers/snmp-ups.h | 11 +++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 9d40fc57cd..3b0a96d5e7 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -133,6 +133,9 @@ struct snmp_session g_snmp_sess, *g_snmp_sess_p; const char *OID_pwr_status; int g_pwr_battery; int pollfreq; /* polling frequency */ +int semistaticfreq; /* semistatic entry update frequency */ +static int semistatic_countdown = 0; + static int quirk_symmetra_threephase = 0; /* Number of device(s): standard is "1", but talking @@ -368,6 +371,8 @@ void upsdrv_makevartable(void) "Set SNMP version (default=v1, allowed: v2c,v3)"); addvar(VAR_VALUE, SU_VAR_POLLFREQ, "Set polling frequency in seconds, to reduce network flow (default=30)"); + addvar(VAR_VALUE, SU_VAR_SEMISTATICFREQ, + "Set semistatic value update frequency in update cycles, to reduce network flow (default=10)"); addvar(VAR_VALUE, SU_VAR_RETRIES, "Specifies the number of Net-SNMP retries to be used in the requests (default=5)"); addvar(VAR_VALUE, SU_VAR_TIMEOUT, @@ -597,6 +602,17 @@ void upsdrv_initups(void) else pollfreq = DEFAULT_POLLFREQ; + /* init semistatic update frequency */ + if (getval(SU_VAR_SEMISTATICFREQ)) + semistaticfreq = atoi(getval(SU_VAR_SEMISTATICFREQ)); + else + semistaticfreq = DEFAULT_SEMISTATICFREQ; + if (semistaticfreq < 1) { + upsdebugx(1, "Bad %s value provided, setting to default", SU_VAR_SEMISTATICFREQ); + semistaticfreq = DEFAULT_SEMISTATICFREQ; + } + semistatic_countdown = semistaticfreq; + /* Get UPS Model node to see if there's a MIB */ /* FIXME: extend and use match_model_OID(char *model) */ su_info_p = su_find_info("ups.model"); @@ -2956,6 +2972,12 @@ bool_t snmp_ups_walk(int mode) snmp_info_t *su_info_p; bool_t status = FALSE; + if (mode == SU_WALKMODE_UPDATE) { + semistatic_countdown--; + if (semistatic_countdown < 0) + semistatic_countdown = semistaticfreq; + } + /* Loop through all device(s) */ /* Note: considering "unitary" and "daisy-chained" devices, we have * several variables (and their values) that can come into play: @@ -3063,6 +3085,13 @@ bool_t snmp_ups_walk(int mode) if ((mode == SU_WALKMODE_UPDATE) && !(su_info_p->flags & SU_FLAG_OK)) continue; + /* skip semi-static elements in update mode: only parse when countdown reaches 0 */ + if ((mode == SU_WALKMODE_UPDATE) && (su_info_p->flags & SU_FLAG_SEMI_STATIC)) { + if (semistatic_countdown != 0) + continue; + upsdebugx(1, "Refreshing semi-static entry %s", su_info_p->OID); + } + /* skip static elements in update mode */ if ((mode == SU_WALKMODE_UPDATE) && (su_info_p->flags & SU_FLAG_STATIC)) continue; diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 4c870138d3..705c6c7b35 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -90,6 +90,7 @@ #define DEFAULT_POLLFREQ 30 /* in seconds */ #define DEFAULT_NETSNMP_RETRIES 5 #define DEFAULT_NETSNMP_TIMEOUT 1 /* in seconds */ +#define DEFAULT_SEMISTATICFREQ 10 /* in snmpwalk update cycles */ /* use explicit booleans */ #ifndef FALSE @@ -157,7 +158,7 @@ typedef struct { info_lkp_t *oid2info; /* lookup table between OID and NUT values */ } snmp_info_t; -/* "flags" bits 0..8 (and 9 reserved for DMF) */ +/* "flags" bits 0..9 */ #define SU_FLAG_OK (1UL << 0) /* show element to upsd - * internal to snmp driver */ #define SU_FLAG_STATIC (1UL << 1) /* retrieve info only once. */ @@ -175,9 +176,9 @@ typedef struct { #define SU_FLAG_NAINVALID (1UL << 7) /* Invalid if "N/A" value */ #define SU_CMD_OFFSET (1UL << 8) /* Add +1 to the OID index */ -/* Reserved slot -- to import from DMF branch codebase: -//#define SU_FLAG_SEMI_STATIC (1UL << 9)*/ /* Refresh this entry once in several walks -// * (for R/W values user can set on device, like descriptions or contacts) */ +#define SU_FLAG_SEMI_STATIC (1UL << 9) /* Refresh this entry once in several walks + * (for R/W values user can set on device, + * like descriptions or contacts) */ /* Notes on outlet templates usage: * - outlet.count MUST exist and MUST be declared before any outlet template @@ -255,6 +256,7 @@ typedef struct { #define SU_VAR_VERSION "snmp_version" #define SU_VAR_RETRIES "snmp_retries" #define SU_VAR_TIMEOUT "snmp_timeout" +#define SU_VAR_SEMISTATICFREQ "semistaticfreq" #define SU_VAR_MIBS "mibs" #define SU_VAR_POLLFREQ "pollfreq" /* SNMP v3 related parameters */ @@ -366,6 +368,7 @@ extern const char *OID_pwr_status; extern int g_pwr_battery; extern int pollfreq; /* polling frequency */ extern int input_phases, output_phases, bypass_phases; +extern int semistaticfreq; /* semistatic entry update frequency */ /* pointer to the Snmp2Nut lookup table */ extern mib2nut_info_t *mib2nut_info; From a00572cc39050541fe6d262256e0a73a070bfeb5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 13 May 2016 17:48:12 +0200 Subject: [PATCH 02/75] drivers/apc-iem-mib.h: split some macro definitions away from apc-mib.h and apc-mib.c and snmp-ups.c --- drivers/Makefile.am | 2 +- drivers/apc-iem-mib.h | 19 +++++++++++++++++++ drivers/apc-mib.c | 6 ------ drivers/apc-mib.h | 10 +--------- 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 drivers/apc-iem-mib.h diff --git a/drivers/Makefile.am b/drivers/Makefile.am index fc1f2f4e6f..d6ea8c9c50 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -313,7 +313,7 @@ nutdrv_qx_SOURCES += $(NUTDRV_QX_SUBDRIVERS) # tracking (which is automatic), but to ensure these files are # distributed by "make dist". -dist_noinst_HEADERS = apc-mib.h apc-hid.h arduino-hid.h baytech-mib.h bcmxcp.h bcmxcp_ser.h \ +dist_noinst_HEADERS = apc-mib.h apc-iem-mib.h apc-hid.h arduino-hid.h baytech-mib.h bcmxcp.h bcmxcp_ser.h \ bcmxcp_io.h belkin.h belkin-hid.h bestpower-mib.h blazer.h cps-hid.h dstate.h \ dummy-ups.h explore-hid.h gamatronic.h genericups.h \ hidparser.h hidtypes.h ietf-mib.h libhid.h libshut.h nut_libusb.h liebert-hid.h \ diff --git a/drivers/apc-iem-mib.h b/drivers/apc-iem-mib.h new file mode 100644 index 0000000000..65904e68c0 --- /dev/null +++ b/drivers/apc-iem-mib.h @@ -0,0 +1,19 @@ +#ifndef APC_IEM_MIB_H +#define APC_IEM_MIB_H + +/* + * FIXME: The below is needed because the main driver body uses this to determine + * whether a conversion from Fahrenheit to Celsius is needed (which really should + * be solved in subdriver specific formatting functions, like we do in usbhid-ups + * This is used in both snmp-ups.c and apc.c logics. + */ + +/* IEM ambient variables */ +/* IEM: integrated environment monitor probe */ + +#define APCC_OID_IEM_TEMP ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1" +#define APCC_OID_IEM_TEMP_UNIT ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.1" +#define APCC_IEM_FAHRENHEIT 2 +#define APCC_OID_IEM_HUMID ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.1" + +#endif /* APC_IEM_MIB_H */ diff --git a/drivers/apc-mib.c b/drivers/apc-mib.c index d640d2c6ef..1ac0a27816 100644 --- a/drivers/apc-mib.c +++ b/drivers/apc-mib.c @@ -276,13 +276,7 @@ static snmp_info_t apcc_mib[] = { { "ambient.humidity", 0, 1, ".1.3.6.1.4.1.318.1.1.2.1.2.0", "", SU_FLAG_OK, NULL }, { "ambient.1.humidity.alarm.high", 0, 1, ".1.3.6.1.4.1.318.1.1.10.1.2.2.1.6.1", "", SU_FLAG_OK, NULL }, { "ambient.1.humidity.alarm.low", 0, 1, ".1.3.6.1.4.1.318.1.1.10.1.2.2.1.7.1", "", SU_FLAG_OK, NULL }, - - /* IEM ambient variables */ /* IEM: integrated environment monitor probe */ -#define APCC_OID_IEM_TEMP ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1" -#define APCC_OID_IEM_TEMP_UNIT ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.1" -#define APCC_IEM_FAHRENHEIT 2 -#define APCC_OID_IEM_HUMID ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.1" { "ambient.temperature", 0, 1, APCC_OID_IEM_TEMP, "", SU_FLAG_OK, NULL }, { "ambient.humidity", 0, 1, APCC_OID_IEM_HUMID, "", SU_FLAG_OK, NULL }, diff --git a/drivers/apc-mib.h b/drivers/apc-mib.h index e5aeb07220..0b510ea4f6 100644 --- a/drivers/apc-mib.h +++ b/drivers/apc-mib.h @@ -3,15 +3,7 @@ #include "main.h" #include "snmp-ups.h" - -/* - * FIXME: The below is needed because the main driver body uses this to determine - * whether a conversion from Fahrenheit to Celsius is needed (which really should - * be solved in subdriver specific formatting functions, like we do in usbhid-ups - */ -#define APCC_OID_IEM_TEMP ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1" -#define APCC_OID_IEM_TEMP_UNIT ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.1" -#define APCC_IEM_FAHRENHEIT 2 +#include "apc-iem-mib.h" extern mib2nut_info_t apc; From bdfa8777c2a2ef9d7364eb382be60e7e4f5cdca0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 23 Aug 2017 19:40:28 +0200 Subject: [PATCH 03/75] Expel the helper function that interacts with dstate from eaton-pdu-marlin-mib.c to eaton-pdu-marlin-helpers.c/.h --- drivers/Makefile.am | 4 +-- drivers/eaton-pdu-marlin-helpers.c | 58 ++++++++++++++++++++++++++++++ drivers/eaton-pdu-marlin-helpers.h | 31 ++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 drivers/eaton-pdu-marlin-helpers.c create mode 100644 drivers/eaton-pdu-marlin-helpers.h diff --git a/drivers/Makefile.am b/drivers/Makefile.am index d6ea8c9c50..6bc4f4262d 100644 --- a/drivers/Makefile.am +++ b/drivers/Makefile.am @@ -232,7 +232,7 @@ snmp_ups_SOURCES = snmp-ups.c snmp-ups-helpers.c \ baytech-mib.c bestpower-mib.c \ compaq-mib.c cyberpower-mib.c \ delta_ups-mib.c \ - eaton-pdu-genesis2-mib.c eaton-pdu-marlin-mib.c \ + eaton-pdu-genesis2-mib.c eaton-pdu-marlin-mib.c eaton-pdu-marlin-helpers.c \ eaton-pdu-pulizzi-mib.c eaton-pdu-revelation-mib.c \ eaton-ats16-nmc-mib.c eaton-ats16-nm2-mib.c apc-ats-mib.c eaton-ats30-mib.c \ emerson-avocent-pdu-mib.c \ @@ -329,7 +329,7 @@ dist_noinst_HEADERS = apc-mib.h apc-iem-mib.h apc-hid.h arduino-hid.h baytech-mi nutdrv_qx_megatec.h nutdrv_qx_megatec-old.h nutdrv_qx_mustek.h nutdrv_qx_q1.h nutdrv_qx_hunnox.h \ nutdrv_qx_voltronic.h nutdrv_qx_voltronic-qs.h nutdrv_qx_voltronic-qs-hex.h nutdrv_qx_zinto.h \ xppc-mib.h huawei-mib.h eaton-ats16-nmc-mib.h eaton-ats16-nm2-mib.h apc-ats-mib.h raritan-px2-mib.h eaton-ats30-mib.h \ - apc-pdu-mib.h ever-hid.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h \ + apc-pdu-mib.h ever-hid.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h eaton-pdu-marlin-helpers.h \ eaton-pdu-pulizzi-mib.h eaton-pdu-revelation-mib.h emerson-avocent-pdu-mib.h legrand-hid.h \ hpe-pdu-mib.h powervar-hid.h delta_ups-hid.h generic_modbus.h salicru-hid.h diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c new file mode 100644 index 0000000000..ae806e086f --- /dev/null +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -0,0 +1,58 @@ +/* eaton-pdu-marlin-helpers.c - helper routines for eaton-pdu-marlin-mib.c + * to monitor Eaton ePDUs branded as: + * G2 Marlin SW / MI / MO / MA + * G3 Shark SW / MI / MO / MA + * + * Copyright (C) 2017 + * Arnaud Quette + * Copyright (C) 2017 + * Jim Klimov + * + * Supported by Eaton + * and previously MGE Office Protection Systems + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "dstate.h" + +static char marlin_scratch_buf[20]; + +/* Compute the phase to which an outlet group is connected + * WRT the number of phase(s) and the outlet group number. + * Note that the group type (marlin_outlet_group_type_info) is + * not considered since this applies to any kind of group */ +static const char *marlin_outlet_group_phase_fun(int outlet_group_nb) +{ + const char* str_phases_nb = dstate_getinfo("input.phases"); + int phases_nb = 1; + if (str_phases_nb) { + phases_nb = atoi(str_phases_nb); + if (phases_nb == 1) { + return "L1"; + } + else { /* 3ph assumed, 2ph PDU don't exist! */ + if (outlet_group_nb > 3) + snprintf(marlin_scratch_buf, 3, "L%i", (outlet_group_nb -3)); + else + snprintf(marlin_scratch_buf, 3, "L%i", outlet_group_nb); + + return marlin_scratch_buf; + } + } + return NULL; +} diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h new file mode 100644 index 0000000000..b26e1793b0 --- /dev/null +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -0,0 +1,31 @@ +/* eaton-pdu-marlin-helpers.h - helper for subdriver to monitor certain + * Eaton ePDU SNMP devices with NUT + * + * Copyright (C) + * 2017 Arnaud Quette + * 2017 Jim Klimov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef EATON_EPDU_MARLIN_HELPERS_H +#define EATON_EPDU_MARLIN_HELPERS_H + +#include "main.h" +#include "snmp-ups.h" + +static const char *marlin_outlet_group_phase_fun(int outlet_group_nb); + +#endif /* EATON_EPDU_MARLIN_HELPERS_H */ From 19b52b97a68d30cfed606c4408e3104a88875cf8 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 24 Aug 2017 12:11:43 +0200 Subject: [PATCH 04/75] eaton-pdu-marlin-helpers.c : update comments for marlin_outlet_group_phase_fun() --- drivers/eaton-pdu-marlin-helpers.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index ae806e086f..e7b1a82f56 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -28,14 +28,22 @@ * */ +#include +#include +#include + #include "dstate.h" static char marlin_scratch_buf[20]; /* Compute the phase to which an outlet group is connected * WRT the number of phase(s) and the outlet group number. - * Note that the group type (marlin_outlet_group_type_info) is - * not considered since this applies to any kind of group */ + * Note that the group type (marlin_outlet_group_type_info) + * is not considered since this applies to any kind of group. + * This trick limits input phase to electrical groups only + * (not outlet-section nor user-defined!), and for now, there + * is a maximum of 6 gangs (electrical groups). + */ static const char *marlin_outlet_group_phase_fun(int outlet_group_nb) { const char* str_phases_nb = dstate_getinfo("input.phases"); @@ -45,9 +53,9 @@ static const char *marlin_outlet_group_phase_fun(int outlet_group_nb) if (phases_nb == 1) { return "L1"; } - else { /* 3ph assumed, 2ph PDU don't exist! */ + else { /* 3ph assumed, 2ph PDU don't exist - at least not in Eaton Marlin lineup! */ if (outlet_group_nb > 3) - snprintf(marlin_scratch_buf, 3, "L%i", (outlet_group_nb -3)); + snprintf(marlin_scratch_buf, 3, "L%i", (outlet_group_nb - 3)); /* FIXME: For more than 6 ports, maybe "nb % 3"? */ else snprintf(marlin_scratch_buf, 3, "L%i", outlet_group_nb); From b2802f8ac246df973f5b18bb1f145a2ba8d18870 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 24 Aug 2017 12:27:57 +0200 Subject: [PATCH 05/75] eaton-pdu-marlin-helpers.c/h fix --- drivers/eaton-pdu-marlin-helpers.c | 3 ++- drivers/eaton-pdu-marlin-helpers.h | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index e7b1a82f56..f11f0a02d3 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -32,6 +32,7 @@ #include #include +#include "eaton-pdu-marlin-helpers.h" #include "dstate.h" static char marlin_scratch_buf[20]; @@ -44,7 +45,7 @@ static char marlin_scratch_buf[20]; * (not outlet-section nor user-defined!), and for now, there * is a maximum of 6 gangs (electrical groups). */ -static const char *marlin_outlet_group_phase_fun(int outlet_group_nb) +const char *marlin_outlet_group_phase_fun(int outlet_group_nb) { const char* str_phases_nb = dstate_getinfo("input.phases"); int phases_nb = 1; diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h index b26e1793b0..d19f7d65c6 100644 --- a/drivers/eaton-pdu-marlin-helpers.h +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -23,9 +23,6 @@ #ifndef EATON_EPDU_MARLIN_HELPERS_H #define EATON_EPDU_MARLIN_HELPERS_H -#include "main.h" -#include "snmp-ups.h" - -static const char *marlin_outlet_group_phase_fun(int outlet_group_nb); +const char *marlin_outlet_group_phase_fun(int outlet_group_nb); #endif /* EATON_EPDU_MARLIN_HELPERS_H */ From e9d45cccc4de5ff8209f303d1c6d54923f7b8a55 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 24 Aug 2017 12:14:02 +0200 Subject: [PATCH 06/75] snmp-ups / eaton-marlin : introduce WITH_SNMP_LKP_FUN to separate codebases that support these callbacks from those that currently do not --- drivers/eaton-pdu-marlin-mib.c | 110 ++++++++++++++++++++++----------- drivers/snmp-ups.c | 2 + drivers/snmp-ups.h | 21 +++++++ 3 files changed, 98 insertions(+), 35 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 729c98f1d0..87d011e1f8 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -29,7 +29,9 @@ */ #include "eaton-pdu-marlin-mib.h" -#include "dstate.h" +#if WITH_SNMP_LKP_FUN +#include "eaton-pdu-marlin-helpers.h" +#endif /* Eaton PDU-MIB - Marlin MIB * ************************** */ @@ -192,43 +194,52 @@ static info_lkp_t marlin_input_type_info[] = { { 0, NULL, NULL, NULL } }; -static char marlin_scratch_buf[20]; - -/* Compute the phase to which an outlet group is connected - * WRT the number of phase(s) and the outlet group number. - * Note that the group type (marlin_outlet_group_type_info) is - * not considered since this applies to any kind of group */ -static const char *marlin_outlet_group_phase_fun(void *raw_outlet_group_nb) -{ - int outlet_group_nb = *((int *)raw_outlet_group_nb); - const char* str_phases_nb = dstate_getinfo("input.phases"); - int phases_nb = 1; - if (str_phases_nb && (outlet_group_nb >= 0) ) { - phases_nb = atoi(str_phases_nb); - if (phases_nb == 1) { - return "L1"; - } - else { /* 3ph assumed, 2ph PDU don't exist! */ - if (outlet_group_nb > 3) - phases_nb = (outlet_group_nb - 3); - else - phases_nb = outlet_group_nb; - - snprintf(marlin_scratch_buf, sizeof(marlin_scratch_buf), "L%i", phases_nb); - if (phases_nb < 1 || phases_nb > 3) - upsdebugx(3, "WARNING: %s got %i phases which is an unexpected amount", - __func__, phases_nb); - - return marlin_scratch_buf; - } - } - return NULL; -} +#if WITH_SNMP_LKP_FUN +/* Note: marlin_outlet_group_phase_fun() is defined in eaton-pdu-marlin-helpers.c + * Future work for DMF might provide a same-named routine via LUA-C gateway. + */ static info_lkp_t marlin_outlet_group_phase_info[] = { { 1, "dummy", marlin_outlet_group_phase_fun, NULL }, { 0, NULL, NULL, NULL } }; +#else /* if not WITH_SNMP_LKP_FUN: */ + +/* FIXME: For now, DMF codebase falls back to old implementation with static + * lookup/mapping tables for this, which can easily go into the DMF XML file. + */ + +/* Ugly trick which limits input phase to electrical groups */ +static info_lkp_t marlin_outlet_group_phase1_info[] = { + /* { 0, NULL }, unknown */ + { 1, "L1" }, /* breaker1pole */ + { 2, "L1" }, /* breaker2pole */ + { 3, "L1" }, /* breaker3pole */ + /* { 4, NULL }, outlet-section */ + /* { 5, NULL }, user-defined */ + { 0, NULL } +}; +static info_lkp_t marlin_outlet_group_phase2_info[] = { + /* { 0, NULL }, unknown */ + { 1, "L2" }, /* breaker1pole */ + { 2, "L2" }, /* breaker2pole */ + { 3, "L2" }, /* breaker3pole */ + /* { 4, NULL }, outlet-section */ + /* { 5, NULL }, user-defined */ + { 0, NULL } +}; +static info_lkp_t marlin_outlet_group_phase3_info[] = { + /* { 0, NULL }, unknown */ + { 1, "L3" }, /* breaker1pole */ + { 2, "L3" }, /* breaker2pole */ + { 3, "L3" }, /* breaker3pole */ + /* { 4, NULL }, outlet-section */ + /* { 5, NULL }, user-defined */ +}; + +#endif /* WITH_SNMP_LKP_FUN */ + + /* Snmp2NUT lookup table for Eaton Marlin MIB */ static snmp_info_t eaton_marlin_mib[] = { @@ -761,11 +772,40 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.group.%i.type", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, - &marlin_outlet_group_type_info[0] }, + &marlin_outlet_group_type_info[0], NULL }, +#if WITH_SNMP_LKP_FUN { "outlet.group.%i.phase", 0, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase_info[0] }, + &marlin_outlet_group_phase_info[0], NULL }, +#else /* not WITH_SNMP_LKP_FUN */ + /* ugly trick which limits input phase to electrical groups only (not outlet-section nor user-defined!) + * For now, there is a maximum of 6 gangs (electrical groups) */ + { "outlet.group.1.phase", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.1", + NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, + &marlin_outlet_group_phase1_info[0], NULL }, + { "outlet.group.2.phase", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.2", + NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, + &marlin_outlet_group_phase2_info[0], NULL }, + { "outlet.group.3.phase", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.3", + NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, + &marlin_outlet_group_phase3_info[0], NULL }, + { "outlet.group.4.phase", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.4", + NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, + &marlin_outlet_group_phase1_info[0], NULL }, + { "outlet.group.5.phase", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.5", + NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, + &marlin_outlet_group_phase2_info[0], NULL }, + { "outlet.group.6.phase", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.6", + NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, + &marlin_outlet_group_phase3_info[0], NULL }, +#endif // WITH_SNMP_LKP_FUN /* groupControlStatus.0.1 = Integer: on (1) */ { "outlet.group.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.6.1.2.%i.%i", diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 3b0a96d5e7..7d9cfbbccb 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -2102,6 +2102,7 @@ const char *su_find_infoval(info_lkp_t *oid2info, void *raw_value) info_lkp_t *info_lkp; long value = *((long *)raw_value); +#ifdef WITH_SNMP_LKP_FUN /* First test if we have a generic lookup function */ if ( (oid2info != NULL) && (oid2info->fun_vp2s != NULL) ) { upsdebugx(2, "%s: using generic lookup function", __func__); @@ -2109,6 +2110,7 @@ const char *su_find_infoval(info_lkp_t *oid2info, void *raw_value) upsdebugx(2, "%s: got value '%s'", __func__, retvalue); return retvalue; } +#endif // WITH_SNMP_LKP_FUN /* Otherwise, use the simple values mapping */ for (info_lkp = oid2info; (info_lkp != NULL) && diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 705c6c7b35..508c5f4e8f 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -109,10 +109,30 @@ typedef int bool_t; /* typedef void (*interpreter)(char *, char *, int); */ +#ifndef WITH_SNMP_LKP_FUN +/* Recent addition of fun/nuf hooks in info_lkp_t is not well handled by + * all corners of the codebase, e.g. not by DMF. So at least until that + * is fixed, (TODO) we enable those bits of code only optionally during + * a build for particular usage. Conversely, experimenters can define + * this macro to a specific value while building the codebase and see + * what happens under different conditions ;) + */ +# if WITH_DMFMIB +# define WITH_SNMP_LKP_FUN 0 +# else +# define WITH_SNMP_LKP_FUN 1 +# endif +#endif + /* for lookup between OID values and INFO_ value */ typedef struct { int oid_value; /* SNMP OID value */ const char *info_value; /* NUT INFO_* value */ +#if WITH_SNMP_LKP_FUN +/* FIXME: Currently we do not have a way to provide custom C code + * via DMF - keep old approach until we get the ability, e.g. by + * requiring a LUA implementation to be passed alongside C lookups. + */ /* * Currently there are a few cases using a "fun_vp2s" type of lookup * function, while the "nuf_s2l" type was added for completeness but @@ -124,6 +144,7 @@ typedef struct { */ const char *(*fun_vp2s)(void *snmp_value); /* optional SNMP to NUT mapping function, converting a pointer to SNMP data (e.g. numeric or string) into a NUT string */ long (*nuf_s2l)(const char *nut_value); /* optional NUT to SNMP mapping function, converting a NUT string into SNMP numeric data */ +#endif /* WITH_SNMP_LKP_FUN */ } info_lkp_t; /* Structure containing info about one item that can be requested From a8f6e7a9022f0a530071250389865108d5d4ae14 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 30 Aug 2017 14:51:45 +0200 Subject: [PATCH 07/75] Fix typo in OID, noticed by aquette Signed-off-by: Jim Klimov --- drivers/eaton-pdu-marlin-mib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 87d011e1f8..4a5325b44d 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -782,27 +782,27 @@ static snmp_info_t eaton_marlin_mib[] = { /* ugly trick which limits input phase to electrical groups only (not outlet-section nor user-defined!) * For now, there is a maximum of 6 gangs (electrical groups) */ { "outlet.group.1.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.1", + ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.1", NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, &marlin_outlet_group_phase1_info[0], NULL }, { "outlet.group.2.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.2", + ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.2", NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, &marlin_outlet_group_phase2_info[0], NULL }, { "outlet.group.3.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.3", + ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.3", NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, &marlin_outlet_group_phase3_info[0], NULL }, { "outlet.group.4.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.4", + ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.4", NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, &marlin_outlet_group_phase1_info[0], NULL }, { "outlet.group.5.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.5", + ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.5", NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, &marlin_outlet_group_phase2_info[0], NULL }, { "outlet.group.6.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.6", + ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.6", NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, &marlin_outlet_group_phase3_info[0], NULL }, #endif // WITH_SNMP_LKP_FUN From 02fb1dc5e5fd29473d2bc3c2e230023aee6a2360 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 9 Oct 2017 21:24:49 +0200 Subject: [PATCH 08/75] eaton-pdu-marlin-mib.c : add basic listing of newly defined OIDs (not a full solution - some mapping functions are needed and revision of MIB data types) --- docs/nut-names.txt | 2 + drivers/eaton-pdu-marlin-mib.c | 109 +++++++++++++++++++++++++++++---- 2 files changed, 100 insertions(+), 11 deletions(-) diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 8c14a87e20..187f7b7efb 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -632,6 +632,8 @@ Some specific data to outlet groups exists: |================================================================================= | Name | Description | Example value | outlet.group.n.type | Type of outlet group (OPAQUE) | outlet-section +| outlet.group.n.color | Color-coding of the outlets + in this group (OPAQUE) | yellow | outlet.group.n.count | Number of outlets in the group | 12 | outlet.group.n.phase | Electrical phase to which the physical outlet group (Gang) is diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 4a5325b44d..9c02354f33 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.59" +#define EATON_MARLIN_MIB_VERSION "0.60" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -265,12 +265,28 @@ static snmp_info_t eaton_marlin_mib[] = { /* For daisychain, there is only 1 physical interface! */ { "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.2.2.1.6.2", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, - /* Daisychained devices support - * Notes: this definition is used to: + + /* Daisychained devices support */ + /* FIXME : Should this be a static value, or can we expect the amount of + * daisy-chained devices to change without restart of the driver by user? + * If this is a critical matter, should a detected change of amount of + * daisy-chained devices, outlet counts, etc. cause restart/reinit of + * this running driver instance? + */ + /* Number of daisychained units is processed according to present units + * in the chain with new G3 firmware (02.00.0051, since autumn 2017): + * Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount + * of "," separators+1 using an inline function */ + /* FIXME: inline func */ + { "device.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.1.0", + "1", SU_FLAG_STATIC | SU_FLAG_UNIQUE, + NULL, NULL /* devices_count */ }, + /* Notes: this older/fallback definition is used to: * - estimate the number of devices, based on the below OID iteration capabilities * - determine the base index of the SNMP OID (ie 0 or 1) */ { "device.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.%i", - "1", SU_FLAG_STATIC, NULL }, + "1", SU_FLAG_STATIC | SU_FLAG_UNIQUE, NULL, + NULL /* devices_count */ }, /* UPS collection */ { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON", @@ -558,6 +574,27 @@ static snmp_info_t eaton_marlin_mib[] = { { "input.L3.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.3", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, + /* Feed to which the ePDU is connected + * ??? // FIXME-Check on real device + */ + /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags */ + /* { "input.feed.%i.id", 0, 1, "???.%i.%i", NULL, SU_FLAG_NEGINVALID, NULL }, */ + /* Feed name + * inputFeedName.0.1 = Value (OctetString): A1 // FIXME-Check on real device + */ + { "input.feed.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + /* Feed A / B color + * inputFeedColor.0.1 = Value (OctetString): 0A8B9C // FIXME-Check on real device + */ + /* FIXME: RFC on key name is needed when backporting to NUT upstream */ + { "input.feed.%i.color", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_OK, NULL }, + /* ePDU "nominal power", inputPowerCapacity with .1.3.6.1.4.1.534.6.6.7.3.4.1.9.x.1.y using "input.power.nominal" (need RFC on NUT) + * TODO: sample says of ...x.1.y and no %i in the key name... + * inputPowerCapacity // FIXME-Check on real device + */ + /* FIXME: RFC on key name is needed when backporting to NUT upstream */ + { "input.power.nominal", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.9.%i.1.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, + /* Ambient collection */ { "ambient.present", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.1.1.3.%i.1", @@ -669,9 +706,18 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, /* outletID: Outlet physical name, related to its number in the group * ex: first outlet of the second group (B) is B1 */ + /* Outlet physical name OID in new G3 firmware (02.00.0051) + * outletPhysicalName.0.1 = Value (OctetString): A1 // FIXME-Check on real device + */ + { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.6.1.1.6.%i.%i", + NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, + NULL, NULL }, + /* Fallback in firmwares issued before Sep 2017: */ { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.2.%i.%i", - NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, + NULL, NULL }, /* FIXME: the last part of the OID gives the group number (i.e. %i.1 means "group 1") * Need to address that, without multiple declaration (%i.%i, SU_OUTLET | SU_OUTLET_GROUP)? */ { "outlet.%i.groupid", ST_FLAG_STRING, SU_INFOSIZE, @@ -765,18 +811,41 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, /* groupName.0.1 = OctetString: Factory Group 1 */ /* FIXME: SU_FLAG_SEMI_STATIC or SU_FLAG_SETTING => refreshed from time to time or upon call to setvar */ - { "outlet.group.%i.name", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, + /* User-friendly (writeable) description of the outlet group: */ + { "outlet.group.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.3.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + /* Outlet-group physical name + * groupPhysicalName.0.1 = Value (OctetString): GRP1 // FIXME-Check on real device + */ + { "outlet.group.%i.name", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.8.%i.%i", + NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + /* Outlet-group color + * groupBkgColor.0.1 = Value (OctetString): 0A8B9C // FIXME-Check on real device + */ + /* FIXME: RFC on key name is needed when backporting to NUT upstream */ + { "outlet.group.%i.color", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.7.%i.%i", + NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, /* groupType.0.1 = Integer: outletSection (4) */ { "outlet.group.%i.type", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, &marlin_outlet_group_type_info[0], NULL }, #if WITH_SNMP_LKP_FUN + /* Phase to which an outlet-group is connected (Caution: the value is numeric, and need to append "L" -- TODO) + * groupPhaseID // FIXME-Check on real device + */ + /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags (daisy?) */ + /* FIXME: inline func */ + { "outlet.group.%i.phase", 0, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.10.%i.%i", + NULL, SU_FLAG_UNIQUE | SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL, NULL }, { "outlet.group.%i.phase", 0, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.%i", - NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL, SU_FLAG_UNIQUE | SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, &marlin_outlet_group_phase_info[0], NULL }, #else /* not WITH_SNMP_LKP_FUN */ /* ugly trick which limits input phase to electrical groups only (not outlet-section nor user-defined!) @@ -885,6 +954,13 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.group.%i.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.5.5.1.2.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + /* Input to which an outlet-group is connected + * groupInputID // FIXME-Check on real device + */ + /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags (daisy?) */ + { "outlet.group.%i.input", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.5.1.1.9.%i.%i", + NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, /* instant commands. */ /* Notes: @@ -895,11 +971,11 @@ static snmp_info_t eaton_marlin_mib[] = { * we currently use "0", so instant On | Off | Reboot... */ /* no counterpart found! { "outlet.load.off", 0, DO_OFF, AR_OID_OUTLET_STATUS ".0", - NULL, SU_TYPE_CMD, NULL, NULL }, + NULL, SU_TYPE_CMD, NULL }, { "outlet.load.on", 0, DO_ON, AR_OID_OUTLET_STATUS ".0", - NULL, SU_TYPE_CMD, NULL, NULL }, + NULL, SU_TYPE_CMD, NULL }, { "outlet.load.cycle", 0, DO_CYCLE, AR_OID_OUTLET_STATUS ".0", - NULL, SU_TYPE_CMD, NULL, NULL }, */ + NULL, SU_TYPE_CMD, NULL }, */ /* Delays handling: * 0-n :Time in seconds until the group command is issued @@ -918,7 +994,18 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.%i.load.cycle.delay", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - /* Delays handling: + /* Per outlet shutdown / startup delay (configuration point, not the timers) + * outletControlShutoffDelay // FIXME-Check on real device + * outletControlSequenceDelay // FIXME-Check on real device ; verify OID is one component shorter? + */ + { "outlet.%i.delay.shutdown", ST_FLAG_RW, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.10.%i.%i", + NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + { "outlet.%i.delay.start", ST_FLAG_RW, 1, + ".1.3.6.1.4.1.534.6.6.7.6.1.7.%i.%i", + NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + + /* TODO: handle delays * 0-n :Time in seconds until the group command is issued * -1:Cancel a pending group-level Off/On/Reboot command */ /* groupControlOffCmd.0.1 = Integer: -1 */ From 456e6231d248c2c616e735393a731005478fa393 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 9 Oct 2017 21:44:35 +0200 Subject: [PATCH 09/75] eaton-pdu-marlin-mib.c / drivers/eaton-pdu-marlin-helpers.[ch] : Implement conversion func for "outlet.group.%i.phase" --- drivers/eaton-pdu-marlin-helpers.c | 10 ++++++++++ drivers/eaton-pdu-marlin-helpers.h | 1 + drivers/eaton-pdu-marlin-mib.c | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index f11f0a02d3..0570f60ae1 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -65,3 +65,13 @@ const char *marlin_outlet_group_phase_fun(int outlet_group_nb) } return NULL; } + +/* Take the value received from MIB, convert to string and add a prefix */ +const char *marlin_outlet_group_phase_prefix_fun(int outlet_group_input_phase) +{ + if (outlet_group_input_phase >= 1 && outlet_group_input_phase <= 3) { + snprintf(marlin_scratch_buf, 3, "L%i", outlet_group_input_phase); + return marlin_scratch_buf; + } + return NULL; +} diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h index d19f7d65c6..182cc05173 100644 --- a/drivers/eaton-pdu-marlin-helpers.h +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -24,5 +24,6 @@ #define EATON_EPDU_MARLIN_HELPERS_H const char *marlin_outlet_group_phase_fun(int outlet_group_nb); +const char *marlin_outlet_group_phase_prefix_fun(int outlet_group_input_phase); #endif /* EATON_EPDU_MARLIN_HELPERS_H */ diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 9c02354f33..95a0d015c3 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -200,6 +200,7 @@ static info_lkp_t marlin_input_type_info[] = { */ static info_lkp_t marlin_outlet_group_phase_info[] = { { 1, "dummy", marlin_outlet_group_phase_fun, NULL }, + { 2, "dummytwoo", marlin_outlet_group_phase_prefix_fun, NULL }, { 0, NULL, NULL, NULL } }; @@ -838,11 +839,10 @@ static snmp_info_t eaton_marlin_mib[] = { * groupPhaseID // FIXME-Check on real device */ /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags (daisy?) */ - /* FIXME: inline func */ { "outlet.group.%i.phase", 0, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.10.%i.%i", NULL, SU_FLAG_UNIQUE | SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, - NULL, NULL }, + &marlin_outlet_group_phase_info[1], NULL }, { "outlet.group.%i.phase", 0, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.%i", NULL, SU_FLAG_UNIQUE | SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, From a76861f4143dd869cbc8a53852320eb3ecb67757 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 9 Oct 2017 22:53:29 +0200 Subject: [PATCH 10/75] eaton-pdu-marlin-mib.c / drivers/eaton-pdu-marlin-helpers.[ch] : Implement conversion func for "device.count" which returns a comma-separated list --- drivers/eaton-pdu-marlin-helpers.c | 18 ++++++++++++++++++ drivers/eaton-pdu-marlin-helpers.h | 2 ++ drivers/eaton-pdu-marlin-mib.c | 22 +++++++++++++++++----- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 0570f60ae1..5a96a3b6cf 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -75,3 +75,21 @@ const char *marlin_outlet_group_phase_prefix_fun(int outlet_group_input_phase) } return NULL; } + +/* Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount + * of "," separators+1 using an inline function */ +const int marlin_device_count_fun(const char *daisy_dev_list) +{ + int count = 0, i; + for (i=0; daisy_dev_list[i] != '\0'; i++) { + if (daisy_dev_list[i] == ',') { + /* Each comma means a new device in the list */ + count ++; + } + } + if (i>0) { + /* Non-empty string => at least one device */ + count ++; + } + return count; +} diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h index 182cc05173..603bea19f4 100644 --- a/drivers/eaton-pdu-marlin-helpers.h +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -26,4 +26,6 @@ const char *marlin_outlet_group_phase_fun(int outlet_group_nb); const char *marlin_outlet_group_phase_prefix_fun(int outlet_group_input_phase); +const int marlin_device_count_fun(const char *daisy_dev_list); + #endif /* EATON_EPDU_MARLIN_HELPERS_H */ diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 95a0d015c3..79b7e8ccd6 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -204,6 +204,11 @@ static info_lkp_t marlin_outlet_group_phase_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t marlin_device_count_info[] = { + { 1, "dummy", NULL, marlin_device_count_fun }, + { 0, NULL, NULL, NULL } +}; + #else /* if not WITH_SNMP_LKP_FUN: */ /* FIXME: For now, DMF codebase falls back to old implementation with static @@ -274,20 +279,27 @@ static snmp_info_t eaton_marlin_mib[] = { * daisy-chained devices, outlet counts, etc. cause restart/reinit of * this running driver instance? */ +#if WITH_SNMP_LKP_FUN /* Number of daisychained units is processed according to present units * in the chain with new G3 firmware (02.00.0051, since autumn 2017): * Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount * of "," separators+1 using an inline function */ /* FIXME: inline func */ - { "device.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.1.0", + { "device.count", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.1.1.0", "1", SU_FLAG_STATIC | SU_FLAG_UNIQUE, - NULL, NULL /* devices_count */ }, + &marlin_device_count_info[0] /* devices_count */ }, +#endif /* Notes: this older/fallback definition is used to: * - estimate the number of devices, based on the below OID iteration capabilities * - determine the base index of the SNMP OID (ie 0 or 1) */ - { "device.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.%i", - "1", SU_FLAG_STATIC | SU_FLAG_UNIQUE, NULL, - NULL /* devices_count */ }, + { "device.count", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.%i", + "1", SU_FLAG_STATIC +#if WITH_SNMP_LKP_FUN + | SU_FLAG_UNIQUE +#endif + , NULL /* devices_count */ }, /* UPS collection */ { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON", From 298445f168504aab4dfac5e68af09d0b20c228b6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 11 Oct 2017 00:32:52 +0200 Subject: [PATCH 11/75] eaton-pdu-marlin-mib.c : Revised added OIDs with a single-group ePDU Also update line-breaks for readability and 80-col standard --- drivers/eaton-pdu-marlin-mib.c | 200 ++++++++++++++++++++++----------- 1 file changed, 134 insertions(+), 66 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 79b7e8ccd6..7ef6dfae52 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -250,26 +250,35 @@ static info_lkp_t marlin_outlet_group_phase3_info[] = { static snmp_info_t eaton_marlin_mib[] = { /* standard MIB items */ - { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, - { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, - { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL }, + { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, + ".1.3.6.1.2.1.1.1.0", + NULL, SU_FLAG_OK, NULL }, + { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, + ".1.3.6.1.2.1.1.4.0", + NULL, SU_FLAG_OK, NULL }, + { "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, + ".1.3.6.1.2.1.1.6.0", + NULL, SU_FLAG_OK, NULL }, /* Device collection */ - { "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + { "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, + NULL, + "EATON", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "device.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.%i", "Eaton Powerware ePDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, { "device.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.1.2.1.4.%i", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, - { "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + { "device.type", ST_FLAG_STRING, SU_INFOSIZE, + NULL, + "pdu", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "device.part", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.1.2.1.3.%i", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, /* For daisychain, there is only 1 physical interface! */ - { "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.2.2.1.6.2", + { "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.2.1.2.2.1.6.2", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, /* Daisychained devices support */ @@ -287,7 +296,7 @@ static snmp_info_t eaton_marlin_mib[] = { /* FIXME: inline func */ { "device.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.1.0", - "1", SU_FLAG_STATIC | SU_FLAG_UNIQUE, + "0", SU_FLAG_STATIC | SU_FLAG_UNIQUE, &marlin_device_count_info[0] /* devices_count */ }, #endif /* Notes: this older/fallback definition is used to: @@ -318,8 +327,9 @@ static snmp_info_t eaton_marlin_mib[] = { { "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.1.2.1.5.%i", "", SU_FLAG_OK, NULL }, - { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, + NULL, + "pdu", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, /* FIXME: needs a date reformating callback * 2011-8-29,16:27:25.0,+1:0 * Hex-STRING: 07 DB 08 1D 10 0C 36 00 2B 01 00 00 @@ -338,15 +348,18 @@ static snmp_info_t eaton_marlin_mib[] = { */ /* Note: the below gives the number of input, not the number of phase(s)! */ /* inputCount.0; Value (Integer): 1 - { "input.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.20.0", + { "input.count", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.1.2.1.20.0", NULL, SU_FLAG_STATIC, NULL }, */ /* Note: for daisychain mode, we must handle phase(s) per device, not as a whole */ /* inputType.%i.1 = INTEGER: singlePhase (1) */ - { "input.phases", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.2.%i.1", + { "input.phases", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.3.1.1.2.%i.1", NULL, SU_FLAG_STATIC, &marlin_input_type_info[0] }, /* Frequency is measured globally */ - { "input.frequency", 0, 0.1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.3.%i.1", + { "input.frequency", 0, 0.1, + ".1.3.6.1.4.1.534.6.6.7.3.1.1.3.%i.1", NULL, 0, NULL }, { "input.frequency.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.4.%i.1", @@ -358,13 +371,17 @@ static snmp_info_t eaton_marlin_mib[] = { /* inputCurrentPercentLoad (measured globally) * Current percent load, based on the rated current capacity */ /* FIXME: input.load is mapped on input.L1.load for both single and 3phase !!! */ - { "input.load", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.1", + { "input.load", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L1.load", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.1", + { "input.L1.load", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L2.load", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.2", + { "input.L2.load", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.2", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L3.load", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.3", + { "input.L3.load", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.3.1.11.%i.1.3", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, /* FIXME: @@ -557,53 +574,85 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.3.3.1.9.%i.1.3", NULL, SU_FLAG_NEGINVALID, NULL }, /* Sum of all phases realpower, valid for Shark 1ph/3ph only */ - { "input.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.5.1.4.%i.1", + { "input.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.5.1.4.%i.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_UNIQUE | SU_FLAG_OK, NULL }, /* Fallback 1: Sum of all phases realpower, valid for Marlin 3ph only */ - { "input.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.4", + { "input.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.4", NULL, SU_FLAG_NEGINVALID | SU_FLAG_UNIQUE | SU_FLAG_OK, NULL }, /* Fallback 2: Sum of the phase realpower, valid for Marlin 1ph only */ - { "input.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.2", + { "input.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.2", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L1.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.1", + { "input.L1.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L2.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.2", + { "input.L2.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.2", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L3.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.3", + { "input.L3.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.3", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, /* Sum of all phases apparent power, valid for Shark 1ph/3ph only */ - { "input.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.5.1.3.%i.1", + { "input.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.5.1.3.%i.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_UNIQUE | SU_FLAG_OK, NULL }, /* Fallback 1: Sum of all phases realpower, valid for Marlin 3ph only */ - { "input.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.4", + { "input.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.4", NULL, SU_FLAG_NEGINVALID | SU_FLAG_UNIQUE | SU_FLAG_OK, NULL }, /* Fallback 2: Sum of the phase realpower, valid for Marlin 1ph only */ - { "input.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.2", + { "input.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.2", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L1.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.1", + { "input.L1.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L2.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.2", + { "input.L2.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.2", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - { "input.L3.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.3", + { "input.L3.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.3", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - /* Feed to which the ePDU is connected - * ??? // FIXME-Check on real device + /* Input feeds need 2 static declarations with last %i in [1,2]: + * iterators are currently available for daisychain devs, outlets, + * and groups - but not for inputs nor feeds. */ + /* Feed ID to which the ePDU is connected + * ??? // FIXME: Numeric value not provided by FW at this time */ /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags */ /* { "input.feed.%i.id", 0, 1, "???.%i.%i", NULL, SU_FLAG_NEGINVALID, NULL }, */ - /* Feed name - * inputFeedName.0.1 = Value (OctetString): A1 // FIXME-Check on real device + /* Feed name(s) of the ePDU power input(s), can be set by user (FIXME: rename to .desc?) + * inputFeedName.0.1 = Value (OctetString): Feed A */ - { "input.feed.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_OK, NULL }, - /* Feed A / B color - * inputFeedColor.0.1 = Value (OctetString): 0A8B9C // FIXME-Check on real device + /* FIXME: SU_FLAG_SEMI_STATIC or SU_FLAG_SETTING => refreshed from time to time or upon call to setvar */ +/* { "input.feed.%i.name", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, + * ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.%i", + * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + */ + { "input.feed.1.name", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.1", + NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + { "input.feed.2.name", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.2", + NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + /* Feed A / B color (integer RGB) + * inputFeedColor.0.1 = Gauge32: 0 (black) */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ - { "input.feed.%i.color", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_OK, NULL }, - /* ePDU "nominal power", inputPowerCapacity with .1.3.6.1.4.1.534.6.6.7.3.4.1.9.x.1.y using "input.power.nominal" (need RFC on NUT) +/* { "input.feed.%i.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", + * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + */ + { "input.feed.1.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.1", + NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + { "input.feed.2.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.2", + NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + /* ePDU "nominal power", inputPowerCapacity with .1.3.6.1.4.1.534.6.6.7.3.4.1.9.x.1.y + * using "input.power.nominal" (need RFC on NUT) * TODO: sample says of ...x.1.y and no %i in the key name... - * inputPowerCapacity // FIXME-Check on real device + * inputPowerCapacity = INTEGER: -1 // FIXME: Test on HW that provides it */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ { "input.power.nominal", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.9.%i.1.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, @@ -675,11 +724,15 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_OK, &marlin_ambient_drycontacts_info[0] }, /* Outlet collection */ - { "outlet.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.22.%i", + { "outlet.count", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.1.2.1.22.%i", "0", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, - { "outlet.id", 0, 1, NULL, + { "outlet.id", 0, 1, + NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, - { "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, NULL, "All outlets", + { "outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, + NULL, + "All outlets", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, /* UnitType * used to depict the overall outlets switchability of the unit on G3 and newer ePDU*/ @@ -692,15 +745,20 @@ static snmp_info_t eaton_marlin_mib[] = { "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_TYPE_DAISY_1, &g2_unit_outlet_switchability_info[0] }, /* The below ones are the same as the input.* equivalent */ /* FIXME: transition period, TO BE REMOVED, moved to input.* */ - { "outlet.frequency", 0, 0.1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.3.%i.1", + { "outlet.frequency", 0, 0.1, + ".1.3.6.1.4.1.534.6.6.7.3.1.1.3.%i.1", NULL, 0, NULL }, - { "outlet.voltage", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.2.1.3.%i.1.1", + { "outlet.voltage", 0, 0.001, + ".1.3.6.1.4.1.534.6.6.7.3.2.1.3.%i.1.1", NULL, 0, NULL }, - { "outlet.current", 0, 0.01, ".1.3.6.1.4.1.534.6.6.7.3.3.1.4.%i.1.1", + { "outlet.current", 0, 0.01, + ".1.3.6.1.4.1.534.6.6.7.3.3.1.4.%i.1.1", NULL, 0, NULL }, - { "outlet.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.4", + { "outlet.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.4.%i.1.4", NULL, 0, NULL }, - { "outlet.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.4", + { "outlet.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.4", NULL, 0, NULL }, /* outlet template definition @@ -828,14 +886,16 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.group.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.3.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, - /* Outlet-group physical name - * groupPhysicalName.0.1 = Value (OctetString): GRP1 // FIXME-Check on real device + /* Outlet-group physical name, a read-only string, + * is named groupDesignator (other MIBs groupPhysicalName) + * groupPhysicalName.0.1 = Value (OctetString): A + * groupDesignator.0.2 = Value (OctetString): B */ { "outlet.group.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.8.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, - /* Outlet-group color - * groupBkgColor.0.1 = Value (OctetString): 0A8B9C // FIXME-Check on real device + /* Outlet-group color: groupColor (other MIBs groupBkgColor) + * groupColor.0.1 = Value (Gauge32): 16051527 (0xF4ED47) */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ { "outlet.group.%i.color", ST_FLAG_STRING, SU_INFOSIZE, @@ -847,8 +907,9 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, &marlin_outlet_group_type_info[0], NULL }, #if WITH_SNMP_LKP_FUN - /* Phase to which an outlet-group is connected (Caution: the value is numeric, and need to append "L" -- TODO) - * groupPhaseID // FIXME-Check on real device + /* Phase to which an outlet-group is connected + * (Caution: the value is numeric, and need to append "L" -- TODO) + * groupPhaseID: // FIXME-Check on real device */ /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags (daisy?) */ { "outlet.group.%i.phase", 0, SU_INFOSIZE, @@ -967,9 +1028,9 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.5.5.1.2.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, /* Input to which an outlet-group is connected - * groupInputID // FIXME-Check on real device + * groupInputIndex.0.1 = Integer: 1 */ - /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags (daisy?) */ + /* FIXME: RFC on key name is needed when backporting to NUT upstream */ { "outlet.group.%i.input", 0, 1, ".1.3.6.1.4.1.534.6.6.7.5.1.1.9.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, @@ -992,29 +1053,36 @@ static snmp_info_t eaton_marlin_mib[] = { /* Delays handling: * 0-n :Time in seconds until the group command is issued * -1:Cancel a pending group-level Off/On/Reboot command */ - { "outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", + { "outlet.%i.load.off", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", "0", SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.4.%i.%i", + { "outlet.%i.load.on", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.4.%i.%i", "0", SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.load.cycle", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", + { "outlet.%i.load.cycle", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", "0", SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, /* Delayed version, parameter is mandatory (so dfl is NULL)! */ - { "outlet.%i.load.off.delay", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", + { "outlet.%i.load.off.delay", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.load.on.delay", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.4.%i.%i", + { "outlet.%i.load.on.delay", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.4.%i.%i", NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.load.cycle.delay", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", + { "outlet.%i.load.cycle.delay", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - /* Per outlet shutdown / startup delay (configuration point, not the timers) - * outletControlShutoffDelay // FIXME-Check on real device - * outletControlSequenceDelay // FIXME-Check on real device ; verify OID is one component shorter? + /* Per-outlet shutdown / startup delay (configuration point, not the timers) + * outletControlShutoffDelay.0.3 = INTEGER: 120 + * outletControlSequenceDelay.0.8 = INTEGER: 8 + * (by default each output socket startup is delayed by its number in seconds) */ { "outlet.%i.delay.shutdown", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.10.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, { "outlet.%i.delay.start", ST_FLAG_RW, 1, - ".1.3.6.1.4.1.534.6.6.7.6.1.7.%i.%i", + ".1.3.6.1.4.1.534.6.6.7.6.6.1.7.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, /* TODO: handle delays From 4ef45b112e3ebc8b7fd7278be2b056235978a970 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 13 Oct 2017 11:10:08 +0200 Subject: [PATCH 12/75] eaton-pdu-marlin-mib.c : fix OID and raise questions on input.power.nominal --- drivers/eaton-pdu-marlin-mib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 7ef6dfae52..2c1af6e59d 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -652,10 +652,15 @@ static snmp_info_t eaton_marlin_mib[] = { /* ePDU "nominal power", inputPowerCapacity with .1.3.6.1.4.1.534.6.6.7.3.4.1.9.x.1.y * using "input.power.nominal" (need RFC on NUT) * TODO: sample says of ...x.1.y and no %i in the key name... - * inputPowerCapacity = INTEGER: -1 // FIXME: Test on HW that provides it + * TODO: is this daisy-chainable? Are there more values for multi-input + * devices? How to name it "right" then? + * inputPowerCapacity.0.1 = INTEGER: -1 + * $ snmpwalk -O0n -v1 -c public EMAB33.localdomain .1.3.6.1.4.1.534.6.6.7.3.5.1.9 + * .1.3.6.1.4.1.534.6.6.7.3.5.1.9.0.1 = INTEGER: 2300 */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ - { "input.power.nominal", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.4.1.9.%i.1.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, + { "input.power.nominal", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.5.1.9.%i.1", + NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, /* Ambient collection */ { "ambient.present", ST_FLAG_STRING, SU_INFOSIZE, From 5cfbde7743f92d29fd388f47df19cccc2573086d Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Fri, 13 Oct 2017 14:29:58 +0200 Subject: [PATCH 13/75] Problem: Need to fix published feed variables Solution: Attach 1 feed to the current input Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 36 ++++++++++------------------------ 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 2c1af6e59d..a96fe4886c 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -616,48 +616,32 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.3", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - /* Input feeds need 2 static declarations with last %i in [1,2]: + /* Input feed: a feed (A or B) is tied to an input. * iterators are currently available for daisychain devs, outlets, - * and groups - but not for inputs nor feeds. */ - /* Feed ID to which the ePDU is connected - * ??? // FIXME: Numeric value not provided by FW at this time - */ + * and groups - but not for inputs. */ /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags */ /* { "input.feed.%i.id", 0, 1, "???.%i.%i", NULL, SU_FLAG_NEGINVALID, NULL }, */ /* Feed name(s) of the ePDU power input(s), can be set by user (FIXME: rename to .desc?) * inputFeedName.0.1 = Value (OctetString): Feed A */ /* FIXME: SU_FLAG_SEMI_STATIC or SU_FLAG_SETTING => refreshed from time to time or upon call to setvar */ -/* { "input.feed.%i.name", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, +/* { "input.%i.feed.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, * ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.%i", * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, */ - { "input.feed.1.name", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, + { "input.feed.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.1", - NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, - { "input.feed.2.name", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.2", - NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, - /* Feed A / B color (integer RGB) + NULL, SU_FLAG_SEMI_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + /* Feed color (integer RGB) * inputFeedColor.0.1 = Gauge32: 0 (black) */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ -/* { "input.feed.%i.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", - * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, +/* { "input.%i.feed.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", + * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL}, */ - { "input.feed.1.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.1", - NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, - { "input.feed.2.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.2", + { "input.feed.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.1", NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, - /* ePDU "nominal power", inputPowerCapacity with .1.3.6.1.4.1.534.6.6.7.3.4.1.9.x.1.y - * using "input.power.nominal" (need RFC on NUT) - * TODO: sample says of ...x.1.y and no %i in the key name... - * TODO: is this daisy-chainable? Are there more values for multi-input - * devices? How to name it "right" then? - * inputPowerCapacity.0.1 = INTEGER: -1 - * $ snmpwalk -O0n -v1 -c public EMAB33.localdomain .1.3.6.1.4.1.534.6.6.7.3.5.1.9 - * .1.3.6.1.4.1.534.6.6.7.3.5.1.9.0.1 = INTEGER: 2300 - */ + /* inputPowerCapacity.0.1 = INTEGER: 2300 */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ { "input.power.nominal", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.5.1.9.%i.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, From 6ab6607e4b245bda789d475a60cfe96ab4f7c20a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 13 Oct 2017 14:59:52 +0200 Subject: [PATCH 14/75] eaton-pdu-marlin-mib.c : updated comments about input/feed relationship, and daisychain implications --- drivers/eaton-pdu-marlin-mib.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index a96fe4886c..7c6f306a2d 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -342,16 +342,27 @@ static snmp_info_t eaton_marlin_mib[] = { */ /* Input collection */ + /* Note: a larger ePDU can have several inputs. The "%i" iterators + * in key names are currently available for daisychain devs, outlets, + * and groups - but not for inputs. These would likely evolve later + * to "input.%i.something" with default (non-%i) same as .1 instance. + * At this time only a single-input (or first of several inputs) is + * supported by this mapping. + */ /* Historically, some of these data were previously published as * outlet.{realpower,...} * However, it's more suitable and logic to have these on input.{...} */ /* Note: the below gives the number of input, not the number of phase(s)! */ /* inputCount.0; Value (Integer): 1 - { "input.count", 0, 1, + { "input.phases", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.20.0", - NULL, SU_FLAG_STATIC, NULL }, */ - /* Note: for daisychain mode, we must handle phase(s) per device, not as a whole */ + NULL, SU_FLAG_STATIC | SU_FLAG_SETINT, NULL, &input_phases }, */ + /* Note: for daisychain mode, we must handle phase(s) per device, + * not as a whole. In case of daisychain, support of the UNIQUE + * field is not yet implemented (FIXME) so the last resolved OID + * value wins. If a more-preferable OID is not implemented by device, + * this is ok - the previous available value remains in place. */ /* inputType.%i.1 = INTEGER: singlePhase (1) */ { "input.phases", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.2.%i.1", @@ -616,9 +627,9 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.3.4.1.3.%i.1.3", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, - /* Input feed: a feed (A or B) is tied to an input. - * iterators are currently available for daisychain devs, outlets, - * and groups - but not for inputs. */ + /* Input feed: a feed (A or B) is tied to an input, and this + * sub-collection describes the properties of an actual cable. + */ /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags */ /* { "input.feed.%i.id", 0, 1, "???.%i.%i", NULL, SU_FLAG_NEGINVALID, NULL }, */ /* Feed name(s) of the ePDU power input(s), can be set by user (FIXME: rename to .desc?) From 184f7fc5b1918f0bcdaff31284da80a5bf887476 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 11 Oct 2017 02:13:10 +0200 Subject: [PATCH 15/75] eaton-pdu-marlin-* : add support for extended fun/nuf l2s/s2l conversions --- drivers/eaton-pdu-marlin-helpers.c | 14 +++++++------- drivers/eaton-pdu-marlin-helpers.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 5a96a3b6cf..45e3f83845 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -45,7 +45,7 @@ static char marlin_scratch_buf[20]; * (not outlet-section nor user-defined!), and for now, there * is a maximum of 6 gangs (electrical groups). */ -const char *marlin_outlet_group_phase_fun(int outlet_group_nb) +const char *marlin_outlet_group_phase_fun(long outlet_group_nb) { const char* str_phases_nb = dstate_getinfo("input.phases"); int phases_nb = 1; @@ -56,9 +56,9 @@ const char *marlin_outlet_group_phase_fun(int outlet_group_nb) } else { /* 3ph assumed, 2ph PDU don't exist - at least not in Eaton Marlin lineup! */ if (outlet_group_nb > 3) - snprintf(marlin_scratch_buf, 3, "L%i", (outlet_group_nb - 3)); /* FIXME: For more than 6 ports, maybe "nb % 3"? */ + snprintf(marlin_scratch_buf, 3, "L%li", (outlet_group_nb - 3)); /* FIXME: For more than 6 ports, maybe "nb % 3"? */ else - snprintf(marlin_scratch_buf, 3, "L%i", outlet_group_nb); + snprintf(marlin_scratch_buf, 3, "L%li", outlet_group_nb); return marlin_scratch_buf; } @@ -67,10 +67,10 @@ const char *marlin_outlet_group_phase_fun(int outlet_group_nb) } /* Take the value received from MIB, convert to string and add a prefix */ -const char *marlin_outlet_group_phase_prefix_fun(int outlet_group_input_phase) +const char *marlin_outlet_group_phase_prefix_fun(long outlet_group_input_phase) { if (outlet_group_input_phase >= 1 && outlet_group_input_phase <= 3) { - snprintf(marlin_scratch_buf, 3, "L%i", outlet_group_input_phase); + snprintf(marlin_scratch_buf, 3, "L%li", outlet_group_input_phase); return marlin_scratch_buf; } return NULL; @@ -78,9 +78,9 @@ const char *marlin_outlet_group_phase_prefix_fun(int outlet_group_input_phase) /* Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount * of "," separators+1 using an inline function */ -const int marlin_device_count_fun(const char *daisy_dev_list) +long marlin_device_count_fun(const char *daisy_dev_list) { - int count = 0, i; + long count = 0, i; for (i=0; daisy_dev_list[i] != '\0'; i++) { if (daisy_dev_list[i] == ',') { /* Each comma means a new device in the list */ diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h index 603bea19f4..a64c9538c0 100644 --- a/drivers/eaton-pdu-marlin-helpers.h +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -23,9 +23,9 @@ #ifndef EATON_EPDU_MARLIN_HELPERS_H #define EATON_EPDU_MARLIN_HELPERS_H -const char *marlin_outlet_group_phase_fun(int outlet_group_nb); -const char *marlin_outlet_group_phase_prefix_fun(int outlet_group_input_phase); +const char *marlin_outlet_group_phase_fun(long outlet_group_nb); +const char *marlin_outlet_group_phase_prefix_fun(long outlet_group_input_phase); -const int marlin_device_count_fun(const char *daisy_dev_list); +long marlin_device_count_fun(const char *daisy_dev_list); #endif /* EATON_EPDU_MARLIN_HELPERS_H */ From a2b8b5e0eae031ef0ebfcd04e06f5d370f53f912 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Tue, 17 Oct 2017 08:33:22 +0200 Subject: [PATCH 16/75] snmp-ups: simplify Eaton ePDU group phase handling Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-helpers.c | 41 ------------- drivers/eaton-pdu-marlin-helpers.h | 3 - drivers/eaton-pdu-marlin-mib.c | 93 +++++++----------------------- 3 files changed, 22 insertions(+), 115 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 45e3f83845..9e86574011 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -35,47 +35,6 @@ #include "eaton-pdu-marlin-helpers.h" #include "dstate.h" -static char marlin_scratch_buf[20]; - -/* Compute the phase to which an outlet group is connected - * WRT the number of phase(s) and the outlet group number. - * Note that the group type (marlin_outlet_group_type_info) - * is not considered since this applies to any kind of group. - * This trick limits input phase to electrical groups only - * (not outlet-section nor user-defined!), and for now, there - * is a maximum of 6 gangs (electrical groups). - */ -const char *marlin_outlet_group_phase_fun(long outlet_group_nb) -{ - const char* str_phases_nb = dstate_getinfo("input.phases"); - int phases_nb = 1; - if (str_phases_nb) { - phases_nb = atoi(str_phases_nb); - if (phases_nb == 1) { - return "L1"; - } - else { /* 3ph assumed, 2ph PDU don't exist - at least not in Eaton Marlin lineup! */ - if (outlet_group_nb > 3) - snprintf(marlin_scratch_buf, 3, "L%li", (outlet_group_nb - 3)); /* FIXME: For more than 6 ports, maybe "nb % 3"? */ - else - snprintf(marlin_scratch_buf, 3, "L%li", outlet_group_nb); - - return marlin_scratch_buf; - } - } - return NULL; -} - -/* Take the value received from MIB, convert to string and add a prefix */ -const char *marlin_outlet_group_phase_prefix_fun(long outlet_group_input_phase) -{ - if (outlet_group_input_phase >= 1 && outlet_group_input_phase <= 3) { - snprintf(marlin_scratch_buf, 3, "L%li", outlet_group_input_phase); - return marlin_scratch_buf; - } - return NULL; -} - /* Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount * of "," separators+1 using an inline function */ long marlin_device_count_fun(const char *daisy_dev_list) diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h index a64c9538c0..50a1d5e37e 100644 --- a/drivers/eaton-pdu-marlin-helpers.h +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -23,9 +23,6 @@ #ifndef EATON_EPDU_MARLIN_HELPERS_H #define EATON_EPDU_MARLIN_HELPERS_H -const char *marlin_outlet_group_phase_fun(long outlet_group_nb); -const char *marlin_outlet_group_phase_prefix_fun(long outlet_group_input_phase); - long marlin_device_count_fun(const char *daisy_dev_list); #endif /* EATON_EPDU_MARLIN_HELPERS_H */ diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 7c6f306a2d..ed104fe603 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -194,16 +194,28 @@ static info_lkp_t marlin_input_type_info[] = { { 0, NULL, NULL, NULL } }; -#if WITH_SNMP_LKP_FUN -/* Note: marlin_outlet_group_phase_fun() is defined in eaton-pdu-marlin-helpers.c - * Future work for DMF might provide a same-named routine via LUA-C gateway. - */ static info_lkp_t marlin_outlet_group_phase_info[] = { - { 1, "dummy", marlin_outlet_group_phase_fun, NULL }, - { 2, "dummytwoo", marlin_outlet_group_phase_prefix_fun, NULL }, + { 0, "unknown", NULL, NULL }, /* unknown */ + { 1, "1", NULL, NULL }, /* singlePhase */ + { 2, "1-N", NULL, NULL }, /* phase1toN */ + { 3, "2-N", NULL, NULL }, /* phase2toN */ + { 4, "3-N", NULL, NULL }, /* phase3toN */ + { 5, "1-2", NULL, NULL }, /* phase1to2 */ + { 6, "2-3", NULL, NULL }, /* phase2to3 */ + { 7, "3-1", NULL, NULL }, /* phase3to1 */ { 0, NULL, NULL, NULL } }; +#if WITH_SNMP_LKP_FUN +/* Note: marlin_device_count_fun() is defined in eaton-pdu-marlin-helpers.c + * Future work for DMF might provide a same-named routine via LUA-C gateway. + */ + +# if WITH_SNMP_LKP_FUN_DUMMY +long marlin_device_count_fun(const char *daisy_dev_list) + { return 1; } +# endif /* WITH_SNMP_LKP_FUN_DUMMY */ + static info_lkp_t marlin_device_count_info[] = { { 1, "dummy", NULL, marlin_device_count_fun }, { 0, NULL, NULL, NULL } @@ -215,34 +227,6 @@ static info_lkp_t marlin_device_count_info[] = { * lookup/mapping tables for this, which can easily go into the DMF XML file. */ -/* Ugly trick which limits input phase to electrical groups */ -static info_lkp_t marlin_outlet_group_phase1_info[] = { - /* { 0, NULL }, unknown */ - { 1, "L1" }, /* breaker1pole */ - { 2, "L1" }, /* breaker2pole */ - { 3, "L1" }, /* breaker3pole */ - /* { 4, NULL }, outlet-section */ - /* { 5, NULL }, user-defined */ - { 0, NULL } -}; -static info_lkp_t marlin_outlet_group_phase2_info[] = { - /* { 0, NULL }, unknown */ - { 1, "L2" }, /* breaker1pole */ - { 2, "L2" }, /* breaker2pole */ - { 3, "L2" }, /* breaker3pole */ - /* { 4, NULL }, outlet-section */ - /* { 5, NULL }, user-defined */ - { 0, NULL } -}; -static info_lkp_t marlin_outlet_group_phase3_info[] = { - /* { 0, NULL }, unknown */ - { 1, "L3" }, /* breaker1pole */ - { 2, "L3" }, /* breaker2pole */ - { 3, "L3" }, /* breaker3pole */ - /* { 4, NULL }, outlet-section */ - /* { 5, NULL }, user-defined */ -}; - #endif /* WITH_SNMP_LKP_FUN */ @@ -906,48 +890,15 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, &marlin_outlet_group_type_info[0], NULL }, -#if WITH_SNMP_LKP_FUN - /* Phase to which an outlet-group is connected - * (Caution: the value is numeric, and need to append "L" -- TODO) - * groupPhaseID: // FIXME-Check on real device + /* Phase to which an outlet-group is connected: + * We use the following OID, which gives the voltage measurement type + * groupVoltageMeasType.0.1; Value (Integer): singlePhase (1) */ /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags (daisy?) */ { "outlet.group.%i.phase", 0, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.10.%i.%i", + ".1.3.6.1.4.1.534.6.6.7.5.3.1.2.%i.%i", NULL, SU_FLAG_UNIQUE | SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, &marlin_outlet_group_phase_info[1], NULL }, - { "outlet.group.%i.phase", 0, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.%i", - NULL, SU_FLAG_UNIQUE | SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase_info[0], NULL }, -#else /* not WITH_SNMP_LKP_FUN */ - /* ugly trick which limits input phase to electrical groups only (not outlet-section nor user-defined!) - * For now, there is a maximum of 6 gangs (electrical groups) */ - { "outlet.group.1.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.1", - NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase1_info[0], NULL }, - { "outlet.group.2.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.2", - NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase2_info[0], NULL }, - { "outlet.group.3.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.3", - NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase3_info[0], NULL }, - { "outlet.group.4.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.4", - NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase1_info[0], NULL }, - { "outlet.group.5.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.5", - NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase2_info[0], NULL }, - { "outlet.group.6.phase", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.6", - NULL, SU_FLAG_STATIC | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase3_info[0], NULL }, -#endif // WITH_SNMP_LKP_FUN /* groupControlStatus.0.1 = Integer: on (1) */ { "outlet.group.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.6.1.2.%i.%i", From 88839b43a09b43970c7edf602523b17ac90558fd Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Tue, 17 Oct 2017 10:45:36 +0200 Subject: [PATCH 17/75] snmp-ups: fix Eaton ePDU group phase handling Remove the not needed SU_FLAG_UNIQUE and the erroneous value lookup structure index Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index ed104fe603..5681c2ad90 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -897,8 +897,8 @@ static snmp_info_t eaton_marlin_mib[] = { /* FIXME: RFC on key name is needed when backporting to NUT upstream ; check type (number? string?) and flags (daisy?) */ { "outlet.group.%i.phase", 0, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.3.1.2.%i.%i", - NULL, SU_FLAG_UNIQUE | SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase_info[1], NULL }, + NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + &marlin_outlet_group_phase_info[0], NULL }, /* groupControlStatus.0.1 = Integer: on (1) */ { "outlet.group.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.6.1.2.%i.%i", From 61c5e2120c83a7c3e53ac0d8cadc911661769185 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 25 Feb 2022 21:14:11 +0100 Subject: [PATCH 18/75] drivers/eaton-pdu-marlin-mib.c: break long lines --- drivers/eaton-pdu-marlin-mib.c | 142 ++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 47 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 5681c2ad90..9b0e8508bb 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -341,7 +341,9 @@ static snmp_info_t eaton_marlin_mib[] = { /* inputCount.0; Value (Integer): 1 { "input.phases", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.20.0", - NULL, SU_FLAG_STATIC | SU_FLAG_SETINT, NULL, &input_phases }, */ + NULL, SU_FLAG_STATIC | SU_FLAG_SETINT, NULL + //, &input_phases + }, */ /* Note: for daisychain mode, we must handle phase(s) per device, * not as a whole. In case of daisychain, support of the UNIQUE * field is not yet implemented (FIXME) so the last resolved OID @@ -350,7 +352,8 @@ static snmp_info_t eaton_marlin_mib[] = { /* inputType.%i.1 = INTEGER: singlePhase (1) */ { "input.phases", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.2.%i.1", - NULL, SU_FLAG_STATIC, &marlin_input_type_info[0] }, + NULL, SU_FLAG_STATIC, + &marlin_input_type_info[0] }, /* Frequency is measured globally */ { "input.frequency", 0, 0.1, @@ -358,10 +361,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.frequency.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.4.%i.1", - NULL, SU_FLAG_OK, &marlin_threshold_frequency_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_frequency_status_info[0] }, { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.4.%i.1", - NULL, SU_FLAG_OK, &marlin_threshold_frequency_alarm_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_frequency_alarm_info[0] }, /* inputCurrentPercentLoad (measured globally) * Current percent load, based on the rated current capacity */ @@ -391,10 +396,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.voltage.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_voltage_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_voltage_alarms_info[0] }, { "input.voltage.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.2.1.5.%i.1.1", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -412,10 +419,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.L1.voltage.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "L1.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_voltage_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_voltage_alarms_info[0] }, { "input.L1.voltage.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.2.1.5.%i.1.1", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -433,10 +442,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.L2.voltage.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.2", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "L2.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.2", - NULL, SU_FLAG_OK, &marlin_threshold_voltage_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_voltage_alarms_info[0] }, { "input.L2.voltage.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.2.1.5.%i.1.2", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -454,10 +465,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.L3.voltage.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.3", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "L3.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.3", - NULL, SU_FLAG_OK, &marlin_threshold_voltage_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_voltage_alarms_info[0] }, { "input.L3.voltage.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.2.1.5.%i.1.3", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -480,10 +493,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.current.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_current_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_current_alarms_info[0] }, { "input.current.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.3.1.6.%i.1.1", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -504,10 +519,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.L1.current.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "L1.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.1", - NULL, SU_FLAG_OK, &marlin_threshold_current_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_current_alarms_info[0] }, { "input.L1.current.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.3.1.6.%i.1.1", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -528,10 +545,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.L2.current.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.2", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "L2.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.2", - NULL, SU_FLAG_OK, &marlin_threshold_current_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_current_alarms_info[0] }, { "input.L2.current.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.3.1.6.%i.1.2", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -552,10 +571,12 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, 0, NULL }, { "input.L3.current.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.3", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "L3.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.3.1.5.%i.1.3", - NULL, SU_FLAG_OK, &marlin_threshold_current_alarms_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_current_alarms_info[0] }, { "input.L3.current.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.3.1.6.%i.1.3", NULL, SU_FLAG_NEGINVALID, NULL }, @@ -631,27 +652,34 @@ static snmp_info_t eaton_marlin_mib[] = { * inputFeedColor.0.1 = Gauge32: 0 (black) */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ -/* { "input.%i.feed.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", +/* { "input.%i.feed.color", 0, 1, + * ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL}, */ - { "input.feed.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.1", + { "input.feed.color", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.1", NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, /* inputPowerCapacity.0.1 = INTEGER: 2300 */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ - { "input.power.nominal", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.5.1.9.%i.1", + { "input.power.nominal", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.3.5.1.9.%i.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, /* Ambient collection */ { "ambient.present", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.1.1.3.%i.1", - NULL, SU_FLAG_OK, &marlin_ambient_presence_info[0] }, + NULL, SU_FLAG_OK, + &marlin_ambient_presence_info[0] }, { "ambient.temperature.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.1.1.5.%i.1", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.1.1.5.%i.1", - NULL, SU_FLAG_OK, &marlin_threshold_temperature_alarms_info[0] }, - { "ambient.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.6.7.7.1.1.4.%i.1", + NULL, SU_FLAG_OK, + &marlin_threshold_temperature_alarms_info[0] }, + { "ambient.temperature", 0, 0.1, + ".1.3.6.1.4.1.534.6.6.7.7.1.1.4.%i.1", NULL, SU_FLAG_OK, NULL }, /* Low and high threshold use the respective critical levels */ { "ambient.temperature.low", ST_FLAG_RW, 0.1, @@ -674,11 +702,14 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, { "ambient.humidity.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.2.1.5.%i.1", - NULL, SU_FLAG_OK, &marlin_threshold_status_info[0] }, + NULL, SU_FLAG_OK, + &marlin_threshold_status_info[0] }, { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.2.1.5.%i.1", - NULL, SU_FLAG_OK, &marlin_threshold_humidity_alarms_info[0] }, - { "ambient.humidity", 0, 0.1, ".1.3.6.1.4.1.534.6.6.7.7.2.1.4.%i.1", + NULL, SU_FLAG_OK, + &marlin_threshold_humidity_alarms_info[0] }, + { "ambient.humidity", 0, 0.1, + ".1.3.6.1.4.1.534.6.6.7.7.2.1.4.%i.1", NULL, SU_FLAG_OK, NULL }, /* Low and high threshold use the respective critical levels */ { "ambient.humidity.low", ST_FLAG_RW, 0.1, @@ -702,10 +733,12 @@ static snmp_info_t eaton_marlin_mib[] = { /* Dry contacts on TH module */ { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.3.1.4.%i.1", - NULL, SU_FLAG_OK, &marlin_ambient_drycontacts_info[0] }, + NULL, SU_FLAG_OK, + &marlin_ambient_drycontacts_info[0] }, { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.3.1.4.%i.2", - NULL, SU_FLAG_OK, &marlin_ambient_drycontacts_info[0] }, + NULL, SU_FLAG_OK, + &marlin_ambient_drycontacts_info[0] }, /* Outlet collection */ { "outlet.count", 0, 1, @@ -722,11 +755,13 @@ static snmp_info_t eaton_marlin_mib[] = { * used to depict the overall outlets switchability of the unit on G3 and newer ePDU*/ { "outlet.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.1.2.1.10.%i", - "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE, &marlin_unit_switchability_info[0] }, + "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE, + &marlin_unit_switchability_info[0] }, /* Ugly hack for older G2 ePDU: check the first outlet to determine unit switchability */ { "outlet.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.1", - "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_TYPE_DAISY_1, &g2_unit_outlet_switchability_info[0] }, + "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_TYPE_DAISY_1, + &g2_unit_outlet_switchability_info[0] }, /* The below ones are the same as the input.* equivalent */ /* FIXME: transition period, TO BE REMOVED, moved to input.* */ { "outlet.frequency", 0, 0.1, @@ -754,7 +789,8 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, { "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.2.%i.%i", - NULL, SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, &marlin_outlet_status_info[0] }, + NULL, SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, + &marlin_outlet_status_info[0] }, /* Numeric identifier of the outlet, tied to the whole unit */ { "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.7.%i.%i", @@ -793,14 +829,17 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.%i.groupid", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.2.1.3.%i.%i.6", NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.current", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.4.1.3.%i.%i", + { "outlet.%i.current", 0, 0.001, + ".1.3.6.1.4.1.534.6.6.7.6.4.1.3.%i.%i", NULL, SU_OUTLET | SU_TYPE_DAISY_1, NULL }, { "outlet.%i.current.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.4.1.4.%i.%i", - NULL, SU_OUTLET | SU_TYPE_DAISY_1, &marlin_threshold_status_info[0] }, + NULL, SU_OUTLET | SU_TYPE_DAISY_1, + &marlin_threshold_status_info[0] }, { "outlet.%i.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.4.1.4.%i.%i", - NULL, SU_OUTLET | SU_TYPE_DAISY_1, &marlin_threshold_current_alarms_info[0] }, + NULL, SU_OUTLET | SU_TYPE_DAISY_1, + &marlin_threshold_current_alarms_info[0] }, { "outlet.%i.current.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.4.1.5.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, @@ -813,16 +852,20 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.%i.current.high.critical", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.4.1.8.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.realpower", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.6.5.1.3.%i.%i", + { "outlet.%i.realpower", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.6.5.1.3.%i.%i", NULL, SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.voltage", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.3.1.2.%i.%i", + { "outlet.%i.voltage", 0, 0.001, + ".1.3.6.1.4.1.534.6.6.7.6.3.1.2.%i.%i", NULL, SU_OUTLET | SU_TYPE_DAISY_1, NULL }, { "outlet.%i.voltage.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.3.1.3.%i.%i", - NULL, SU_OUTLET | SU_TYPE_DAISY_1, &marlin_threshold_status_info[0] }, + NULL, SU_OUTLET | SU_TYPE_DAISY_1, + &marlin_threshold_status_info[0] }, { "outlet.%i.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.3.1.3.%i.%i", - NULL, SU_OUTLET | SU_TYPE_DAISY_1, &marlin_threshold_voltage_alarms_info[0] }, + NULL, SU_OUTLET | SU_TYPE_DAISY_1, + &marlin_threshold_voltage_alarms_info[0] }, { "outlet.%i.voltage.low.warning", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.3.1.4.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, @@ -835,19 +878,23 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.%i.voltage.high.critical", ST_FLAG_RW, 0.001, ".1.3.6.1.4.1.534.6.6.7.6.3.1.7.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.6.5.1.2.%i.%i", + { "outlet.%i.power", 0, 1.0, + ".1.3.6.1.4.1.534.6.6.7.6.5.1.2.%i.%i", NULL, SU_OUTLET | SU_TYPE_DAISY_1, NULL }, /* outletControlSwitchable */ { "outlet.%i.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.9.%i.%i", - "no", SU_OUTLET | SU_FLAG_UNIQUE | SU_TYPE_DAISY_1, &marlin_outlet_switchability_info[0] }, + "no", SU_OUTLET | SU_FLAG_UNIQUE | SU_TYPE_DAISY_1, + &marlin_outlet_switchability_info[0] }, /* FIXME: handle non switchable units (only measurements), which do not expose this OID */ { "outlet.%i.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", - "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_OUTLET | SU_FLAG_OK | SU_TYPE_DAISY_1, &g2_unit_outlet_switchability_info[0] }, + "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_OUTLET | SU_FLAG_OK | SU_TYPE_DAISY_1, + &g2_unit_outlet_switchability_info[0] }, { "outlet.%i.type", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.5.%i.%i", - "unknown", SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, &marlin_outlet_type_info[0] }, + "unknown", SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, + &marlin_outlet_type_info[0] }, /* TODO: handle statistics * outletWh.0.1 @@ -855,7 +902,8 @@ static snmp_info_t eaton_marlin_mib[] = { */ /* Outlet groups collection */ - { "outlet.group.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.21.%i", + { "outlet.group.count", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.1.2.1.21.%i", "0", SU_FLAG_STATIC | SU_TYPE_DAISY_1, NULL }, /* outlet groups template definition * Indexes start from 1, ie outlet.group.1 => .1 */ From 6bf88fbc094a4c9160184bdf41e92265ba808efb Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 25 Feb 2022 21:33:40 +0100 Subject: [PATCH 19/75] drivers/eaton-pdu-marlin-mib.c: break long lines like in FTY --- drivers/eaton-pdu-marlin-mib.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 9b0e8508bb..24941698fc 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -295,8 +295,9 @@ static snmp_info_t eaton_marlin_mib[] = { , NULL /* devices_count */ }, /* UPS collection */ - { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON", - SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, + { "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, + NULL, + "EATON", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, { "ups.model", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.4.1.534.6.6.7.1.2.1.2.%i", "Eaton Powerware ePDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL }, @@ -392,7 +393,8 @@ static snmp_info_t eaton_marlin_mib[] = { * This is depending on OID inputVoltageMeasType * INTEGER {singlePhase (1),phase1toN (2),phase2toN (3),phase3toN (4),phase1to2 (5),phase2to3 (6),phase3to1 (7) * => RFC input.Lx.voltage.context */ - { "input.voltage", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.2.1.3.%i.1.1", + { "input.voltage", 0, 0.001, + ".1.3.6.1.4.1.534.6.6.7.3.2.1.3.%i.1.1", NULL, 0, NULL }, { "input.voltage.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.2.1.4.%i.1.1", @@ -654,7 +656,7 @@ static snmp_info_t eaton_marlin_mib[] = { /* FIXME: RFC on key name is needed when backporting to NUT upstream */ /* { "input.%i.feed.color", 0, 1, * ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.%i", - * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL}, + * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, */ { "input.feed.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.1", @@ -786,7 +788,8 @@ static snmp_info_t eaton_marlin_mib[] = { /* outletName: Outlet friendly name, which can be modified by the user */ { "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.3.%i.%i", - NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, + NULL }, { "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.2.%i.%i", NULL, SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, @@ -794,7 +797,8 @@ static snmp_info_t eaton_marlin_mib[] = { /* Numeric identifier of the outlet, tied to the whole unit */ { "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.7.%i.%i", - NULL, SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, + NULL }, /* outletID: Outlet physical name, related to its number in the group * ex: first outlet of the second group (B) is B1 */ /* Outlet physical name OID in new G3 firmware (02.00.0051) @@ -803,12 +807,12 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.6.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, - NULL, NULL }, + NULL }, /* Fallback in firmwares issued before Sep 2017: */ { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.2.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, - NULL, NULL }, + NULL }, /* FIXME: the last part of the OID gives the group number (i.e. %i.1 means "group 1") * Need to address that, without multiple declaration (%i.%i, SU_OUTLET | SU_OUTLET_GROUP)? */ { "outlet.%i.groupid", ST_FLAG_STRING, SU_INFOSIZE, @@ -917,7 +921,8 @@ static snmp_info_t eaton_marlin_mib[] = { /* User-friendly (writeable) description of the outlet group: */ { "outlet.group.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.3.%i.%i", - NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL }, /* Outlet-group physical name, a read-only string, * is named groupDesignator (other MIBs groupPhysicalName) * groupPhysicalName.0.1 = Value (OctetString): A @@ -925,19 +930,21 @@ static snmp_info_t eaton_marlin_mib[] = { */ { "outlet.group.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.8.%i.%i", - NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL }, /* Outlet-group color: groupColor (other MIBs groupBkgColor) * groupColor.0.1 = Value (Gauge32): 16051527 (0xF4ED47) */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ { "outlet.group.%i.color", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.7.%i.%i", - NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL }, /* groupType.0.1 = Integer: outletSection (4) */ { "outlet.group.%i.type", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.4.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, - &marlin_outlet_group_type_info[0], NULL }, + &marlin_outlet_group_type_info[0] }, /* Phase to which an outlet-group is connected: * We use the following OID, which gives the voltage measurement type * groupVoltageMeasType.0.1; Value (Integer): singlePhase (1) @@ -946,7 +953,7 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.group.%i.phase", 0, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.3.1.2.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, - &marlin_outlet_group_phase_info[0], NULL }, + &marlin_outlet_group_phase_info[0] }, /* groupControlStatus.0.1 = Integer: on (1) */ { "outlet.group.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.6.1.2.%i.%i", From 3c553301e84e0c020d7d7548b91b0a35b909d784 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 25 Feb 2022 21:33:59 +0100 Subject: [PATCH 20/75] drivers/eaton-pdu-marlin-mib.c: relocate outlet.%i.load.off.delay etc like in FTY --- drivers/eaton-pdu-marlin-mib.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 24941698fc..7b62aefc5c 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -1068,16 +1068,6 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.%i.load.cycle", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", "0", SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - /* Delayed version, parameter is mandatory (so dfl is NULL)! */ - { "outlet.%i.load.off.delay", 0, 1, - ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", - NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.load.on.delay", 0, 1, - ".1.3.6.1.4.1.534.6.6.7.6.6.1.4.%i.%i", - NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - { "outlet.%i.load.cycle.delay", 0, 1, - ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", - NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, /* Per-outlet shutdown / startup delay (configuration point, not the timers) * outletControlShutoffDelay.0.3 = INTEGER: 120 @@ -1091,7 +1081,18 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.6.6.1.7.%i.%i", NULL, SU_FLAG_NEGINVALID | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - /* TODO: handle delays + /* Delayed version, parameter is mandatory (so dfl is NULL)! */ + { "outlet.%i.load.off.delay", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", + NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + { "outlet.%i.load.on.delay", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.4.%i.%i", + NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + { "outlet.%i.load.cycle.delay", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", + NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + + /* Delays handling: * 0-n :Time in seconds until the group command is issued * -1:Cancel a pending group-level Off/On/Reboot command */ /* groupControlOffCmd.0.1 = Integer: -1 */ From bcee36df8565648b05066bc5e95d3321d952644a Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Mon, 30 Oct 2017 12:47:10 +0100 Subject: [PATCH 21/75] eaton-pdu-marlin-mib.c/dmf: add outlet timers Add support for shutdown and start timers Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 7b62aefc5c..2cca3f23f7 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -1092,6 +1092,17 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.6.6.1.5.%i.%i", NULL, SU_TYPE_CMD | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + /* Per-outlet shutdown / startup timers + * outletControlOffCmd.0.1 = INTEGER: -1 + * outletControlOnCmd.0.1 = INTEGER: -1 + */ + { "outlet.%i.timer.shutdown", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.%i", + NULL, SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + { "outlet.%i.timer.start", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.4.%i.%i", + NULL, SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + /* Delays handling: * 0-n :Time in seconds until the group command is issued * -1:Cancel a pending group-level Off/On/Reboot command */ From 84d0d52181e7622572b3a45e6bb91bd5121ba5d0 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Tue, 26 Jun 2018 10:58:07 +0200 Subject: [PATCH 22/75] snmp-ups: Eaton ePDU input.power.nominal is realpower Fix data name, since the published value is in Watts, so realpower, not power Signed-off-by: Arnaud Quette --- docs/nut-names.txt | 2 ++ drivers/eaton-pdu-marlin-mib.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/nut-names.txt b/docs/nut-names.txt index 187f7b7efb..58db63e4de 100644 --- a/docs/nut-names.txt +++ b/docs/nut-names.txt @@ -241,6 +241,8 @@ input: Incoming line/power information of full) | 25 | input.realpower | Current sum value of all (ePDU) phases real power (W) | 300 +| input.realpower.nominal | Nominal sum value of all (ePDU) + phases real power (W) | 850 | input.power | Current sum value of all (ePDU) phases apparent power (VA) | 500 | input.source | The current input power source | 1 diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 2cca3f23f7..a2cec03e8e 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.60" +#define EATON_MARLIN_MIB_VERSION "0.61" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -663,7 +663,7 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, /* inputPowerCapacity.0.1 = INTEGER: 2300 */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ - { "input.power.nominal", 0, 1.0, + { "input.realpower.nominal", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.3.5.1.9.%i.1", NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, From f917d3dc5b320a350fdfb9d23fc0a279398b15ba Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 2 Aug 2018 11:09:15 +0200 Subject: [PATCH 23/75] snmp-ups: Eaton feed color is semi static Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index a2cec03e8e..e8253d1aa4 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.61" +#define EATON_MARLIN_MIB_VERSION "0.62" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -660,7 +660,7 @@ static snmp_info_t eaton_marlin_mib[] = { */ { "input.feed.color", 0, 1, ".1.3.6.1.4.1.534.6.6.7.3.1.1.9.%i.1", - NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_SEMI_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, /* inputPowerCapacity.0.1 = INTEGER: 2300 */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ { "input.realpower.nominal", 0, 1.0, From fe37b2243bb46bb79f96c228295f208dff0c128d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 25 Feb 2022 22:51:21 +0100 Subject: [PATCH 24/75] drivers/snmp-ups.h: avoid "#if" with possibly not-defined macro --- drivers/snmp-ups.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 508c5f4e8f..0f5f8c1d53 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -117,7 +117,7 @@ typedef int bool_t; * this macro to a specific value while building the codebase and see * what happens under different conditions ;) */ -# if WITH_DMFMIB +# if (defined WITH_DMFMIB) && (WITH_DMFMIB != 0) # define WITH_SNMP_LKP_FUN 0 # else # define WITH_SNMP_LKP_FUN 1 From f4c44f414c8b6c9b1a7432005cac767e39915bc3 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Fri, 3 Nov 2017 12:14:34 +0100 Subject: [PATCH 25/75] Add support for dry contacts to Eaton ATS16 and UPS Add support for the 2 GPI accessible through EMP001 environmental sensor, connected to a UPS or ATS16. The same is already available for Eaton ePDU. This affect the snmp-ups driver (eaton_ats16 and pw/pxgx_ups MIBs), and the netxml-ups driver Signed-off-by: Arnaud Quette --- drivers/eaton-ats16-nm2-mib.c | 20 +++++++++++++++++++- drivers/eaton-ats16-nmc-mib.c | 15 ++++++++++----- drivers/mge-mib.c | 13 ++++++++++++- drivers/mge-xml.c | 23 ++++++++++++++++++++++- drivers/powerware-mib.c | 8 +++++++- 5 files changed, 70 insertions(+), 9 deletions(-) diff --git a/drivers/eaton-ats16-nm2-mib.c b/drivers/eaton-ats16-nm2-mib.c index 256fd4359e..1980c30039 100644 --- a/drivers/eaton-ats16-nm2-mib.c +++ b/drivers/eaton-ats16-nm2-mib.c @@ -25,7 +25,7 @@ #include "eaton-ats16-nm2-mib.h" -#define EATON_ATS16_NM2_MIB_VERSION "0.21" +#define EATON_ATS16_NM2_MIB_VERSION "0.22" #define EATON_ATS16_NM2_SYSOID ".1.3.6.1.4.1.534.10.2" /* newer Network-M2 */ #define EATON_ATS16_NM2_MODEL ".1.3.6.1.4.1.534.10.2.1.2.0" @@ -78,6 +78,15 @@ static info_lkp_t eaton_ats16_nm2_output_status_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t eaton_ats16_ambient_drycontacts_info[] = { + { -1, "unknown", NULL, NULL }, + { 1, "opened", NULL, NULL }, + { 2, "closed", NULL, NULL }, + { 3, "opened", NULL, NULL }, /* openWithNotice */ + { 4, "closed", NULL, NULL }, /* closedWithNotice */ + { 0, NULL, NULL, NULL } +}; + /* EATON_ATS Snmp2NUT lookup table */ static snmp_info_t eaton_ats16_nm2_mib[] = { @@ -167,6 +176,15 @@ static snmp_info_t eaton_ats16_nm2_mib[] = { { "ambient.humidity.low", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.7.0", NULL, SU_FLAG_OK, NULL }, /* ats2EnvRemoteHumidityUpperLimit.0 = INTEGER: 90 percent */ { "ambient.humidity.high", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.8.0", NULL, SU_FLAG_OK, NULL }, + /* Dry contacts on EMP001 TH module */ + /* ats2ContactState.1 = INTEGER: open(1) */ + { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.10.2.5.4.1.3.1", + NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0] }, + /* ats2ContactState.2 = INTEGER: open(1) */ + { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.10.2.5.4.1.3.2", + NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0] }, #if 0 /* FIXME: Remaining data to be processed */ /* ats2InputStatusDephasing.0 = INTEGER: normal(1) */ diff --git a/drivers/eaton-ats16-nmc-mib.c b/drivers/eaton-ats16-nmc-mib.c index 3b75c0a5dd..0897ea056c 100644 --- a/drivers/eaton-ats16-nmc-mib.c +++ b/drivers/eaton-ats16-nmc-mib.c @@ -25,7 +25,7 @@ #include "eaton-ats16-nmc-mib.h" -#define EATON_ATS16_NMC_MIB_VERSION "0.20" +#define EATON_ATS16_NMC_MIB_VERSION "0.21" #define EATON_ATS16_NMC_SYSOID ".1.3.6.1.4.1.705.1" /* legacy NMC */ #define EATON_ATS16_NMC_MODEL ".1.3.6.1.4.1.534.10.2.1.2.0" @@ -167,6 +167,15 @@ static snmp_info_t eaton_ats16_nmc_mib[] = { { "ambient.humidity.low", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.7.0", NULL, SU_FLAG_OK, NULL }, /* ats2EnvRemoteHumidityUpperLimit.0 = INTEGER: 90 percent */ { "ambient.humidity.high", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.8.0", NULL, SU_FLAG_OK, NULL }, + /* Dry contacts on EMP001 TH module */ + /* ats2ContactState.1 = INTEGER: open(1) */ + { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.10.2.5.4.1.3.1", + NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0] }, + /* ats2ContactState.2 = INTEGER: open(1) */ + { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.10.2.5.4.1.3.2", + NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0]}, #if 0 /* FIXME: Remaining data to be processed */ /* ats2InputStatusDephasing.0 = INTEGER: normal(1) */ @@ -236,10 +245,6 @@ static snmp_info_t eaton_ats16_nmc_mib[] = { { "unmapped.ats2ContactType", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.2.1", NULL, SU_FLAG_OK, NULL }, /* ats2ContactType.2 = INTEGER: notUsed(4) */ { "unmapped.ats2ContactType", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.2.2", NULL, SU_FLAG_OK, NULL }, - /* ats2ContactState.1 = INTEGER: open(1) */ - { "unmapped.ats2ContactState", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.3.1", NULL, SU_FLAG_OK, NULL }, - /* ats2ContactState.2 = INTEGER: open(1) */ - { "unmapped.ats2ContactState", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.3.2", NULL, SU_FLAG_OK, NULL }, /* ats2ContactDescr.1 = STRING: Input #1 */ { "unmapped.ats2ContactDescr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.10.2.5.4.1.4.1", NULL, SU_FLAG_OK, NULL }, /* ats2ContactDescr.2 = STRING: Input #2 */ diff --git a/drivers/mge-mib.c b/drivers/mge-mib.c index 4430112b0b..a683379b3b 100644 --- a/drivers/mge-mib.c +++ b/drivers/mge-mib.c @@ -27,7 +27,7 @@ #include "mge-mib.h" -#define MGE_MIB_VERSION "0.54" +#define MGE_MIB_VERSION "0.55" /* TODO: * - MGE PDU MIB and sysOID (".1.3.6.1.4.1.705.2") */ @@ -132,6 +132,13 @@ static info_lkp_t mge_power_source_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t mge_ambient_drycontacts_info[] = { + { -1, "unknown", NULL, NULL }, + { 1, "closed", NULL, NULL }, + { 2, "open", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + /* Parameters default values */ #define DEFAULT_ONDELAY "30" /* Delay between return of utility power */ /* and powering up of load, in seconds */ @@ -244,6 +251,10 @@ static snmp_info_t mge_mib[] = { /* Ambient page: Environment Sensor (ref 66 846) */ { "ambient.temperature", 0, 0.1, ".1.3.6.1.4.1.705.1.8.1.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL }, { "ambient.humidity", 0, 0.1, ".1.3.6.1.4.1.705.1.8.2.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL }, + /* upsmgEnvironmentInput1State.1 */ + { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.8.7.1.9.1", "", SU_TYPE_INT | SU_FLAG_OK, mge_ambient_drycontacts_info }, + /* upsmgEnvironmentInput1State.1 */ + { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.705.1.8.7.1.10.1", "", SU_TYPE_INT | SU_FLAG_OK, mge_ambient_drycontacts_info }, /* Outlet page */ { "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, diff --git a/drivers/mge-xml.c b/drivers/mge-xml.c index 8a1a3cc497..449e212b55 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -35,7 +35,7 @@ #include "mge-xml.h" #include "main.h" /* for testvar() */ -#define MGE_XML_VERSION "MGEXML/0.32" +#define MGE_XML_VERSION "MGEXML/0.33" #define MGE_XML_INITUPS "/" #define MGE_XML_INITINFO "/mgeups/product.xml /product.xml /ws/product.xml" @@ -577,6 +577,25 @@ static const char *mge_ambient_info(const char *arg_val) } } +static const char *mge_drycontact_info(const char *val) +{ + /* these values should theoretically be obtained through + * Environment.Input[1].State[x].Description + * Examples: + * open + * closed + */ + switch (atoi(val)) + { + case 0: + return "open"; + case 1: + return "closed"; + default: + return NULL; + } +} + static const char *mge_timer_shutdown(const char *delay_before_shutoff) { if (atoi(delay_before_shutoff) > -1 ) { @@ -1059,6 +1078,8 @@ static xml_info_t mge_xml2nut[] = { { "ambient.temperature.low", ST_FLAG_RW, 0, "Environment.Temperature.LowThreshold", 0, 0, NULL }, { "ambient.temperature.maximum", 0, 0, "Environment.PresentStatus.HighTemperature", 0, 0, mge_ambient_info }, { "ambient.temperature.minimum", 0, 0, "Environment.PresentStatus.LowTemperature", 0, 0, mge_ambient_info }, + { "ambient.contacts.1.status", 0, 0, "Environment.Input[1].PresentStatus.State", 0, 0, mge_drycontact_info }, + { "ambient.contacts.2.status", 0, 0, "Environment.Input[2].PresentStatus.State", 0, 0, mge_drycontact_info }, /* Outlet page (using MGE UPS SYSTEMS - PowerShare technology) */ { "outlet.id", 0, 0, "UPS.OutletSystem.Outlet[1].OutletID", 0, 0, NULL }, diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 2d739347e0..90403239dd 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -25,7 +25,7 @@ #include "powerware-mib.h" -#define PW_MIB_VERSION "0.95" +#define PW_MIB_VERSION "0.96" /* TODO: more sysOID and MIBs support: * @@ -365,6 +365,12 @@ static snmp_info_t pw_mib[] = { { "ambient.humidity.low", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.11.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvRemoteHumidityUpperLimit.0 */ { "ambient.humidity.high", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.12.0", "", 0, NULL }, + /* XUPS-MIB::xupsContactState.1 */ + { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.1.6.8.1.3.1", "", 0, &pw_ambient_drycontacts_info[0] }, + /* XUPS-MIB::xupsContactState.2 */ + { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.1.6.8.1.3.2", "", 0, &pw_ambient_drycontacts_info[0] }, /* instant commands */ { "test.battery.start.quick", 0, 1, PW_OID_BATTEST_START, "", From d3b6ea4d891363037e0058b5ed0d9135f17fcd53 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Fri, 17 Nov 2017 15:05:29 +0100 Subject: [PATCH 26/75] Modify "open" to "opened" for dry contacts status While "open" is the best adjective for the opposite of "closed", and thus suitable for GPI status, this may lead to confusion with the GPO actions "open|close" Vs the GPI status "opened|closed". These last are also not inapropriate, since they can refer to the fact that the GPI state has change due to some external action or event Signed-off-by: Arnaud Quette --- drivers/eaton-ats16-nmc-mib.c | 10 +++++++++- drivers/eaton-pdu-marlin-mib.c | 2 +- drivers/mge-mib.c | 2 +- drivers/mge-xml.c | 4 ++-- drivers/powerware-mib.c | 9 +++++++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/eaton-ats16-nmc-mib.c b/drivers/eaton-ats16-nmc-mib.c index 0897ea056c..8cf2496bfd 100644 --- a/drivers/eaton-ats16-nmc-mib.c +++ b/drivers/eaton-ats16-nmc-mib.c @@ -78,9 +78,17 @@ static info_lkp_t eaton_ats16_nmc_output_status_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t eaton_ats16_ambient_drycontacts_info[] = { + { -1, "unknown", NULL, NULL }, + { 1, "opened", NULL, NULL }, + { 2, "closed", NULL, NULL }, + { 3, "opened", NULL, NULL }, /* openWithNotice */ + { 4, "closed", NULL, NULL }, /* closedWithNotice */ + { 0, NULL, NULL, NULL } +}; + /* EATON_ATS_NMC Snmp2NUT lookup table */ static snmp_info_t eaton_ats16_nmc_mib[] = { - /* standard MIB items */ { "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL }, { "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL }, diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index e8253d1aa4..5573cd1a0e 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -129,7 +129,7 @@ static info_lkp_t marlin_threshold_frequency_status_info[] = { static info_lkp_t marlin_ambient_drycontacts_info[] = { { -1, "unknown", NULL, NULL }, - { 0, "open", NULL, NULL }, + { 0, "opened", NULL, NULL }, { 1, "closed", NULL, NULL }, { 0, NULL, NULL, NULL } }; diff --git a/drivers/mge-mib.c b/drivers/mge-mib.c index a683379b3b..d0a844d84f 100644 --- a/drivers/mge-mib.c +++ b/drivers/mge-mib.c @@ -135,7 +135,7 @@ static info_lkp_t mge_power_source_info[] = { static info_lkp_t mge_ambient_drycontacts_info[] = { { -1, "unknown", NULL, NULL }, { 1, "closed", NULL, NULL }, - { 2, "open", NULL, NULL }, + { 2, "opened", NULL, NULL }, { 0, NULL, NULL, NULL } }; diff --git a/drivers/mge-xml.c b/drivers/mge-xml.c index 449e212b55..af9c60b2d5 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -35,7 +35,7 @@ #include "mge-xml.h" #include "main.h" /* for testvar() */ -#define MGE_XML_VERSION "MGEXML/0.33" +#define MGE_XML_VERSION "MGEXML/0.34" #define MGE_XML_INITUPS "/" #define MGE_XML_INITINFO "/mgeups/product.xml /product.xml /ws/product.xml" @@ -588,7 +588,7 @@ static const char *mge_drycontact_info(const char *val) switch (atoi(val)) { case 0: - return "open"; + return "opened"; case 1: return "closed"; default: diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 90403239dd..af7665daff 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -194,6 +194,15 @@ static info_lkp_t pw_yes_no_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t pw_ambient_drycontacts_info[] = { + { -1, "unknown", NULL, NULL }, + { 1, "opened", NULL, NULL }, + { 2, "closed", NULL, NULL }, + { 3, "opened", NULL, NULL }, /* openWithNotice */ + { 4, "closed", NULL, NULL }, /* closedWithNotice */ + { 0, NULL, NULL, NULL } +}; + /* Snmp2NUT lookup table */ static snmp_info_t pw_mib[] = { From 29c6dea2702c5b76a6bbc42fd5e27e2eacc633a9 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 12:41:40 +0100 Subject: [PATCH 27/75] drivers/eaton-pdu-marlin-mib.c: align with "snmp-ups: Simplify the mapping structure" changes for input.phases=>input.count --- drivers/eaton-pdu-marlin-mib.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 5573cd1a0e..0e43bcd100 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -340,11 +340,9 @@ static snmp_info_t eaton_marlin_mib[] = { */ /* Note: the below gives the number of input, not the number of phase(s)! */ /* inputCount.0; Value (Integer): 1 - { "input.phases", 0, 1, + { "input.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.20.0", - NULL, SU_FLAG_STATIC | SU_FLAG_SETINT, NULL - //, &input_phases - }, */ + NULL, SU_FLAG_STATIC, NULL }, */ /* Note: for daisychain mode, we must handle phase(s) per device, * not as a whole. In case of daisychain, support of the UNIQUE * field is not yet implemented (FIXME) so the last resolved OID From 53ad5cff36cfee38e938faa7184f41645991e13a Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Tue, 7 Aug 2018 09:13:33 +0200 Subject: [PATCH 28/75] snmp-ups: support newer Genepi management cards * duplicate some OIDs, with refinement to point at the first index (i.e ".0" or ".1.0") since otherwise the agent doesn't respond to queries. This could be fixed at the snmp-ups level later * fixed "ups.type" (power topology of the UPS) which was pointing at the output.source or ups.mode Signed-off-by: Arnaud Quette --- drivers/powerware-mib.c | 95 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 11 deletions(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index af7665daff..f17f79178f 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -25,7 +25,7 @@ #include "powerware-mib.h" -#define PW_MIB_VERSION "0.96" +#define PW_MIB_VERSION "0.97" /* TODO: more sysOID and MIBs support: * @@ -35,7 +35,8 @@ * PXGX 1000 cards (PDU/RPP/RPM): Get pduNumPanels ".1.3.6.1.4.1.534.6.6.4.1.1.1.4.0" */ -/* Powerware UPS (Ingrasys X-SLOT and BD-SLOT) */ +/* Powerware UPS (Ingrasys X-SLOT and BD-SLOT) + * Eaton Gigabit Network Card (Genepi) */ #define POWERWARE_SYSOID ".1.3.6.1.4.1.534.1" /* Powerware UPS newer PXGX UPS cards (BladeUPS, ...) */ #define EATON_PXGX_SYSOID ".1.3.6.1.4.1.534.2.12" @@ -78,7 +79,6 @@ #define PW_OID_CONT_ONT_DEL "1.3.6.1.4.1.534.1.9.4" /* XUPS-MIB::xupsControlOutputOnTrapDelay */ #define PW_OID_CONT_LOAD_SHED_AND_RESTART "1.3.6.1.4.1.534.1.9.6" /* XUPS-MIB::xupsLoadShedSecsWithRestart */ -#define PW_OID_CONF_OVOLTAGE "1.3.6.1.4.1.534.1.10.1.0" /* XUPS-MIB::xupsConfigOutputVoltage.0 */ #define PW_OID_CONF_IVOLTAGE "1.3.6.1.4.1.534.1.10.2.0" /* XUPS-MIB::xupsConfigInputVoltage.0 */ #define PW_OID_CONF_POWER "1.3.6.1.4.1.534.1.10.3.0" /* XUPS-MIB::xupsConfigOutputWatts.0 */ #define PW_OID_CONF_FREQ "1.3.6.1.4.1.534.1.10.4.0" /* XUPS-MIB::xupsConfigOutputFreq.0 */ @@ -135,6 +135,9 @@ static info_lkp_t pw_pwr_info[] = { { 0, NULL, NULL, NULL } }; +/* FIXME: mapped to ups.type, but should be output.source or ups.mode (need RFC) + * to complement the above ups.status + * along with having ups.type as described hereafter*/ static info_lkp_t pw_mode_info[] = { { 1, "", NULL, NULL }, { 2, "", NULL, NULL }, @@ -146,7 +149,8 @@ static info_lkp_t pw_mode_info[] = { { 8, "parallel capacity", NULL, NULL }, { 9, "parallel redundancy", NULL, NULL }, { 10, "high efficiency", NULL, NULL }, - /* Extended status values */ + /* Extended status values, + * FIXME: check for source and completion */ { 240, "" /* battery (0xF0) */, NULL, NULL }, { 100, "" /* maintenanceBypass (0x64) */, NULL, NULL }, { 96, "" /* Bypass (0x60) */, NULL, NULL }, @@ -157,6 +161,33 @@ static info_lkp_t pw_mode_info[] = { { 0, NULL, NULL, NULL } }; +/* FIXME: may be standardized + * extracted from bcmxcp.c->BCMXCP_TOPOLOGY_*, Make some common definitions */ +static info_lkp_t pw_topology_info[] = { + { 0x0000, "", NULL, NULL }, /* None; use the Table of Elements */ + { 0x0010, "Off-line switcher, Single Phase", NULL, NULL }, + { 0x0020, "Line-Interactive UPS, Single Phase", NULL, NULL }, + { 0x0021, "Line-Interactive UPS, Two Phase", NULL, NULL }, + { 0x0022, "Line-Interactive UPS, Three Phase", NULL, NULL }, + { 0x0030, "Dual AC Input, On-Line UPS, Single Phase", NULL, NULL }, + { 0x0031, "Dual AC Input, On-Line UPS, Two Phase", NULL, NULL }, + { 0x0032, "Dual AC Input, On-Line UPS, Three Phase", NULL, NULL }, + { 0x0040, "On-Line UPS, Single Phase", NULL, NULL }, + { 0x0041, "On-Line UPS, Two Phase", NULL, NULL }, + { 0x0042, "On-Line UPS, Three Phase", NULL, NULL }, + { 0x0050, "Parallel Redundant On-Line UPS, Single Phase", NULL, NULL }, + { 0x0051, "Parallel Redundant On-Line UPS, Two Phase", NULL, NULL }, + { 0x0052, "Parallel Redundant On-Line UPS, Three Phase", NULL, NULL }, + { 0x0060, "Parallel for Capacity On-Line UPS, Single Phase", NULL, NULL }, + { 0x0061, "Parallel for Capacity On-Line UPS, Two Phase", NULL, NULL }, + { 0x0062, "Parallel for Capacity On-Line UPS, Three Phase", NULL, NULL }, + { 0x0102, "System Bypass Module, Three Phase", NULL, NULL }, + { 0x0122, "Hot-Tie Cabinet, Three Phase", NULL, NULL }, + { 0x0200, "Outlet Controller, Single Phase", NULL, NULL }, + { 0x0222, "Dual AC Input Static Switch Module, 3 Phase", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + /* Legacy implementation */ static info_lkp_t pw_battery_abm_status[] = { { 1, "CHRG", NULL, NULL }, @@ -198,7 +229,7 @@ static info_lkp_t pw_ambient_drycontacts_info[] = { { -1, "unknown", NULL, NULL }, { 1, "opened", NULL, NULL }, { 2, "closed", NULL, NULL }, - { 3, "opened", NULL, NULL }, /* openWithNotice */ + { 3, "opened", NULL, NULL }, /* openWithNotice */ { 4, "closed", NULL, NULL }, /* closedWithNotice */ { 0, NULL, NULL, NULL } }; @@ -228,8 +259,14 @@ static snmp_info_t pw_mib[] = { SU_FLAG_STATIC, NULL }, { "ups.load", 0, 1.0, PW_OID_OUT_LOAD, "", SU_OUTPUT_1, NULL }, + /* FIXME: should be removed in favor of output.power */ { "ups.power", 0, 1.0, PW_OID_OUT_POWER ".1", "", 0, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsOutputWatts.1.0; Value (Integer): 300 */ + { "ups.power", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.4.1.0", "", + 0, NULL }, + { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_POWER_STATUS, "OFF", SU_STATUS_PWR, &pw_pwr_info[0] }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_ALARM_OB, "", @@ -238,10 +275,16 @@ static snmp_info_t pw_mib[] = { SU_STATUS_BATT, &pw_alarm_lb[0] }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_BATT_STATUS, "", SU_STATUS_BATT, &pw_battery_abm_status[0] }, - { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_POWER_STATUS, "", + /* FIXME: should be ups.mode or output.source (need RFC) */ + { "experimental.ups.type", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_POWER_STATUS, "", SU_FLAG_STATIC | SU_FLAG_OK, &pw_mode_info[0] }, + /* xupsTopologyType.0; Value (Integer): 32 */ + { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.4.1.534.1.13.1.0", "", + SU_FLAG_STATIC | SU_FLAG_OK, &pw_topology_info[0] }, + /* FIXME: should be removed in favor of their output. equivalent! */ { "ups.realpower.nominal", 0, 1.0, PW_OID_CONF_POWER, "", 0, NULL }, + /* FIXME: should be removed in favor of output.power.nominal */ { "ups.power.nominal", 0, 1.0, IETF_OID_CONF_OUT_VA, "", 0, NULL }, /* XUPS-MIB::xupsEnvAmbientTemp.0 */ @@ -278,7 +321,10 @@ static snmp_info_t pw_mib[] = { /* XUPS-MIB::xupsConfigOutputFreq.0 */ { "output.frequency.nominal", 0, 0.1, "1.3.6.1.4.1.534.1.10.4.0", "", 0, NULL }, /* XUPS-MIB::xupsOutputVoltage.1 */ - { "output.voltage", 0, 1.0, ".1.3.6.1.4.1.534.1.4.4.1.2.1", "", SU_OUTPUT_1, NULL }, + { "output.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.2.1", "", SU_OUTPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsOutputVoltage.1.0; Value (Integer): 230 */ + { "output.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.2.1.0", "", SU_OUTPUT_1, NULL }, /* XUPS-MIB::xupsConfigOutputVoltage.0 */ { "output.voltage.nominal", 0, 1.0, "1.3.6.1.4.1.534.1.10.1.0", "", 0, NULL }, /* XUPS-MIB::xupsConfigLowOutputVoltageLimit.0 */ @@ -287,8 +333,20 @@ static snmp_info_t pw_mib[] = { { "output.voltage.high", 0, 1.0, ".1.3.6.1.4.1.534.1.10.7.0", "", 0, NULL }, { "output.current", 0, 1.0, PW_OID_OUT_CURRENT ".1", "", SU_OUTPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsOutputCurrent.1.0; Value (Integer): 0 */ + { "output.current", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.3.1.0", "", + SU_OUTPUT_1, NULL }, { "output.realpower", 0, 1.0, PW_OID_OUT_POWER ".1", "", SU_OUTPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* Name/OID: xupsOutputWatts.1.0; Value (Integer): 1200 */ + { "output.realpower", 0, 1.0, "1.3.6.1.4.1.534.1.4.4.1.4.1.0", "", + 0, NULL }, + /* Duplicate of "ups.realpower.nominal" + * FIXME: map either ups or output, but not both (or have an auto-remap) */ + { "output.realpower.nominal", 0, 1.0, PW_OID_CONF_POWER, "", + 0, NULL }, { "output.L1-N.voltage", 0, 1.0, PW_OID_OUT_VOLTAGE ".1", "", SU_OUTPUT_3, NULL }, { "output.L2-N.voltage", 0, 1.0, PW_OID_OUT_VOLTAGE ".2", "", @@ -314,8 +372,6 @@ static snmp_info_t pw_mib[] = { SU_OUTPUT_3, NULL }, { "output.L3.power.percent", 0, 1.0, IETF_OID_LOAD_LEVEL ".3", "", SU_OUTPUT_3, NULL }, - { "output.voltage.nominal", 0, 1.0, PW_OID_CONF_OVOLTAGE, "", - 0, NULL }, /* Input page */ { "input.phases", 0, 1.0, PW_OID_IN_LINES, "", @@ -324,6 +380,12 @@ static snmp_info_t pw_mib[] = { 0, NULL }, { "input.voltage", 0, 1.0, PW_OID_IN_VOLTAGE ".0", "", SU_INPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsInputVoltage.1.0; Value (Integer): 245 */ + { "input.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.3.4.1.2.1.0", "", + SU_INPUT_1, NULL }, + + /* XUPS-MIB::xupsConfigInputVoltage.0 */ { "input.voltage.nominal", 0, 1.0, "1.3.6.1.4.1.534.1.10.2.0", "", 0, NULL }, { "input.current", 0, 0.1, PW_OID_IN_CURRENT ".0", "", @@ -354,6 +416,10 @@ static snmp_info_t pw_mib[] = { { "input.bypass.frequency", 0, 0.1, PW_OID_BY_FREQUENCY, "", 0, NULL }, { "input.bypass.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".0", "", SU_INPUT_1, NULL }, + /* Duplicate of the above entry, but pointing at the first index */ + /* xupsBypassVoltage.1.0; Value (Integer): 244 */ + { "input.bypass.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.5.3.1.2.1.0", "", + SU_INPUT_1, NULL }, { "input.bypass.L1-N.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".1", "", SU_INPUT_3, NULL }, { "input.bypass.L2-N.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".2", "", @@ -376,10 +442,17 @@ static snmp_info_t pw_mib[] = { { "ambient.humidity.high", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.12.0", "", 0, NULL }, /* XUPS-MIB::xupsContactState.1 */ { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.1.6.8.1.3.1", "", 0, &pw_ambient_drycontacts_info[0] }, + "1.3.6.1.4.1.534.1.6.8.1.3.1", "", 0, &pw_ambient_drycontacts_info[0] }, + /* Duplicate of the above entry, but pointing at the first index */ + /* FIXME: check snmp-ups->get_oid() for the walk/check on ".0" */ + { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, + "1.3.6.1.4.1.534.1.6.8.1.3.1.0", "", 0, &pw_ambient_drycontacts_info[0] }, /* XUPS-MIB::xupsContactState.2 */ { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.1.6.8.1.3.2", "", 0, &pw_ambient_drycontacts_info[0] }, + "1.3.6.1.4.1.534.1.6.8.1.3.2", "", 0, &pw_ambient_drycontacts_info[0] }, + /* Duplicate of the above entry, but pointing at the first index */ + { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, + "1.3.6.1.4.1.534.1.6.8.1.3.2.0", "", 0, &pw_ambient_drycontacts_info[0] }, /* instant commands */ { "test.battery.start.quick", 0, 1, PW_OID_BATTEST_START, "", From 8647d18b076bca31924dbd53798ea0dd84752e8a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 7 Aug 2018 20:46:28 +0200 Subject: [PATCH 29/75] powerware-mib.c : fix fallout from "snmp-ups: support newer Genepi management cards" (unused variable warning) --- drivers/powerware-mib.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index f17f79178f..d27d396b5a 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -135,9 +135,20 @@ static info_lkp_t pw_pwr_info[] = { { 0, NULL, NULL, NULL } }; -/* FIXME: mapped to ups.type, but should be output.source or ups.mode (need RFC) +/* FIXME: mapped to (experimental.)ups.type, but + * should be output.source or ups.mode (need RFC) * to complement the above ups.status * along with having ups.type as described hereafter*/ +/* FIXME: should be used by ups.mode or output.source (need RFC); + * Note: this define is not set via project options; code was hidden with + * original commit to "snmp-ups: support newer Genepi management cards"; + * un-hidden to make it "experimental.*" namespace during backporting + */ +#ifndef USE_PW_MODE_INFO +# define USE_PW_MODE_INFO 1 +#endif + +#if USE_PW_MODE_INFO static info_lkp_t pw_mode_info[] = { { 1, "", NULL, NULL }, { 2, "", NULL, NULL }, @@ -160,6 +171,7 @@ static info_lkp_t pw_mode_info[] = { { 16, "" /* none (0x10) */, NULL, NULL }, { 0, NULL, NULL, NULL } }; +#endif /* USE_PW_MODE_INFO */ /* FIXME: may be standardized * extracted from bcmxcp.c->BCMXCP_TOPOLOGY_*, Make some common definitions */ @@ -275,9 +287,13 @@ static snmp_info_t pw_mib[] = { SU_STATUS_BATT, &pw_alarm_lb[0] }, { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_BATT_STATUS, "", SU_STATUS_BATT, &pw_battery_abm_status[0] }, +#if USE_PW_MODE_INFO /* FIXME: should be ups.mode or output.source (need RFC) */ + /* Note: this define is not set via project options; code hidden with + * commit to "snmp-ups: support newer Genepi management cards" */ { "experimental.ups.type", ST_FLAG_STRING, SU_INFOSIZE, PW_OID_POWER_STATUS, "", SU_FLAG_STATIC | SU_FLAG_OK, &pw_mode_info[0] }, +#endif /* USE_PW_MODE_INFO */ /* xupsTopologyType.0; Value (Integer): 32 */ { "ups.type", ST_FLAG_STRING, SU_INFOSIZE, "1.3.6.1.4.1.534.1.13.1.0", "", SU_FLAG_STATIC | SU_FLAG_OK, &pw_topology_info[0] }, From a8e12c0082da08287370b73d606eb8d8e13b36b5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 11 Oct 2017 21:44:05 +0200 Subject: [PATCH 30/75] eaton-pdu-marlin-mib.c : preferred templated outlet.%i.name goes last in MIB --- drivers/eaton-pdu-marlin-mib.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 0e43bcd100..b876fb40fc 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -792,25 +792,37 @@ static snmp_info_t eaton_marlin_mib[] = { ".1.3.6.1.4.1.534.6.6.7.6.6.1.2.%i.%i", NULL, SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, &marlin_outlet_status_info[0] }, + /* Numeric identifier of the outlet, tied to the whole unit */ { "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.534.6.6.7.6.6.1.7.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - /* outletID: Outlet physical name, related to its number in the group - * ex: first outlet of the second group (B) is B1 */ - /* Outlet physical name OID in new G3 firmware (02.00.0051) - * outletPhysicalName.0.1 = Value (OctetString): A1 // FIXME-Check on real device + + /* NOTE: For daisychain devices ATM the last listed value presented by + * the SNMP device is kept by the driver - no SU_FLAG_UNIQUE here yet. + * Verified that a non-implemented OID does not publish empty values. */ + /* Fallback in firmwares issued before Sep 2017 is to use the + * outletID: Outlet physical name, related to its number in the group + * ex: first outlet of the second group (B) is B1, or can default to + * the outlet number (represented as string) and is a read-only string + * outletID.0.8 = Value (OctetString): "8" */ { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.6.1.1.6.%i.%i", + ".1.3.6.1.4.1.534.6.6.7.6.1.1.2.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - /* Fallback in firmwares issued before Sep 2017: */ + /* Preferred: Outlet physical name OID in new G3 firmware (02.00.0051) + * is named outletDesignator (other MIBs outletPhysicalName) + * and is a read-only string provided by firmware + * outletDesignator.0.1 = Value (OctetString): "A1" + * outletPhysicalName.0.16 = Value (OctetString): "A16" + */ { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, - ".1.3.6.1.4.1.534.6.6.7.6.1.1.2.%i.%i", + ".1.3.6.1.4.1.534.6.6.7.6.1.1.6.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, + /* FIXME: the last part of the OID gives the group number (i.e. %i.1 means "group 1") * Need to address that, without multiple declaration (%i.%i, SU_OUTLET | SU_OUTLET_GROUP)? */ { "outlet.%i.groupid", ST_FLAG_STRING, SU_INFOSIZE, From 27b92d9f7584719f248caddae669c8867a6fc7ac Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 13:16:50 +0100 Subject: [PATCH 31/75] drivers/eaton-pdu-marlin-mib.c: align comments around outlet.%i.name with FTY version --- drivers/eaton-pdu-marlin-mib.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index b876fb40fc..37a3056d95 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -794,11 +794,6 @@ static snmp_info_t eaton_marlin_mib[] = { &marlin_outlet_status_info[0] }, /* Numeric identifier of the outlet, tied to the whole unit */ - { "outlet.%i.id", 0, 1, - ".1.3.6.1.4.1.534.6.6.7.6.6.1.7.%i.%i", - NULL, SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, - NULL }, - /* NOTE: For daisychain devices ATM the last listed value presented by * the SNMP device is kept by the driver - no SU_FLAG_UNIQUE here yet. * Verified that a non-implemented OID does not publish empty values. */ @@ -808,6 +803,12 @@ static snmp_info_t eaton_marlin_mib[] = { * the outlet number (represented as string) and is a read-only string * outletID.0.8 = Value (OctetString): "8" */ + { "outlet.%i.id", 0, 1, + ".1.3.6.1.4.1.534.6.6.7.6.6.1.7.%i.%i", + NULL, SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, + NULL }, + + /* Fallback in firmwares issued before Sep 2017: */ { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.2.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, From b8591f8db840d4bd3e04940de42659061f510ec9 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Mon, 9 Sep 2019 16:43:52 +0200 Subject: [PATCH 32/75] snmp-ups: support for daisychained ambient sensor Signed-off-by: Arnaud Quette --- drivers/snmp-ups.c | 114 ++++++++++++++++++++++++++++++++++++++++++--- drivers/snmp-ups.h | 22 ++++++--- 2 files changed, 123 insertions(+), 13 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 7d9cfbbccb..b1c982ad0a 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -166,7 +166,7 @@ static const char *mibname; static const char *mibvers; #define DRIVER_NAME "Generic SNMP UPS driver" -#define DRIVER_VERSION "1.19" +#define DRIVER_VERSION "1.20" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -193,8 +193,12 @@ static int template_index_base = -1; static int device_template_index_base = -1; /* OID index of the 1rst daisychained device */ static int outlet_template_index_base = -1; static int outletgroup_template_index_base = -1; +static int ambient_template_index_base = -1; static int device_template_offset = -1; +/* Temperature handling, to convert back to Celsius */ +int temperature_unit = TEMPERATURE_UNKNOWN; + /* sysOID location */ #define SYSOID_OID ".1.3.6.1.2.1.1.2.0" @@ -2208,7 +2212,7 @@ static bool_t is_multiple_template(const char *OID_template) } /* Instantiate an snmp_info_t from a template. - * Useful for outlet and outlet.group templates. + * Useful for device, outlet, outlet.group and ambient templates. * Note: remember to adapt info_type, OID and optionaly dfl */ static snmp_info_t *instantiate_info(snmp_info_t *info_template, snmp_info_t *new_instance) { @@ -2292,6 +2296,9 @@ static int base_snmp_template_index(const snmp_info_t *su_info_p) case SU_DAISY: template_index_base = device_template_index_base; break; + case SU_AMBIENT_TEMPLATE: + template_index_base = ambient_template_index_base; + break; default: /* we should never fall here! */ upsdebugx(3, "%s: unknown template type '%" PRI_SU_FLAGS "' for %s", @@ -2356,6 +2363,8 @@ static int base_snmp_template_index(const snmp_info_t *su_info_p) outlet_template_index_base = base_index; else if (su_info_p->flags & SU_OUTLET_GROUP) outletgroup_template_index_base = base_index; + else if (su_info_p->flags & SU_AMBIENT_TEMPLATE) + ambient_template_index_base = base_index; else device_template_index_base = base_index; } @@ -2464,6 +2473,7 @@ static bool_t process_template(int mode, const char* type, snmp_info_t *su_info_ else { template_count = atoi(dstate_getinfo(template_count_var)); } + upsdebugx(1, "%i instances found...", template_count); /* Only instantiate templates if needed! */ if (template_count > 0) { @@ -2476,6 +2486,7 @@ static bool_t process_template(int mode, const char* type, snmp_info_t *su_info_ cur_template_number < (template_count + base_snmp_index) ; cur_template_number++) { + upsdebugx(1, "Processing instance %i/%i...", cur_template_number, template_count); /* Special processing for daisychain: * append 'device.x' to the NUT variable name, except for the * whole daisychain ("device.0") */ @@ -2515,7 +2526,7 @@ static bool_t process_template(int mode, const char* type, snmp_info_t *su_info_ #endif } } - else /* Outlet and outlet groups templates */ + else if (!strncmp(type, "outlet", 6)) /* Outlet and outlet groups templates */ { /* Get the index of the current template instance */ cur_nut_index = cur_template_number; @@ -2552,6 +2563,44 @@ static bool_t process_template(int mode, const char* type, snmp_info_t *su_info_ su_info_p->info_type, cur_nut_index); } } + else if (!strncmp(type, "ambient", 7)) + { + /* FIXME: can be grouped with outlet* above */ + /* Get the index of the current template instance */ + cur_nut_index = cur_template_number; + + /* Special processing for daisychain */ + if (daisychain_enabled == TRUE) { + /* Only publish on the daisychain host */ + if ( (su_info_p->flags & SU_TYPE_DAISY_MASTER_ONLY) + && (current_device_number != 1) ) { + upsdebugx(2, "discarding variable due to daisychain master flag"); + continue; + } + + /* Device(s) 1-N (master + slave(s)) need to append 'device.x' */ + if ((devices_count > 1) && (current_device_number > 0)) { + memset(&tmp_buf[0], 0, SU_INFOSIZE); + strcat(&tmp_buf[0], "device.%i."); + strcat(&tmp_buf[0], su_info_p->info_type); + + upsdebugx(4, "FORMATTING STRING = %s", &tmp_buf[0]); + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + &tmp_buf[0], current_device_number, cur_nut_index); + } + else { + /* FIXME: daisychain-whole, what to do? */ + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + su_info_p->info_type, cur_nut_index); + } + } + else { + snprintf((char*)cur_info_p.info_type, SU_INFOSIZE, + su_info_p->info_type, cur_nut_index); + } + } + else + upsdebugx(4, "Error: unknown template type '%s", type); /* check if default value is also a template */ if ((cur_info_p.dfl != NULL) && @@ -2580,9 +2629,14 @@ static bool_t process_template(int mode, const char* type, snmp_info_t *su_info_ snprintf((char *)cur_info_p.OID, SU_INFOSIZE, su_info_p->OID, current_device_number + device_template_offset, cur_template_number); } - else { + else if (su_info_p->flags & SU_TYPE_DAISY_2) { snprintf((char *)cur_info_p.OID, SU_INFOSIZE, - su_info_p->OID, cur_template_number + device_template_offset, current_device_number - device_template_offset); + su_info_p->OID, cur_template_number + device_template_offset, + current_device_number - device_template_offset); + } + else { + /* Note: no device daisychain templating (SU_TYPE_DAISY_MASTER_ONLY)! */ + snprintf((char *)cur_info_p.OID, SU_INFOSIZE, su_info_p->OID, cur_template_number); } } else { @@ -2638,6 +2692,10 @@ snmp_info_flags_t get_template_type(const char* varname) upsdebugx(4, "device template"); return SU_DAISY; } + else if (!strncmp(varname, "ambient", 7)) { + upsdebugx(4, "ambient template"); + return SU_AMBIENT_TEMPLATE; + } else { upsdebugx(2, "Unknown template type: %s", varname); return 0; @@ -2657,6 +2715,8 @@ int extract_template_number(snmp_info_flags_t template_type, const char* varname item_number_ptr = &varname[6]; else if (template_type & SU_DAISY) item_number_ptr = &varname[6]; + else if (template_type & SU_AMBIENT_TEMPLATE) + item_number_ptr = &varname[7]; else return -1; @@ -3103,7 +3163,8 @@ bool_t snmp_ups_walk(int mode) * Not applicable to outlets (need SU_FLAG_STATIC tagging) */ if ((su_info_p->flags & SU_FLAG_ABSENT) && !(su_info_p->flags & SU_OUTLET) - && !(su_info_p->flags & SU_OUTLET_GROUP)) + && !(su_info_p->flags & SU_OUTLET_GROUP) + && !(su_info_p->flags & SU_AMBIENT_TEMPLATE)) { if (mode == SU_WALKMODE_INIT) { @@ -3175,6 +3236,13 @@ bool_t snmp_ups_walk(int mode) else status = process_template(mode, "outlet.group", su_info_p); } + else if (su_info_p->flags & SU_AMBIENT_TEMPLATE) { + /* Skip commands after init */ + if ((SU_TYPE(su_info_p) == SU_TYPE_CMD) && (mode == SU_WALKMODE_UPDATE)) + continue; + else + status = process_template(mode, "ambient", su_info_p); + } else { /* if (daisychain_enabled == TRUE) { status = process_template(mode, "device", su_info_p); @@ -3990,3 +4058,37 @@ void read_mibconf(char *mib) } pconf_finish(&ctx); } + +/*********************************************************************** + * Subdrivers shared helpers functions + **********************************************************************/ + +static char su_scratch_buf[20]; + +/* Process temperature value according to 'temperature_unit' */ +const char *su_temperature_read_fun(long snmp_value) +{ + memset(su_scratch_buf, 0, sizeof(su_scratch_buf)); + long celsius_value = snmp_value; + + switch (temperature_unit) { + case TEMPERATURE_KELVIN: + celsius_value = (snmp_value / 10) - 273.15; + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); + break; + case TEMPERATURE_CELSIUS: + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", (snmp_value / 10)); + break; + case TEMPERATURE_FARHENHEIT: + celsius_value = (((snmp_value / 10) - 32) * 5) / 9; + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); + break; + case TEMPERATURE_UNKNOWN: + default: + upsdebugx(1, "%s: not a known temperature unit for conversion!", __func__); + break; + } + upsdebugx(2, "%s: %.1ld => %s", __func__, (snmp_value / 10), su_scratch_buf); + return su_scratch_buf; +} + diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 0f5f8c1d53..c3dc8decfd 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -244,17 +244,14 @@ typedef struct { /* "flags" bits 21..23 (and 24 reserved for DMF) */ #define SU_TYPE_DAISY_1 (1UL << 21) /* Daisychain index is the 1st specifier */ #define SU_TYPE_DAISY_2 (1UL << 22) /* Daisychain index is the 2nd specifier */ -#define SU_TYPE_DAISY(t) ((t)->flags & (3UL << 21)) /* Mask the 2 SU_TYPE_DAISY_* but not SU_DAISY */ +#define SU_TYPE_DAISY(t) ((t)->flags & (11UL << 21)) /* Mask the SU_TYPE_DAISY_{1,2,MASTER_ONLY} but not SU_DAISY */ #define SU_DAISY (1UL << 23) /* Daisychain template definition - set at run-time for devices with detected "device.count" over 1 */ -/* NOTE: Previously SU_DAISY had same bit-flag value as SU_TYPE_DAISY_2*/ -/* Reserved slot -- to import from DMF branch codebase -// (and change SU_TYPE_DAISY to 11UL<<21 for the 3 types then): -//#define SU_TYPE_DAISY_MASTER_ONLY (1UL << 24)*/ /* Only valid for daisychain master (device.1) */ +/* NOTE: Previously SU_DAISY had same bit-flag value as SU_TYPE_DAISY_2 */ +#define SU_TYPE_DAISY_MASTER_ONLY (1UL << 24) /* Only valid for daisychain master (device.1) */ /* Free slot: (1UL << 25) */ -/* Reserved slot -- to import from DMF branch codebase: -//#define SU_AMBIENT_TEMPLATE (1UL << 26)*/ /* ambient template definition */ +#define SU_AMBIENT_TEMPLATE (1UL << 26) /* ambient template definition */ /* Reserved slot -- to import from DMF branch codebase: //#define SU_FLAG_FUNCTION (1UL << 27) @@ -372,6 +369,17 @@ extern info_lkp_t su_convert_to_iso_date_info[]; /* Name the mapping location in that array for consumers to reference */ #define FUNMAP_USDATE_TO_ISODATE 0 +/* Process temperature value according to 'temperature_unit' */ +const char *su_temperature_read_fun(long snmp_value); + +/* Temperature handling, to convert back to Celsius (NUT standard) */ +extern int temperature_unit; + +#define TEMPERATURE_UNKNOWN 0 +#define TEMPERATURE_CELSIUS 1 +#define TEMPERATURE_KELVIN 2 +#define TEMPERATURE_FARHENHEIT 3 + /***************************************************** * End of Subdrivers shared helpers functions *****************************************************/ From ebcac3ba4833910a46caf6765e2882b8acf437ed Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Mon, 9 Sep 2019 16:45:12 +0200 Subject: [PATCH 33/75] SNMP Eaton ePDU: support for EMPDT1H1C2 Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-helpers.c | 28 ++++++- drivers/eaton-pdu-marlin-helpers.h | 3 +- drivers/eaton-pdu-marlin-mib.c | 123 ++++++++++++++++++++++++++++- 3 files changed, 151 insertions(+), 3 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 9e86574011..cbbaed9307 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -3,7 +3,7 @@ * G2 Marlin SW / MI / MO / MA * G3 Shark SW / MI / MO / MA * - * Copyright (C) 2017 + * Copyright (C) 2017-2019 * Arnaud Quette * Copyright (C) 2017 * Jim Klimov @@ -34,6 +34,9 @@ #include "eaton-pdu-marlin-helpers.h" #include "dstate.h" +/* Allow access to temperature_unit */ +#include "snmp-ups.h" + /* Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount * of "," separators+1 using an inline function */ @@ -52,3 +55,26 @@ long marlin_device_count_fun(const char *daisy_dev_list) } return count; } + +/* Temperature unit consideration */ +const char *eaton_sensor_temperature_unit_fun(long snmp_value) +{ + switch (snmp_value) { + case 0: + /* store the value, for temperature processing */ + temperature_unit = TEMPERATURE_KELVIN; + return "kelvin"; + case 1: + /* store the value, for temperature processing */ + temperature_unit = TEMPERATURE_CELSIUS; + return "celsius"; + case 2: + /* store the value, for temperature processing */ + temperature_unit = TEMPERATURE_FARHENHEIT; + return "farhenheit"; + default: + /* store the value, for temperature processing */ + temperature_unit = TEMPERATURE_UNKNOWN; + return "unknown"; + } +} diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h index 50a1d5e37e..070896e22f 100644 --- a/drivers/eaton-pdu-marlin-helpers.h +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -2,7 +2,7 @@ * Eaton ePDU SNMP devices with NUT * * Copyright (C) - * 2017 Arnaud Quette + * 2017-2019 Arnaud Quette * 2017 Jim Klimov * * This program is free software; you can redistribute it and/or modify @@ -24,5 +24,6 @@ #define EATON_EPDU_MARLIN_HELPERS_H long marlin_device_count_fun(const char *daisy_dev_list); +const char *eaton_sensor_temperature_unit_fun(long snmp_value); #endif /* EATON_EPDU_MARLIN_HELPERS_H */ diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 37a3056d95..a384decd52 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.62" +#define EATON_MARLIN_MIB_VERSION "0.63" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -206,6 +206,57 @@ static info_lkp_t marlin_outlet_group_phase_info[] = { { 0, NULL, NULL, NULL } }; +#if WITH_SNMP_LKP_FUN +/* Note: eaton_sensor_temperature_unit_fun() is defined in eaton-pdu-marlin-helpers.c + * Future work for DMF might provide a same-named routine via LUA-C gateway. + */ + +#if WITH_SNMP_LKP_FUN_DUMMY +/* Temperature unit consideration */ +const char *eaton_sensor_temperature_unit_fun(long snmp_value) + { return "unknown"; } +/* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ +const char *su_temperature_read_fun(long snmp_value) + { return "dummy"; }; +#endif // WITH_SNMP_LKP_FUN_DUMMY + +static info_lkp_t eaton_sensor_temperature_unit_info[] = { + { 0, "dummy", eaton_sensor_temperature_unit_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t eaton_sensor_temperature_read_info[] = { + { 0, "dummy", su_temperature_read_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +#else // if not WITH_SNMP_LKP_FUN: + +/* FIXME: For now, DMF codebase falls back to old implementation with static + * lookup/mapping tables for this, which can easily go into the DMF XML file. + */ +static info_lkp_t eaton_sensor_temperature_unit_info[] = { + { 0, "kelvin", NULL, NULL }, + { 1, "celsius", NULL, NULL }, + { 2, "farhenheit", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +#endif // WITH_SNMP_LKP_FUN + +/* Extracted from powerware-mib.c ; try to commonalize */ +static info_lkp_t ambient_drycontacts_polarity_info[] = { + { 0, "normal-opened", NULL, NULL }, + { 1, "normal-closed", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ambient_drycontacts_state_info[] = { + { 0, "active", NULL, NULL }, + { 1, "inactive", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + #if WITH_SNMP_LKP_FUN /* Note: marlin_device_count_fun() is defined in eaton-pdu-marlin-helpers.c * Future work for DMF might provide a same-named routine via LUA-C gateway. @@ -666,6 +717,8 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_NEGINVALID | SU_FLAG_OK, NULL }, /* Ambient collection */ + /* EMP001 (legacy) mapping */ + /* Note: this is still published, beside from the new daisychained version! */ { "ambient.present", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.7.1.1.3.%i.1", NULL, SU_FLAG_OK, @@ -740,6 +793,74 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_OK, &marlin_ambient_drycontacts_info[0] }, + + /* EMP002 (EATON EMP MIB) mapping, including daisychain support */ + /* Warning: indexes start at '1' not '0'! */ + /* sensorCount.0 */ + { "ambient.count", ST_FLAG_RW, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.1.0", "0", SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorName.n: OctetString EMPDT1H1C2 @1 */ + { "ambient.%i.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.3.1.1.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorManufacturer.n */ + { "ambient.%i.mfr", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.6.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorModel.n */ + { "ambient.%i.model", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.7.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorSerialNumber.n */ + { "ambient.%i.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorFirmwareVersion.n */ + { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* temperatureUnit.1 + * MUST be before the temperature data reading! */ + { "ambient.%i.temperature.unit", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &eaton_sensor_temperature_unit_info[0] }, + /* temperatureValue.n.1 */ + { "ambient.%i.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, +#if WITH_SNMP_LKP_FUN + &eaton_sensor_temperature_read_info[0] +#else + NULL +#endif + }, + { "ambient.%i.temperature.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_status_info[0] }, + { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_temperature_alarms_info[0] }, + /* FIXME: ambient.n.temperature.{minimum,maximum} */ + /* temperatureThresholdLowCritical.n.1 */ + { "ambient.%i.temperature.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* temperatureThresholdLowWarning.n.1 */ + { "ambient.%i.temperature.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* temperatureThresholdHighWarning.n.1 */ + { "ambient.%i.temperature.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* temperatureThresholdHighCritical.n.1 */ + { "ambient.%i.temperature.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* humidityValue.n.1 */ + { "ambient.%i.humidity", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.humidity.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_status_info[0] }, + { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_humidity_alarms_info[0] }, + /* FIXME: consider ambient.n.humidity.{minimum,maximum} */ + /* humidityThresholdLowCritical.n.1 */ + { "ambient.%i.humidity.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* humidityThresholdLowWarning.n.1 */ + { "ambient.%i.humidity.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* humidityThresholdHighWarning.n.1 */ + { "ambient.%i.humidity.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* humidityThresholdHighCritical.n.1 */ + { "ambient.%i.humidity.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* digitalInputName.n.{1,2} */ + { "ambient.%i.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* digitalInputPolarity.n */ + { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_polarity_info[0] }, + /* XUPS-MIB::xupsContactState.n */ + { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_state_info[0] }, + /* Outlet collection */ { "outlet.count", 0, 1, ".1.3.6.1.4.1.534.6.6.7.1.2.1.22.%i", From 23054dfa45ff87ced114e3042382be12bc737913 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 11 Oct 2017 02:56:42 +0200 Subject: [PATCH 34/75] eaton-pdu-marlin-helpers.c : in device_count helper do not assume a trailing comma (as last char) as an extra device --- drivers/eaton-pdu-marlin-helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index cbbaed9307..7663379ada 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -49,8 +49,8 @@ long marlin_device_count_fun(const char *daisy_dev_list) count ++; } } - if (i>0) { - /* Non-empty string => at least one device */ + if (i>0 && (daisy_dev_list[i-1] != ',') ) { + /* Non-empty string => at least one device, and no trailing commas */ count ++; } return count; From 1cfb80912a77b0304b31d61f26a21d4002ff0d7d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 15:12:51 +0100 Subject: [PATCH 35/75] drivers/eaton-pdu-marlin-helpers.c: fix whitespace --- drivers/eaton-pdu-marlin-helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 7663379ada..1bea9a5563 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -43,13 +43,13 @@ long marlin_device_count_fun(const char *daisy_dev_list) { long count = 0, i; - for (i=0; daisy_dev_list[i] != '\0'; i++) { + for (i = 0; daisy_dev_list[i] != '\0'; i++) { if (daisy_dev_list[i] == ',') { /* Each comma means a new device in the list */ count ++; } } - if (i>0 && (daisy_dev_list[i-1] != ',') ) { + if (i > 0 && (daisy_dev_list[i - 1] != ',') ) { /* Non-empty string => at least one device, and no trailing commas */ count ++; } From 952ab95ab07cf2fb9c1975a7f1e84d0fdbfed086 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Mon, 9 Sep 2019 16:46:34 +0200 Subject: [PATCH 36/75] SNMP Eaton Gb Network Card: support for EMPDT1H1C2 Signed-off-by: Arnaud Quette --- drivers/powerware-mib.c | 179 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 163 insertions(+), 16 deletions(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index d27d396b5a..f46ee9b375 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -4,7 +4,7 @@ * Copyright (C) * 2005-2006 Olli Savia * 2005-2006 Niels Baggesen - * 2015-2021 Eaton (author: Arnaud Quette ) + * 2015-2019 Eaton (author: Arnaud Quette ) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,12 @@ */ #include "powerware-mib.h" +#if WITH_SNMP_LKP_FUN +/* FIXME: shared helper code, need to be put in common */ +#include "eaton-pdu-marlin-helpers.h" +#endif -#define PW_MIB_VERSION "0.97" +#define PW_MIB_VERSION "0.98" /* TODO: more sysOID and MIBs support: * @@ -79,6 +83,7 @@ #define PW_OID_CONT_ONT_DEL "1.3.6.1.4.1.534.1.9.4" /* XUPS-MIB::xupsControlOutputOnTrapDelay */ #define PW_OID_CONT_LOAD_SHED_AND_RESTART "1.3.6.1.4.1.534.1.9.6" /* XUPS-MIB::xupsLoadShedSecsWithRestart */ +#define PW_OID_CONF_OVOLTAGE "1.3.6.1.4.1.534.1.10.1.0" /* XUPS-MIB::xupsConfigOutputVoltage.0 */ #define PW_OID_CONF_IVOLTAGE "1.3.6.1.4.1.534.1.10.2.0" /* XUPS-MIB::xupsConfigInputVoltage.0 */ #define PW_OID_CONF_POWER "1.3.6.1.4.1.534.1.10.3.0" /* XUPS-MIB::xupsConfigOutputWatts.0 */ #define PW_OID_CONF_FREQ "1.3.6.1.4.1.534.1.10.4.0" /* XUPS-MIB::xupsConfigOutputFreq.0 */ @@ -246,6 +251,85 @@ static info_lkp_t pw_ambient_drycontacts_info[] = { { 0, NULL, NULL, NULL } }; +#if WITH_SNMP_LKP_FUN +/* Note: eaton_sensor_temperature_unit_fun() is defined in powerware-helpers.c + * Future work for DMF might provide a same-named routine via LUA-C gateway. + */ + +#if WITH_SNMP_LKP_FUN_DUMMY +/* Temperature unit consideration */ +const char *eaton_sensor_temperature_unit_fun(long snmp_value) + { return "unknown"; } +/* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ +const char *su_temperature_read_fun(long snmp_value) + { return "dummy"; }; +#endif // WITH_SNMP_LKP_FUN_DUMMY + +static info_lkp_t eaton_sensor_temperature_unit_info[] = { + { 0, "dummy", eaton_sensor_temperature_unit_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t eaton_sensor_temperature_read_info[] = { + { 0, "dummy", su_temperature_read_fun, NULL }, + { 0, NULL, NULL, NULL } +}; + +#else // if not WITH_SNMP_LKP_FUN: + +/* FIXME: For now, DMF codebase falls back to old implementation with static + * lookup/mapping tables for this, which can easily go into the DMF XML file. + */ +static info_lkp_t eaton_sensor_temperature_unit_info[] = { + { 0, "kelvin", NULL, NULL }, + { 1, "celsius", NULL, NULL }, + { 2, "farhenheit", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +#endif // WITH_SNMP_LKP_FUN + +static info_lkp_t ambient_drycontacts_polarity_info[] = { + { 0, "normal-opened", NULL, NULL }, + { 1, "normal-closed", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t ambient_drycontacts_state_info[] = { + { 0, "active", NULL, NULL }, + { 1, "inactive", NULL, NULL }, + { 0, NULL, NULL, NULL } +}; + +/* extracted from drivers/eaton-pdu-marlin-mib.c -> marlin_threshold_status_info */ +static info_lkp_t pw_threshold_status_info[] = { + { 0, "good", NULL, NULL }, /* No threshold triggered */ + { 1, "warning-low", NULL, NULL }, /* Warning low threshold triggered */ + { 2, "critical-low", NULL, NULL }, /* Critical low threshold triggered */ + { 3, "warning-high", NULL, NULL }, /* Warning high threshold triggered */ + { 4, "critical-high", NULL, NULL }, /* Critical high threshold triggered */ + { 0, NULL, NULL, NULL } +}; + +/* extracted from drivers/eaton-pdu-marlin-mib.c -> marlin_threshold_xxx_alarms_info */ +static info_lkp_t pw_threshold_temperature_alarms_info[] = { + { 0, "", NULL, NULL }, /* No threshold triggered */ + { 1, "low temperature warning!", NULL, NULL }, /* Warning low threshold triggered */ + { 2, "low temperature critical!", NULL, NULL }, /* Critical low threshold triggered */ + { 3, "high temperature warning!", NULL, NULL }, /* Warning high threshold triggered */ + { 4, "high temperature critical!", NULL, NULL }, /* Critical high threshold triggered */ + { 0, NULL, NULL, NULL } +}; + +static info_lkp_t pw_threshold_humidity_alarms_info[] = { + { 0, "", NULL, NULL }, /* No threshold triggered */ + { 1, "low humidity warning!", NULL, NULL }, /* Warning low threshold triggered */ + { 2, "low humidity critical!", NULL, NULL }, /* Critical low threshold triggered */ + { 3, "high humidity warning!", NULL, NULL }, /* Warning high threshold triggered */ + { 4, "high humidity critical!", NULL, NULL }, /* Critical high threshold triggered */ + { 0, NULL, NULL, NULL } +}; + /* Snmp2NUT lookup table */ static snmp_info_t pw_mib[] = { @@ -388,6 +472,8 @@ static snmp_info_t pw_mib[] = { SU_OUTPUT_3, NULL }, { "output.L3.power.percent", 0, 1.0, IETF_OID_LOAD_LEVEL ".3", "", SU_OUTPUT_3, NULL }, + { "output.voltage.nominal", 0, 1.0, PW_OID_CONF_OVOLTAGE, "", + 0, NULL }, /* Input page */ { "input.phases", 0, 1.0, PW_OID_IN_LINES, "", @@ -443,7 +529,8 @@ static snmp_info_t pw_mib[] = { { "input.bypass.L3-N.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".3", "", SU_INPUT_3, NULL }, - /* Ambient page */ + /* Ambient collection */ + /* EMP001 (legacy) mapping */ /* XUPS-MIB::xupsEnvRemoteTemp.0 */ { "ambient.temperature", 0, 1.0, "1.3.6.1.4.1.534.1.6.5.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvRemoteTempLowerLimit.0 */ @@ -456,19 +543,79 @@ static snmp_info_t pw_mib[] = { { "ambient.humidity.low", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.11.0", "", 0, NULL }, /* XUPS-MIB::xupsEnvRemoteHumidityUpperLimit.0 */ { "ambient.humidity.high", ST_FLAG_RW, 1.0, "1.3.6.1.4.1.534.1.6.12.0", "", 0, NULL }, - /* XUPS-MIB::xupsContactState.1 */ - { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, - "1.3.6.1.4.1.534.1.6.8.1.3.1", "", 0, &pw_ambient_drycontacts_info[0] }, - /* Duplicate of the above entry, but pointing at the first index */ - /* FIXME: check snmp-ups->get_oid() for the walk/check on ".0" */ - { "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE, - "1.3.6.1.4.1.534.1.6.8.1.3.1.0", "", 0, &pw_ambient_drycontacts_info[0] }, - /* XUPS-MIB::xupsContactState.2 */ - { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, - "1.3.6.1.4.1.534.1.6.8.1.3.2", "", 0, &pw_ambient_drycontacts_info[0] }, - /* Duplicate of the above entry, but pointing at the first index */ - { "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE, - "1.3.6.1.4.1.534.1.6.8.1.3.2.0", "", 0, &pw_ambient_drycontacts_info[0] }, + /* XUPS-MIB::xupsContactDescr.n */ + { "ambient.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.4.1", "", 0, NULL }, + { "ambient.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.4.2", "", 0, NULL }, + /* XUPS-MIB::xupsContactState.n */ + { "ambient.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.3.1", "", 0, &pw_ambient_drycontacts_info[0] }, + { "ambient.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.1.6.8.1.3.2", "", 0, &pw_ambient_drycontacts_info[0] }, + + /* EMP002 (EATON EMP MIB) mapping, including daisychain support */ + /* Warning: indexes start at '1' not '0'! */ + /* sensorCount.0 */ + { "ambient.count", ST_FLAG_RW, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.1.0", "", 0, NULL }, + /* sensorName.n: OctetString EMPDT1H1C2 @1 */ + { "ambient.%i.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.3.1.1.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorManufacturer.n */ + { "ambient.%i.mfr", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.6.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorModel.n */ + { "ambient.%i.model", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.7.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorSerialNumber.n */ + { "ambient.%i.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorFirmwareVersion.n */ + { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureUnit.1 + * MUST be before the temperature data reading! */ + { "ambient.%i.temperature.unit", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE, &eaton_sensor_temperature_unit_info[0] }, + /* temperatureValue.n.1 */ + { "ambient.%i.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, +#if WITH_SNMP_LKP_FUN + &eaton_sensor_temperature_read_info[0] +#else + NULL +#endif + }, + { "ambient.%i.temperature.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_status_info[0] }, + { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_temperature_alarms_info[0] }, + /* FIXME: ambient.n.temperature.{minimum,maximum} */ + /* temperatureThresholdLowCritical.n.1 */ + { "ambient.%i.temperature.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureThresholdLowWarning.n.1 */ + { "ambient.%i.temperature.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureThresholdHighWarning.n.1 */ + { "ambient.%i.temperature.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* temperatureThresholdHighCritical.n.1 */ + { "ambient.%i.temperature.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityValue.n.1 */ + { "ambient.%i.humidity", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + { "ambient.%i.humidity.status", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_status_info[0] }, + { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", + NULL, SU_AMBIENT_TEMPLATE, &pw_threshold_humidity_alarms_info[0] }, + /* FIXME: consider ambient.n.humidity.{minimum,maximum} */ + /* humidityThresholdLowCritical.n.1 */ + { "ambient.%i.humidity.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityThresholdLowWarning.n.1 */ + { "ambient.%i.humidity.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityThresholdHighWarning.n.1 */ + { "ambient.%i.humidity.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* humidityThresholdHighCritical.n.1 */ + { "ambient.%i.humidity.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + /* digitalInputName.n.{1,2} */ + { "ambient.%i.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, + { "ambient.%i.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.2", "", SU_AMBIENT_TEMPLATE, NULL }, + /* digitalInputPolarity.n */ + { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_polarity_info[0] }, + /* XUPS-MIB::xupsContactState.n */ + { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_state_info[0] }, /* instant commands */ { "test.battery.start.quick", 0, 1, PW_OID_BATTEST_START, "", From 8e181ef403497249369efe15b9e277e8b381fad0 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 12 Sep 2019 14:58:35 +0200 Subject: [PATCH 37/75] Fix compilation warning Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index a384decd52..de30b38a1f 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -217,7 +217,7 @@ const char *eaton_sensor_temperature_unit_fun(long snmp_value) { return "unknown"; } /* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ const char *su_temperature_read_fun(long snmp_value) - { return "dummy"; }; + { return "dummy"; } #endif // WITH_SNMP_LKP_FUN_DUMMY static info_lkp_t eaton_sensor_temperature_unit_info[] = { From 43d8c6608029e118372171755ccd486913fb687b Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 12 Sep 2019 18:00:10 +0200 Subject: [PATCH 38/75] Typo fix: sorry Mr Fahrenheit And thanks to Jim Klimov for the review! Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-helpers.c | 4 ++-- drivers/eaton-pdu-marlin-mib.c | 2 +- drivers/powerware-mib.c | 2 +- drivers/snmp-ups.c | 2 +- drivers/snmp-ups.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 1bea9a5563..dd2baa50a6 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -70,8 +70,8 @@ const char *eaton_sensor_temperature_unit_fun(long snmp_value) return "celsius"; case 2: /* store the value, for temperature processing */ - temperature_unit = TEMPERATURE_FARHENHEIT; - return "farhenheit"; + temperature_unit = TEMPERATURE_FAHRENHEIT; + return "fahrenheit"; default: /* store the value, for temperature processing */ temperature_unit = TEMPERATURE_UNKNOWN; diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index de30b38a1f..1709d17d21 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -238,7 +238,7 @@ static info_lkp_t eaton_sensor_temperature_read_info[] = { static info_lkp_t eaton_sensor_temperature_unit_info[] = { { 0, "kelvin", NULL, NULL }, { 1, "celsius", NULL, NULL }, - { 2, "farhenheit", NULL, NULL }, + { 2, "fahrenheit", NULL, NULL }, { 0, NULL, NULL, NULL } }; diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index f46ee9b375..5aae5fcda9 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -283,7 +283,7 @@ static info_lkp_t eaton_sensor_temperature_read_info[] = { static info_lkp_t eaton_sensor_temperature_unit_info[] = { { 0, "kelvin", NULL, NULL }, { 1, "celsius", NULL, NULL }, - { 2, "farhenheit", NULL, NULL }, + { 2, "fahrenheit", NULL, NULL }, { 0, NULL, NULL, NULL } }; diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index b1c982ad0a..fcec2c09da 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -4079,7 +4079,7 @@ const char *su_temperature_read_fun(long snmp_value) case TEMPERATURE_CELSIUS: snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", (snmp_value / 10)); break; - case TEMPERATURE_FARHENHEIT: + case TEMPERATURE_FAHRENHEIT: celsius_value = (((snmp_value / 10) - 32) * 5) / 9; snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); break; diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index c3dc8decfd..c71b371f6a 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -378,7 +378,7 @@ extern int temperature_unit; #define TEMPERATURE_UNKNOWN 0 #define TEMPERATURE_CELSIUS 1 #define TEMPERATURE_KELVIN 2 -#define TEMPERATURE_FARHENHEIT 3 +#define TEMPERATURE_FAHRENHEIT 3 /***************************************************** * End of Subdrivers shared helpers functions From 2c1fb1d10a24ef6d6ae623a40106e9cbb729b978 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 25 May 2016 10:07:08 +0200 Subject: [PATCH 39/75] powerware-mib - renamed "ietf_*" and "eaton_*" lookups to have "pw_*" prefix --- drivers/powerware-mib.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 5aae5fcda9..932238405b 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -256,46 +256,46 @@ static info_lkp_t pw_ambient_drycontacts_info[] = { * Future work for DMF might provide a same-named routine via LUA-C gateway. */ -#if WITH_SNMP_LKP_FUN_DUMMY +# if WITH_SNMP_LKP_FUN_DUMMY /* Temperature unit consideration */ const char *eaton_sensor_temperature_unit_fun(long snmp_value) { return "unknown"; } /* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ const char *su_temperature_read_fun(long snmp_value) { return "dummy"; }; -#endif // WITH_SNMP_LKP_FUN_DUMMY +# endif /* WITH_SNMP_LKP_FUN_DUMMY */ -static info_lkp_t eaton_sensor_temperature_unit_info[] = { +static info_lkp_t pw_sensor_temperature_unit_info[] = { { 0, "dummy", eaton_sensor_temperature_unit_fun, NULL }, { 0, NULL, NULL, NULL } }; -static info_lkp_t eaton_sensor_temperature_read_info[] = { +static info_lkp_t pw_sensor_temperature_read_info[] = { { 0, "dummy", su_temperature_read_fun, NULL }, { 0, NULL, NULL, NULL } }; -#else // if not WITH_SNMP_LKP_FUN: +#else /* if not WITH_SNMP_LKP_FUN: */ /* FIXME: For now, DMF codebase falls back to old implementation with static * lookup/mapping tables for this, which can easily go into the DMF XML file. */ -static info_lkp_t eaton_sensor_temperature_unit_info[] = { +static info_lkp_t pw_sensor_temperature_unit_info[] = { { 0, "kelvin", NULL, NULL }, { 1, "celsius", NULL, NULL }, { 2, "fahrenheit", NULL, NULL }, { 0, NULL, NULL, NULL } }; -#endif // WITH_SNMP_LKP_FUN +#endif /* WITH_SNMP_LKP_FUN */ -static info_lkp_t ambient_drycontacts_polarity_info[] = { +static info_lkp_t pw_ambient_drycontacts_polarity_info[] = { { 0, "normal-opened", NULL, NULL }, { 1, "normal-closed", NULL, NULL }, { 0, NULL, NULL, NULL } }; -static info_lkp_t ambient_drycontacts_state_info[] = { +static info_lkp_t pw_ambient_drycontacts_state_info[] = { { 0, "active", NULL, NULL }, { 1, "inactive", NULL, NULL }, { 0, NULL, NULL, NULL } @@ -566,11 +566,11 @@ static snmp_info_t pw_mib[] = { { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* temperatureUnit.1 * MUST be before the temperature data reading! */ - { "ambient.%i.temperature.unit", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE, &eaton_sensor_temperature_unit_info[0] }, + { "ambient.%i.temperature.unit", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE, &pw_sensor_temperature_unit_info[0] }, /* temperatureValue.n.1 */ { "ambient.%i.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, #if WITH_SNMP_LKP_FUN - &eaton_sensor_temperature_read_info[0] + &pw_sensor_temperature_read_info[0] #else NULL #endif @@ -611,11 +611,11 @@ static snmp_info_t pw_mib[] = { { "ambient.%i.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.1", "", SU_AMBIENT_TEMPLATE, NULL }, { "ambient.%i.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.2", "", SU_AMBIENT_TEMPLATE, NULL }, /* digitalInputPolarity.n */ - { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_polarity_info[0] }, - { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_polarity_info[0] }, /* XUPS-MIB::xupsContactState.n */ - { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_state_info[0] }, - { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE, &pw_ambient_drycontacts_state_info[0] }, /* instant commands */ { "test.battery.start.quick", 0, 1, PW_OID_BATTEST_START, "", From 41415a8758dc436525da88959208a794e34b3aef Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 19 Sep 2019 09:18:32 +0200 Subject: [PATCH 40/75] SNMP Eaton ePDU: always return celsius for temperature since the value reading is always adapted to celsius Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-helpers.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index dd2baa50a6..468eefcaf3 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -56,25 +56,29 @@ long marlin_device_count_fun(const char *daisy_dev_list) return count; } -/* Temperature unit consideration */ +/* Temperature unit consideration: + * only store the device unit, for converting to Celsius. + * Don't publish the device unit, since NUT will publish + * as Celsius in all cases */ const char *eaton_sensor_temperature_unit_fun(long snmp_value) { switch (snmp_value) { case 0: /* store the value, for temperature processing */ temperature_unit = TEMPERATURE_KELVIN; - return "kelvin"; + break; case 1: /* store the value, for temperature processing */ temperature_unit = TEMPERATURE_CELSIUS; - return "celsius"; + break; case 2: /* store the value, for temperature processing */ temperature_unit = TEMPERATURE_FAHRENHEIT; - return "fahrenheit"; + break; default: /* store the value, for temperature processing */ temperature_unit = TEMPERATURE_UNKNOWN; - return "unknown"; + break; } + return "celsius"; } From 33a66d29c88347a411b235e7bf966f134a541a15 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 15:16:36 +0100 Subject: [PATCH 41/75] drivers/eaton-pdu-marlin-helpers.{c,h}: adjust eaton_sensor_temperature_unit_fun() API to that used in NUT master branch --- drivers/eaton-pdu-marlin-helpers.c | 3 ++- drivers/eaton-pdu-marlin-helpers.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 468eefcaf3..2ed3aae517 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -60,8 +60,9 @@ long marlin_device_count_fun(const char *daisy_dev_list) * only store the device unit, for converting to Celsius. * Don't publish the device unit, since NUT will publish * as Celsius in all cases */ -const char *eaton_sensor_temperature_unit_fun(long snmp_value) +const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) { + long snmp_value = *((long*)raw_snmp_value); switch (snmp_value) { case 0: /* store the value, for temperature processing */ diff --git a/drivers/eaton-pdu-marlin-helpers.h b/drivers/eaton-pdu-marlin-helpers.h index 070896e22f..fc9890e519 100644 --- a/drivers/eaton-pdu-marlin-helpers.h +++ b/drivers/eaton-pdu-marlin-helpers.h @@ -24,6 +24,6 @@ #define EATON_EPDU_MARLIN_HELPERS_H long marlin_device_count_fun(const char *daisy_dev_list); -const char *eaton_sensor_temperature_unit_fun(long snmp_value); +const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value); #endif /* EATON_EPDU_MARLIN_HELPERS_H */ From 3e25ddbcb29697ee224a7acd7eeb88f13c0e6fa0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 15:25:34 +0100 Subject: [PATCH 42/75] drivers/snmp-ups.{c,h}: adjust su_temperature_read_fun() API to that used in NUT master branch --- drivers/eaton-pdu-marlin-mib.c | 4 ++-- drivers/powerware-mib.c | 6 +++--- drivers/snmp-ups.c | 6 ++++-- drivers/snmp-ups.h | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 1709d17d21..03a8dadf12 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -213,10 +213,10 @@ static info_lkp_t marlin_outlet_group_phase_info[] = { #if WITH_SNMP_LKP_FUN_DUMMY /* Temperature unit consideration */ -const char *eaton_sensor_temperature_unit_fun(long snmp_value) +const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) { return "unknown"; } /* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ -const char *su_temperature_read_fun(long snmp_value) +const char *su_temperature_read_fun(void *raw_snmp_value) { return "dummy"; } #endif // WITH_SNMP_LKP_FUN_DUMMY diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 932238405b..cca31c925e 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -258,11 +258,11 @@ static info_lkp_t pw_ambient_drycontacts_info[] = { # if WITH_SNMP_LKP_FUN_DUMMY /* Temperature unit consideration */ -const char *eaton_sensor_temperature_unit_fun(long snmp_value) +const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) { return "unknown"; } /* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ -const char *su_temperature_read_fun(long snmp_value) - { return "dummy"; }; +const char *su_temperature_read_fun(void *raw_snmp_value) + { return "dummy"; } # endif /* WITH_SNMP_LKP_FUN_DUMMY */ static info_lkp_t pw_sensor_temperature_unit_info[] = { diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index fcec2c09da..8d8ca05230 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -4066,11 +4066,13 @@ void read_mibconf(char *mib) static char su_scratch_buf[20]; /* Process temperature value according to 'temperature_unit' */ -const char *su_temperature_read_fun(long snmp_value) +const char *su_temperature_read_fun(void *raw_snmp_value) { - memset(su_scratch_buf, 0, sizeof(su_scratch_buf)); + const long snmp_value = *((long*)raw_snmp_value); long celsius_value = snmp_value; + memset(su_scratch_buf, 0, sizeof(su_scratch_buf)); + switch (temperature_unit) { case TEMPERATURE_KELVIN: celsius_value = (snmp_value / 10) - 273.15; diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index c71b371f6a..0f8c06b75f 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -370,7 +370,7 @@ extern info_lkp_t su_convert_to_iso_date_info[]; #define FUNMAP_USDATE_TO_ISODATE 0 /* Process temperature value according to 'temperature_unit' */ -const char *su_temperature_read_fun(long snmp_value); +const char *su_temperature_read_fun(void *raw_snmp_value); /* Temperature handling, to convert back to Celsius (NUT standard) */ extern int temperature_unit; From 8ab3116687806084577515f6f031602d84fe0ab6 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 15:46:47 +0100 Subject: [PATCH 43/75] drivers/eaton-pdu-marlin-mib.c: update comments and implem for dummy eaton_sensor_temperature_unit_fun()/su_temperature_read_fun() from 42ity/nut --- drivers/eaton-pdu-marlin-mib.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 03a8dadf12..39de2d77c7 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -208,16 +208,23 @@ static info_lkp_t marlin_outlet_group_phase_info[] = { #if WITH_SNMP_LKP_FUN /* Note: eaton_sensor_temperature_unit_fun() is defined in eaton-pdu-marlin-helpers.c - * Future work for DMF might provide a same-named routine via LUA-C gateway. + * and su_temperature_read_fun() is in snmp-ups.c + * Future work for DMF might provide same-named routines via LUA-C gateway. */ #if WITH_SNMP_LKP_FUN_DUMMY /* Temperature unit consideration */ -const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) - { return "unknown"; } +const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) { + /* snmp_value here would be a (long*) */ + NUT_UNUSED_VARIABLE(raw_snmp_value); + return "unknown"; +} /* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ -const char *su_temperature_read_fun(void *raw_snmp_value) - { return "dummy"; } +const char *su_temperature_read_fun(void *raw_snmp_value) { + /* snmp_value here would be a (long*) */ + NUT_UNUSED_VARIABLE(raw_snmp_value); + return "dummy"; +} #endif // WITH_SNMP_LKP_FUN_DUMMY static info_lkp_t eaton_sensor_temperature_unit_info[] = { @@ -245,13 +252,13 @@ static info_lkp_t eaton_sensor_temperature_unit_info[] = { #endif // WITH_SNMP_LKP_FUN /* Extracted from powerware-mib.c ; try to commonalize */ -static info_lkp_t ambient_drycontacts_polarity_info[] = { +static info_lkp_t marlin_ambient_drycontacts_polarity_info[] = { { 0, "normal-opened", NULL, NULL }, { 1, "normal-closed", NULL, NULL }, { 0, NULL, NULL, NULL } }; -static info_lkp_t ambient_drycontacts_state_info[] = { +static info_lkp_t marlin_ambient_drycontacts_state_info[] = { { 0, "active", NULL, NULL }, { 1, "inactive", NULL, NULL }, { 0, NULL, NULL, NULL } @@ -855,11 +862,11 @@ static snmp_info_t eaton_marlin_mib[] = { { "ambient.%i.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, { "ambient.%i.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* digitalInputPolarity.n */ - { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_polarity_info[0] }, - { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_polarity_info[0] }, /* XUPS-MIB::xupsContactState.n */ - { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_state_info[0] }, - { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_state_info[0] }, /* Outlet collection */ { "outlet.count", 0, 1, From 0a29f942080749fdfc286b00a1786bcc4c36d04e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 15:50:38 +0100 Subject: [PATCH 44/75] drivers/powerware-mib.c: update comments and implem for dummy eaton_sensor_temperature_unit_fun()/su_temperature_read_fun() from 42ity/nut --- drivers/powerware-mib.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index cca31c925e..db03898262 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -252,17 +252,24 @@ static info_lkp_t pw_ambient_drycontacts_info[] = { }; #if WITH_SNMP_LKP_FUN -/* Note: eaton_sensor_temperature_unit_fun() is defined in powerware-helpers.c - * Future work for DMF might provide a same-named routine via LUA-C gateway. +/* Note: eaton_sensor_temperature_unit_fun() is defined in eaton-pdu-marlin-helpers.c + * and su_temperature_read_fun() is in snmp-ups.c + * Future work for DMF might provide same-named routines via LUA-C gateway. */ # if WITH_SNMP_LKP_FUN_DUMMY /* Temperature unit consideration */ -const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) - { return "unknown"; } +const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value) { + /* snmp_value here would be a (long*) */ + NUT_UNUSED_VARIABLE(raw_snmp_value); + return "unknown"; +} /* FIXME: please DMF, though this should be in snmp-ups.c or equiv. */ -const char *su_temperature_read_fun(void *raw_snmp_value) - { return "dummy"; } +const char *su_temperature_read_fun(void *raw_snmp_value) { + /* snmp_value here would be a (long*) */ + NUT_UNUSED_VARIABLE(raw_snmp_value); + return "dummy"; +}; # endif /* WITH_SNMP_LKP_FUN_DUMMY */ static info_lkp_t pw_sensor_temperature_unit_info[] = { From e280e84cb6ab7f27efaaf0dc2d7d02c8ab6932b0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 13 Oct 2021 03:34:23 +0200 Subject: [PATCH 45/75] drivers/eaton-pdu-marlin-mib.c: update for new fun_vp2s() type args From 968f5593f408f4ddb8dbb8da48e66966772cc2d2 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 19 Sep 2019 14:51:56 +0200 Subject: [PATCH 46/75] SNMP Eaton EMP002: handle sensor presence Sensor may not be present (or connected). However, the values (temperature, humidity, ...) are still available, but should not be considered Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 12 +++++++++++- drivers/powerware-mib.c | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 39de2d77c7..96abcbc427 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.63" +#define EATON_MARLIN_MIB_VERSION "0.64" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -112,6 +112,13 @@ static info_lkp_t marlin_ambient_presence_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t marlin_emp002_ambient_presence_info[] = { + { 0, "unknown", NULL, NULL }, + { 2, "yes", NULL, NULL }, /* communicationOK */ + { 3, "no", NULL, NULL }, /* communicationLost */ + { 0, NULL, NULL, NULL } +}; + static info_lkp_t marlin_threshold_status_info[] = { { 0, "good", NULL, NULL }, /* No threshold triggered */ { 1, "warning-low", NULL, NULL }, /* Warning low threshold triggered */ @@ -805,6 +812,9 @@ static snmp_info_t eaton_marlin_mib[] = { /* Warning: indexes start at '1' not '0'! */ /* sensorCount.0 */ { "ambient.count", ST_FLAG_RW, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.1.0", "0", SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* CommunicationStatus.n */ + { "ambient.%i.present", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.1.4.1.1.%i", + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_emp002_ambient_presence_info[0] }, /* sensorName.n: OctetString EMPDT1H1C2 @1 */ { "ambient.%i.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.3.1.1.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorManufacturer.n */ diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index db03898262..a2ad7ba0c1 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-marlin-helpers.h" #endif -#define PW_MIB_VERSION "0.98" +#define PW_MIB_VERSION "0.99" /* TODO: more sysOID and MIBs support: * @@ -308,6 +308,13 @@ static info_lkp_t pw_ambient_drycontacts_state_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t pw_emp002_ambient_presence_info[] = { + { 0, "unknown", NULL, NULL }, + { 2, "yes", NULL, NULL }, /* communicationOK */ + { 3, "no", NULL, NULL }, /* communicationLost */ + { 0, NULL, NULL, NULL } +}; + /* extracted from drivers/eaton-pdu-marlin-mib.c -> marlin_threshold_status_info */ static info_lkp_t pw_threshold_status_info[] = { { 0, "good", NULL, NULL }, /* No threshold triggered */ @@ -561,6 +568,9 @@ static snmp_info_t pw_mib[] = { /* Warning: indexes start at '1' not '0'! */ /* sensorCount.0 */ { "ambient.count", ST_FLAG_RW, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.1.0", "", 0, NULL }, + /* CommunicationStatus.n */ + { "ambient.%i.present", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.1.4.1.1.%i", + NULL, SU_AMBIENT_TEMPLATE, &pw_emp002_ambient_presence_info[0] }, /* sensorName.n: OctetString EMPDT1H1C2 @1 */ { "ambient.%i.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.3.1.1.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* sensorManufacturer.n */ From 4153cd1ef5cdc9a71708bb407c6d7f0dd717eb15 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 7 Nov 2019 16:54:32 +0100 Subject: [PATCH 47/75] SNMP Eaton Gb Network Card: various data completion * fix reading of input.voltage, related to the ending ".0", * fix existing commands handling, * add support for the load segment (managed outlets), including status information and commands Signed-off-by: Arnaud Quette --- drivers/powerware-mib.c | 62 ++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index a2ad7ba0c1..cab6fadf8a 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-marlin-helpers.h" #endif -#define PW_MIB_VERSION "0.99" +#define PW_MIB_VERSION "0.100" /* TODO: more sysOID and MIBs support: * @@ -77,8 +77,8 @@ #define PW_OID_BATTEST_START "1.3.6.1.4.1.534.1.8.1" /* XUPS-MIB::xupsTestBattery set to startTest(1) to initiate test*/ -#define PW_OID_CONT_OFFDELAY "1.3.6.1.4.1.534.1.9.1" /* XUPS-MIB::xupsControlOutputOffDelay */ -#define PW_OID_CONT_ONDELAY "1.3.6.1.4.1.534.1.9.2" /* XUPS-MIB::xupsControlOutputOnDelay */ +#define PW_OID_CONT_OFFDELAY "1.3.6.1.4.1.534.1.9.1.0" /* XUPS-MIB::xupsControlOutputOffDelay */ +#define PW_OID_CONT_ONDELAY "1.3.6.1.4.1.534.1.9.2.0" /* XUPS-MIB::xupsControlOutputOnDelay */ #define PW_OID_CONT_OFFT_DEL "1.3.6.1.4.1.534.1.9.3" /* XUPS-MIB::xupsControlOutputOffTrapDelay */ #define PW_OID_CONT_ONT_DEL "1.3.6.1.4.1.534.1.9.4" /* XUPS-MIB::xupsControlOutputOnTrapDelay */ #define PW_OID_CONT_LOAD_SHED_AND_RESTART "1.3.6.1.4.1.534.1.9.6" /* XUPS-MIB::xupsLoadShedSecsWithRestart */ @@ -242,6 +242,18 @@ static info_lkp_t pw_yes_no_info[] = { { 0, NULL, NULL, NULL } }; +static info_lkp_t pw_outlet_status_info[] = { + { 1, "on", NULL, NULL }, + { 2, "off", NULL, NULL }, + { 3, "on", NULL, NULL }, /* pendingOff, transitional status */ + { 4, "off", NULL, NULL }, /* pendingOn, transitional status */ + /* { 5, "", NULL, NULL }, unknown */ + /* { 6, "", NULL, NULL }, reserved */ + { 7, "off", NULL, NULL }, /* Failed in Closed position */ + { 8, "on", NULL, NULL }, /* Failed in Open position */ + { 0, NULL, NULL, NULL } +}; + static info_lkp_t pw_ambient_drycontacts_info[] = { { -1, "unknown", NULL, NULL }, { 1, "opened", NULL, NULL }, @@ -497,11 +509,10 @@ static snmp_info_t pw_mib[] = { { "input.voltage", 0, 1.0, PW_OID_IN_VOLTAGE ".0", "", SU_INPUT_1, NULL }, /* Duplicate of the above entry, but pointing at the first index */ - /* xupsInputVoltage.1.0; Value (Integer): 245 */ - { "input.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.3.4.1.2.1.0", "", + /* xupsInputVoltage.1[.0]; Value (Integer): 245 */ + { "input.voltage", 0, 1.0, "1.3.6.1.4.1.534.1.3.4.1.2.1", "", SU_INPUT_1, NULL }, - /* XUPS-MIB::xupsConfigInputVoltage.0 */ { "input.voltage.nominal", 0, 1.0, "1.3.6.1.4.1.534.1.10.2.0", "", 0, NULL }, { "input.current", 0, 0.1, PW_OID_IN_CURRENT ".0", "", @@ -543,6 +554,17 @@ static snmp_info_t pw_mib[] = { { "input.bypass.L3-N.voltage", 0, 1.0, PW_OID_BY_VOLTAGE ".3", "", SU_INPUT_3, NULL }, + /* Outlet page */ + /* XUPS-MIB::xupsNumReceptacles; Value (Integer): 2 */ + { "outlet.count", 0, 1, ".1.3.6.1.4.1.534.1.12.1.0", NULL, SU_FLAG_STATIC, NULL }, + /* XUPS-MIB::xupsRecepIndex.X; Value (Integer): X */ + { "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.1.%i", NULL, SU_FLAG_STATIC | SU_OUTLET, NULL }, + /* This MIB does not provide outlets switchability info. So map to a nearby + OID, for data activation, and map all values to "yes" */ + { "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.1.%i", NULL, SU_FLAG_STATIC | SU_OUTLET, NULL }, + /* XUPS-MIB::xupsRecepStatus.X; Value (Integer): 1 */ + { "outlet.%i.status", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.2.%i", NULL, SU_OUTLET, &pw_outlet_status_info[0] }, + /* Ambient collection */ /* EMP001 (legacy) mapping */ /* XUPS-MIB::xupsEnvRemoteTemp.0 */ @@ -643,17 +665,37 @@ static snmp_info_t pw_mib[] = { /* Cancel output off, by writing 0 to xupsControlOutputOffDelay */ { "shutdown.stop", 0, 0, PW_OID_CONT_OFFDELAY, "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, + /* XUPS-MIB::xupsControlOutputOffDelay */ /* load off after 1 sec, shortest possible delay; 0 cancels */ - { "load.off", 0, 1, PW_OID_CONT_OFFDELAY, "", + { "load.off", 0, 1, PW_OID_CONT_OFFDELAY, "1", SU_TYPE_CMD | SU_FLAG_OK, NULL }, - { "load.off.delay", 0, DEFAULT_OFFDELAY, PW_OID_CONT_OFFDELAY, "", + /* Delayed version, parameter is mandatory (so dfl is NULL)! */ + { "load.off.delay", 0, 1, PW_OID_CONT_OFFDELAY, NULL, SU_TYPE_CMD | SU_FLAG_OK, NULL }, + /* XUPS-MIB::xupsControlOutputOnDelay */ /* load on after 1 sec, shortest possible delay; 0 cancels */ - { "load.on", 0, 1, PW_OID_CONT_ONDELAY, "", + { "load.on", 0, 1, PW_OID_CONT_ONDELAY, "1", SU_TYPE_CMD | SU_FLAG_OK, NULL }, - { "load.on.delay", 0, DEFAULT_ONDELAY, PW_OID_CONT_ONDELAY, "", + /* Delayed version, parameter is mandatory (so dfl is NULL)! */ + { "load.on.delay", 0, 1, PW_OID_CONT_ONDELAY, NULL, SU_TYPE_CMD | SU_FLAG_OK, NULL }, + /* Delays handling: + * 0-n :Time in seconds until the command is issued + * -1:Cancel a pending Off/On command */ + /* XUPS-MIB::xupsRecepOffDelaySecs.n */ + { "outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.3.%i", + "0", SU_TYPE_CMD | SU_OUTLET, NULL }, + /* XUPS-MIB::xupsRecepOnDelaySecs.n */ + { "outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.4.%i", + "0", SU_TYPE_CMD | SU_OUTLET, NULL }, + /* Delayed version, parameter is mandatory (so dfl is NULL)! */ + { "outlet.%i.load.off.delay", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.3.%i", + NULL, SU_TYPE_CMD | SU_OUTLET, NULL }, + /* XUPS-MIB::xupsRecepOnDelaySecs.n */ + { "outlet.%i.load.on.delay", 0, 1, ".1.3.6.1.4.1.534.1.12.2.1.4.%i", + NULL, SU_TYPE_CMD | SU_OUTLET, NULL }, + { "ups.alarms", 0, 1.0, PW_OID_ALARMS, "", 0, NULL }, From 8930755f05e1723112c7d8b9d470b82b29a86dfb Mon Sep 17 00:00:00 2001 From: "Clappier, Eric" Date: Mon, 14 Dec 2020 15:39:56 +0100 Subject: [PATCH 48/75] Add modbus_address and uuid in snmp-ups/pw driver --- drivers/powerware-mib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index cab6fadf8a..2d85446afb 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -601,6 +601,10 @@ static snmp_info_t pw_mib[] = { { "ambient.%i.model", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.7.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* sensorSerialNumber.n */ { "ambient.%i.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorUuid.n */ + { "ambient.%i.uuid", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + /* sensorAddress.n */ + { "ambient.%i.modbus_address", 0, 1, ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* sensorFirmwareVersion.n */ { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* temperatureUnit.1 From e093c199c69e7b4d5aacd2d849d164eb4f35db98 Mon Sep 17 00:00:00 2001 From: "Clappier, Eric" Date: Tue, 15 Dec 2020 12:01:29 +0100 Subject: [PATCH 49/75] Change uid and modbus address name according nut nomenclature --- drivers/eaton-pdu-marlin-mib.c | 6 +++++- drivers/powerware-mib.c | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 96abcbc427..ebb4f3f037 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.64" +#define EATON_MARLIN_MIB_VERSION "0.65" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -823,6 +823,10 @@ static snmp_info_t eaton_marlin_mib[] = { { "ambient.%i.model", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.7.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorSerialNumber.n */ { "ambient.%i.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorUuid.n */ + { "ambient.%i.id", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorAddress.n */ + { "ambient.%i.address", 0, 1, ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorFirmwareVersion.n */ { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* temperatureUnit.1 diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 2d85446afb..f2541411a4 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-marlin-helpers.h" #endif -#define PW_MIB_VERSION "0.100" +#define PW_MIB_VERSION "0.101" /* TODO: more sysOID and MIBs support: * @@ -602,9 +602,9 @@ static snmp_info_t pw_mib[] = { /* sensorSerialNumber.n */ { "ambient.%i.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* sensorUuid.n */ - { "ambient.%i.uuid", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + { "ambient.%i.id", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* sensorAddress.n */ - { "ambient.%i.modbus_address", 0, 1, ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", "", SU_AMBIENT_TEMPLATE, NULL }, + { "ambient.%i.address", 0, 1, ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* sensorFirmwareVersion.n */ { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* temperatureUnit.1 From 111462040231bfd00946caed657e92c3a7650504 Mon Sep 17 00:00:00 2001 From: "Clappier, Eric" Date: Mon, 14 Dec 2020 15:39:06 +0100 Subject: [PATCH 50/75] Add modbus_address and uuid in eaton_epdu driver From e2b51e58496ea820084704e91dba9f792a7b2cf7 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Tue, 15 Dec 2020 14:49:40 +0100 Subject: [PATCH 51/75] snmp-ups: Restore legacy Eaton ePDU switchability info Use a hack to also have switchability for both the unit and its outlets on legacy Eaton G2 ePDU Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index ebb4f3f037..b6ae9ce061 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.65" +#define EATON_MARLIN_MIB_VERSION "0.66" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -902,7 +902,7 @@ static snmp_info_t eaton_marlin_mib[] = { /* Ugly hack for older G2 ePDU: check the first outlet to determine unit switchability */ { "outlet.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.1", - "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_TYPE_DAISY_1, + "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_OUTLET | SU_FLAG_OK | SU_TYPE_DAISY_1, &g2_unit_outlet_switchability_info[0] }, /* The below ones are the same as the input.* equivalent */ /* FIXME: transition period, TO BE REMOVED, moved to input.* */ From 7d0640f4da3b134c4b3426c76ea858247e59fcc1 Mon Sep 17 00:00:00 2001 From: "Clappier, Eric" Date: Wed, 16 Dec 2020 16:01:04 +0100 Subject: [PATCH 52/75] Add ambient.n.parent.serial for marlin epdu Regarding dropped code from snmp-ups.c - per discussion in https://github.com/42ity/nut/pull/117 this was not a typo: > It is an intentional change for oid read value issue. > This allows to actually retrieve an indirection value > (when an Oid points at an Oid, like stood) --- drivers/eaton-pdu-marlin-mib.c | 2 ++ drivers/snmp-ups.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index b6ae9ce061..36fdc7435c 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -827,6 +827,8 @@ static snmp_info_t eaton_marlin_mib[] = { { "ambient.%i.id", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorAddress.n */ { "ambient.%i.address", 0, 1, ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + /* sensorMonitoredBy.n */ + { "ambient.%i.parent.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.5.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorFirmwareVersion.n */ { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* temperatureUnit.1 diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 8d8ca05230..cabb46c685 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -1271,8 +1271,6 @@ static bool_t decode_str(struct snmp_pdu *pdu, char *buf, size_t buf_len, info_l snprintf(buf, buf_len, "%s", oid_leaf+1); upsdebugx(3, "Fallback value: %s", buf); } - else - snprintf(buf, buf_len, "%s", tmp_buf); break; default: return FALSE; From 6f647c278f9f34f310a1a93ef8833a0c83551c69 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Tue, 26 Jan 2021 12:07:02 +0100 Subject: [PATCH 53/75] snmp-ups: fix regression on Eaton ePDU Fix a regression that caused a mis-determination of the SNMP base OID index (0 or 1, should be 1). This in turn caused a mis-iteration over the outlets, from 0 to N-1 instead of 1 to N, which resulted in the missing Nth outlet (last outlet of the PDU). This also caused some data refresh issues Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 36fdc7435c..d9aaadf042 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.66" +#define EATON_MARLIN_MIB_VERSION "0.67" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -904,7 +904,7 @@ static snmp_info_t eaton_marlin_mib[] = { /* Ugly hack for older G2 ePDU: check the first outlet to determine unit switchability */ { "outlet.switchable", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.3.%i.1", - "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_OUTLET | SU_FLAG_OK | SU_TYPE_DAISY_1, + "no", SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_TYPE_DAISY_1, &g2_unit_outlet_switchability_info[0] }, /* The below ones are the same as the input.* equivalent */ /* FIXME: transition period, TO BE REMOVED, moved to input.* */ From 95da25b9a661dfdd91fa0f2087bf1d8174975519 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 16:03:46 +0100 Subject: [PATCH 54/75] Move su_temperature_read_fun() from drivers/snmp-ups.c to snmp-ups-helpers.c --- drivers/snmp-ups-helpers.c | 32 +++++++++++++++++++++++++++++++ drivers/snmp-ups.c | 39 -------------------------------------- 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/drivers/snmp-ups-helpers.c b/drivers/snmp-ups-helpers.c index ce3f2abcff..b4116ff6f8 100644 --- a/drivers/snmp-ups-helpers.c +++ b/drivers/snmp-ups-helpers.c @@ -45,6 +45,9 @@ static char su_scratch_buf[255]; +/* Temperature handling, to convert back to Celsius */ +int temperature_unit = TEMPERATURE_UNKNOWN; + /* Convert a US formated date (mm/dd/yyyy) to an ISO 8601 Calendar date (yyyy-mm-dd) */ const char *su_usdate_to_isodate_info_fun(void *raw_date) { @@ -72,3 +75,32 @@ info_lkp_t su_convert_to_iso_date_info[] = { { 1, "dummy", su_usdate_to_isodate_info_fun, NULL }, { 0, NULL, NULL, NULL } }; + +/* Process temperature value according to 'temperature_unit' */ +const char *su_temperature_read_fun(void *raw_snmp_value) +{ + const long snmp_value = *((long*)raw_snmp_value); + long celsius_value = snmp_value; + + memset(su_scratch_buf, 0, sizeof(su_scratch_buf)); + + switch (temperature_unit) { + case TEMPERATURE_KELVIN: + celsius_value = (snmp_value / 10) - 273.15; + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); + break; + case TEMPERATURE_CELSIUS: + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", (snmp_value / 10)); + break; + case TEMPERATURE_FAHRENHEIT: + celsius_value = (((snmp_value / 10) - 32) * 5) / 9; + snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); + break; + case TEMPERATURE_UNKNOWN: + default: + upsdebugx(1, "%s: not a known temperature unit for conversion!", __func__); + break; + } + upsdebugx(2, "%s: %.1ld => %s", __func__, (snmp_value / 10), su_scratch_buf); + return su_scratch_buf; +} diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index cabb46c685..6016b73eec 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -196,9 +196,6 @@ static int outletgroup_template_index_base = -1; static int ambient_template_index_base = -1; static int device_template_offset = -1; -/* Temperature handling, to convert back to Celsius */ -int temperature_unit = TEMPERATURE_UNKNOWN; - /* sysOID location */ #define SYSOID_OID ".1.3.6.1.2.1.1.2.0" @@ -4056,39 +4053,3 @@ void read_mibconf(char *mib) } pconf_finish(&ctx); } - -/*********************************************************************** - * Subdrivers shared helpers functions - **********************************************************************/ - -static char su_scratch_buf[20]; - -/* Process temperature value according to 'temperature_unit' */ -const char *su_temperature_read_fun(void *raw_snmp_value) -{ - const long snmp_value = *((long*)raw_snmp_value); - long celsius_value = snmp_value; - - memset(su_scratch_buf, 0, sizeof(su_scratch_buf)); - - switch (temperature_unit) { - case TEMPERATURE_KELVIN: - celsius_value = (snmp_value / 10) - 273.15; - snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); - break; - case TEMPERATURE_CELSIUS: - snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", (snmp_value / 10)); - break; - case TEMPERATURE_FAHRENHEIT: - celsius_value = (((snmp_value / 10) - 32) * 5) / 9; - snprintf(su_scratch_buf, sizeof(su_scratch_buf), "%.1ld", celsius_value); - break; - case TEMPERATURE_UNKNOWN: - default: - upsdebugx(1, "%s: not a known temperature unit for conversion!", __func__); - break; - } - upsdebugx(2, "%s: %.1ld => %s", __func__, (snmp_value / 10), su_scratch_buf); - return su_scratch_buf; -} - From eb7d25094a7c5dda3d78907ee357951ef377be8d Mon Sep 17 00:00:00 2001 From: "Clappier, Eric" Date: Mon, 1 Feb 2021 08:49:45 +0100 Subject: [PATCH 55/75] Fix dry contacts status for EMP02 --- drivers/eaton-pdu-marlin-mib.c | 6 +++--- drivers/powerware-mib.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index d9aaadf042..9ee3f934e5 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.67" +#define EATON_MARLIN_MIB_VERSION "0.68" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -266,8 +266,8 @@ static info_lkp_t marlin_ambient_drycontacts_polarity_info[] = { }; static info_lkp_t marlin_ambient_drycontacts_state_info[] = { - { 0, "active", NULL, NULL }, - { 1, "inactive", NULL, NULL }, + { 0, "inactive", NULL, NULL }, + { 1, "active", NULL, NULL }, { 0, NULL, NULL, NULL } }; diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index f2541411a4..019f70c057 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-marlin-helpers.h" #endif -#define PW_MIB_VERSION "0.101" +#define PW_MIB_VERSION "0.102" /* TODO: more sysOID and MIBs support: * @@ -315,8 +315,8 @@ static info_lkp_t pw_ambient_drycontacts_polarity_info[] = { }; static info_lkp_t pw_ambient_drycontacts_state_info[] = { - { 0, "active", NULL, NULL }, - { 1, "inactive", NULL, NULL }, + { 0, "inactive", NULL, NULL }, + { 1, "active", NULL, NULL }, { 0, NULL, NULL, NULL } }; From 50dcc410cdeb243a0b4171ea85854b76c19b9197 Mon Sep 17 00:00:00 2001 From: "Clappier, Eric" Date: Mon, 14 Jun 2021 16:43:56 +0200 Subject: [PATCH 56/75] Add missing outlet objects for master --- drivers/powerware-mib.c | 4 ++++ drivers/snmp-ups.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 019f70c057..18d147b4dc 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -555,6 +555,10 @@ static snmp_info_t pw_mib[] = { SU_INPUT_3, NULL }, /* Outlet page */ + /* Master outlet id always equal to 0 */ + { "outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC , NULL }, + /* XUPS-MIB:: xupsSwitchable.0 */ + { "outlet.switchable", 0, 1, ".1.3.6.1.4.1.534.1.9.7.0", NULL, SU_FLAG_STATIC , &pw_yes_no_info[0] }, /* XUPS-MIB::xupsNumReceptacles; Value (Integer): 2 */ { "outlet.count", 0, 1, ".1.3.6.1.4.1.534.1.12.1.0", NULL, SU_FLAG_STATIC, NULL }, /* XUPS-MIB::xupsRecepIndex.X; Value (Integer): X */ diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 6016b73eec..4911aad357 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -3281,7 +3281,9 @@ bool_t su_ups_get(snmp_info_t *su_info_p) upsdebugx(2, "%s: %s %s", __func__, su_info_p->info_type, su_info_p->OID); /* Check if this is a daisychain template */ - if ((format_char = strchr(su_info_p->OID, '%')) != NULL) { + if (su_info_p->OID != NULL + && (format_char = strchr(su_info_p->OID, '%')) != NULL + ) { upsdebugx(3, "%s: calling instantiate_info() for " "daisy-chain template", __func__); tmp_info_p = instantiate_info(su_info_p, tmp_info_p); @@ -3501,7 +3503,12 @@ bool_t su_ups_get(snmp_info_t *su_info_p) return TRUE; } - if (su_info_p->info_flags & ST_FLAG_STRING) { + /* special treatment for element without oid but with default value */ + if (su_info_p->OID == NULL && su_info_p->dfl != NULL) { + status = TRUE; + strncpy(buf, su_info_p->dfl, sizeof(buf)); + } + else if (su_info_p->info_flags & ST_FLAG_STRING) { upsdebugx(2, "%s: requesting nut_snmp_get_str(), " "with%s daisy template originally", __func__, (format_char!=NULL ? "" : "out")); From 6e83f1f052f9283d6b8ff81f90c458eeeecb225e Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Mon, 15 Nov 2021 17:19:33 +0100 Subject: [PATCH 57/75] Fix regression on Eaton EMP002 temperature reading (SNMP) Following the recent addition of the "String reformating function" (su_find_strval()), a regression appeared on a corner case: when flagging a data with ST_FLAG_STRING, while the SNMP OID is an int, and when there is a fun_vp2s() conversion function, a double conversion is applied, resulting in no value published. This was limited to one data (temperature.unit) Signed-off-by: Arnaud Quette --- drivers/eaton-pdu-marlin-mib.c | 4 ++-- drivers/powerware-mib.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 9ee3f934e5..ca0e007dc1 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -36,7 +36,7 @@ /* Eaton PDU-MIB - Marlin MIB * ************************** */ -#define EATON_MARLIN_MIB_VERSION "0.68" +#define EATON_MARLIN_MIB_VERSION "0.69" #define EATON_MARLIN_SYSOID ".1.3.6.1.4.1.534.6.6.7" #define EATON_MARLIN_OID_MODEL_NAME ".1.3.6.1.4.1.534.6.6.7.1.2.1.2.0" @@ -833,7 +833,7 @@ static snmp_info_t eaton_marlin_mib[] = { { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* temperatureUnit.1 * MUST be before the temperature data reading! */ - { "ambient.%i.temperature.unit", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &eaton_sensor_temperature_unit_info[0] }, + { "ambient.%i.temperature.unit", 0, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &eaton_sensor_temperature_unit_info[0] }, /* temperatureValue.n.1 */ { "ambient.%i.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, #if WITH_SNMP_LKP_FUN diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 18d147b4dc..5dcc2444d5 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-marlin-helpers.h" #endif -#define PW_MIB_VERSION "0.102" +#define PW_MIB_VERSION "0.103" /* TODO: more sysOID and MIBs support: * @@ -613,7 +613,7 @@ static snmp_info_t pw_mib[] = { { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE, NULL }, /* temperatureUnit.1 * MUST be before the temperature data reading! */ - { "ambient.%i.temperature.unit", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE, &pw_sensor_temperature_unit_info[0] }, + { "ambient.%i.temperature.unit", 0, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE, &pw_sensor_temperature_unit_info[0] }, /* temperatureValue.n.1 */ { "ambient.%i.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE, #if WITH_SNMP_LKP_FUN From 79dd9579165676cdccf7d336b4b47f86d6a9c3d0 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Mon, 22 Nov 2021 14:30:01 +0100 Subject: [PATCH 58/75] Eaton XML/PDC: add External Battery Module count Signed-off-by: Arnaud Quette --- drivers/mge-xml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mge-xml.c b/drivers/mge-xml.c index af9c60b2d5..73aa43f0e3 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -35,7 +35,7 @@ #include "mge-xml.h" #include "main.h" /* for testvar() */ -#define MGE_XML_VERSION "MGEXML/0.34" +#define MGE_XML_VERSION "MGEXML/0.35" #define MGE_XML_INITUPS "/" #define MGE_XML_INITINFO "/mgeups/product.xml /product.xml /ws/product.xml" From 9a8c11bb42479945225c9433706166b9546ace33 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Wed, 12 Jan 2022 15:12:38 +0100 Subject: [PATCH 59/75] Eaton NMC: fix the non publication of real/power with 3ph power and realpower for 3ph Lx were not publishing values when they were 0 Signed-off-by: Arnaud Quette --- drivers/mge-xml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mge-xml.c b/drivers/mge-xml.c index 73aa43f0e3..fc2f8d4b3b 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -35,7 +35,7 @@ #include "mge-xml.h" #include "main.h" /* for testvar() */ -#define MGE_XML_VERSION "MGEXML/0.35" +#define MGE_XML_VERSION "MGEXML/0.36" #define MGE_XML_INITUPS "/" #define MGE_XML_INITINFO "/mgeups/product.xml /product.xml /ws/product.xml" From 015619e316c9351eb889358686123d9a89ef1a5c Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Thu, 25 Nov 2021 08:45:46 +0100 Subject: [PATCH 60/75] Eaton SNMP: also publish ups.load for 3phase Though there is output.Lx.power.percent, for 3phase, it's desirable to also have the standard ups.load Signed-off-by: Arnaud Quette --- drivers/powerware-mib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/powerware-mib.c b/drivers/powerware-mib.c index 5dcc2444d5..e4b0296010 100644 --- a/drivers/powerware-mib.c +++ b/drivers/powerware-mib.c @@ -29,7 +29,7 @@ #include "eaton-pdu-marlin-helpers.h" #endif -#define PW_MIB_VERSION "0.103" +#define PW_MIB_VERSION "0.104" /* TODO: more sysOID and MIBs support: * @@ -380,7 +380,7 @@ static snmp_info_t pw_mib[] = { { "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_IDENT, "", SU_FLAG_STATIC, NULL }, { "ups.load", 0, 1.0, PW_OID_OUT_LOAD, "", - SU_OUTPUT_1, NULL }, + 0, NULL }, /* FIXME: should be removed in favor of output.power */ { "ups.power", 0, 1.0, PW_OID_OUT_POWER ".1", "", 0, NULL }, From f799e083c3bd9aed989455064e14346d7b02fdf3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Nov 2021 11:19:23 +0100 Subject: [PATCH 61/75] drivers/eaton-pdu-marlin-helpers.c: include config.h first --- drivers/eaton-pdu-marlin-helpers.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index 2ed3aae517..a386e11095 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -28,6 +28,8 @@ * */ +#include "config.h" /* must be the first header */ + #include #include #include From a27079588f75e007be92fc1f51be5240772f8c6a Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Thu, 11 Nov 2021 11:03:48 +0100 Subject: [PATCH 62/75] drivers/snmp-ups.c: avoid stringop-truncation warning --- drivers/snmp-ups.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 4911aad357..5235b0f099 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -3506,7 +3506,7 @@ bool_t su_ups_get(snmp_info_t *su_info_p) /* special treatment for element without oid but with default value */ if (su_info_p->OID == NULL && su_info_p->dfl != NULL) { status = TRUE; - strncpy(buf, su_info_p->dfl, sizeof(buf)); + strncpy(buf, su_info_p->dfl, sizeof(buf) - 1); } else if (su_info_p->info_flags & ST_FLAG_STRING) { upsdebugx(2, "%s: requesting nut_snmp_get_str(), " From c2f50f01c520419c2d4443a1f3a67704cd80c05d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 16:52:40 +0100 Subject: [PATCH 63/75] drivers/snmp-ups.c: avoid stringop-truncation warning: make sure string is finite --- drivers/snmp-ups.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 5235b0f099..ecc85b7047 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -3506,7 +3506,9 @@ bool_t su_ups_get(snmp_info_t *su_info_p) /* special treatment for element without oid but with default value */ if (su_info_p->OID == NULL && su_info_p->dfl != NULL) { status = TRUE; + /* FIXME: strlcpy() would fit here safer; not used in NUT yet */ strncpy(buf, su_info_p->dfl, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; } else if (su_info_p->info_flags & ST_FLAG_STRING) { upsdebugx(2, "%s: requesting nut_snmp_get_str(), " From 8df3a971a00533f1bd672e7d7da10d6647a61aae Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 25 Feb 2022 21:06:14 +0100 Subject: [PATCH 64/75] drivers/eaton-pdu-marlin-mib.c: break long lines --- drivers/eaton-pdu-marlin-mib.c | 137 ++++++++++++++++++++++++--------- 1 file changed, 101 insertions(+), 36 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index ca0e007dc1..59732ccdba 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -455,7 +455,7 @@ static snmp_info_t eaton_marlin_mib[] = { * Voltage has to be expressed either phase-phase or phase-neutral * This is depending on OID inputVoltageMeasType * INTEGER {singlePhase (1),phase1toN (2),phase2toN (3),phase3toN (4),phase1to2 (5),phase2to3 (6),phase3to1 (7) - * => RFC input.Lx.voltage.context */ + * => RFC input.Lx.voltage.context */ { "input.voltage", 0, 0.001, ".1.3.6.1.4.1.534.6.6.7.3.2.1.3.%i.1.1", NULL, 0, NULL }, @@ -708,7 +708,7 @@ static snmp_info_t eaton_marlin_mib[] = { /* FIXME: SU_FLAG_SEMI_STATIC or SU_FLAG_SETTING => refreshed from time to time or upon call to setvar */ /* { "input.%i.feed.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, * ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.%i", - * NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, + * NULL, SU_FLAG_SEMI_STATIC | SU_FLAG_OK | SU_TYPE_DAISY_1, NULL }, */ { "input.feed.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.3.1.1.10.%i.1", @@ -811,31 +811,56 @@ static snmp_info_t eaton_marlin_mib[] = { /* EMP002 (EATON EMP MIB) mapping, including daisychain support */ /* Warning: indexes start at '1' not '0'! */ /* sensorCount.0 */ - { "ambient.count", ST_FLAG_RW, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.1.0", "0", SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.count", ST_FLAG_RW, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.1.0", + "0", SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* CommunicationStatus.n */ - { "ambient.%i.present", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.1.4.1.1.%i", - NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_emp002_ambient_presence_info[0] }, + { "ambient.%i.present", ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.1.4.1.1.%i", + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_emp002_ambient_presence_info[0] }, /* sensorName.n: OctetString EMPDT1H1C2 @1 */ - { "ambient.%i.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.3.1.1.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.name", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.3.1.1.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorManufacturer.n */ - { "ambient.%i.mfr", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.6.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.mfr", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.2.1.6.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorModel.n */ - { "ambient.%i.model", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.7.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.model", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.2.1.7.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorSerialNumber.n */ - { "ambient.%i.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.serial", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.2.1.9.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorUuid.n */ - { "ambient.%i.id", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.id", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.2.1.2.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorAddress.n */ - { "ambient.%i.address", 0, 1, ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.address", 0, 1, + ".1.3.6.1.4.1.534.6.8.1.1.2.1.4.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorMonitoredBy.n */ - { "ambient.%i.parent.serial", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.5.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.parent.serial", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.2.1.5.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* sensorFirmwareVersion.n */ - { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.firmware", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.1.2.1.10.%i", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* temperatureUnit.1 * MUST be before the temperature data reading! */ - { "ambient.%i.temperature.unit", 0, 1.0, ".1.3.6.1.4.1.534.6.8.1.2.5.0", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &eaton_sensor_temperature_unit_info[0] }, + { "ambient.%i.temperature.unit", 0, 1.0, + ".1.3.6.1.4.1.534.6.8.1.2.5.0", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &eaton_sensor_temperature_unit_info[0] }, /* temperatureValue.n.1 */ - { "ambient.%i.temperature", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + { "ambient.%i.temperature", 0, 0.1, + ".1.3.6.1.4.1.534.6.8.1.2.3.1.3.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, #if WITH_SNMP_LKP_FUN &eaton_sensor_temperature_read_info[0] #else @@ -844,45 +869,83 @@ static snmp_info_t eaton_marlin_mib[] = { }, { "ambient.%i.temperature.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", - NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_status_info[0] }, + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_threshold_status_info[0] }, { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.2.3.1.1.%i.1", - NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_temperature_alarms_info[0] }, + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_threshold_temperature_alarms_info[0] }, /* FIXME: ambient.n.temperature.{minimum,maximum} */ /* temperatureThresholdLowCritical.n.1 */ - { "ambient.%i.temperature.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.temperature.low.critical", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.2.2.1.6.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* temperatureThresholdLowWarning.n.1 */ - { "ambient.%i.temperature.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.temperature.low.warning", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.2.2.1.5.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* temperatureThresholdHighWarning.n.1 */ - { "ambient.%i.temperature.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.temperature.high.warning", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.2.2.1.7.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* temperatureThresholdHighCritical.n.1 */ - { "ambient.%i.temperature.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.2.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.temperature.high.critical", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.2.2.1.8.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* humidityValue.n.1 */ - { "ambient.%i.humidity", 0, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.humidity", 0, 0.1, + ".1.3.6.1.4.1.534.6.8.1.3.3.1.3.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, { "ambient.%i.humidity.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", - NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_status_info[0] }, + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_threshold_status_info[0] }, { "ups.alarm", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.3.3.1.1.%i.1", - NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_threshold_humidity_alarms_info[0] }, + NULL, SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_threshold_humidity_alarms_info[0] }, /* FIXME: consider ambient.n.humidity.{minimum,maximum} */ /* humidityThresholdLowCritical.n.1 */ - { "ambient.%i.humidity.low.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.6.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.humidity.low.critical", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.3.2.1.6.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* humidityThresholdLowWarning.n.1 */ - { "ambient.%i.humidity.low.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.5.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.humidity.low.warning", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.3.2.1.5.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* humidityThresholdHighWarning.n.1 */ - { "ambient.%i.humidity.high.warning", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.7.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.humidity.high.warning", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.3.2.1.7.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* humidityThresholdHighCritical.n.1 */ - { "ambient.%i.humidity.high.critical", ST_FLAG_RW, 0.1, ".1.3.6.1.4.1.534.6.8.1.3.2.1.8.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.humidity.high.critical", ST_FLAG_RW, 0.1, + ".1.3.6.1.4.1.534.6.8.1.3.2.1.8.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* digitalInputName.n.{1,2} */ - { "ambient.%i.contacts.1.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, - { "ambient.%i.contacts.2.name", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.contacts.1.name", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, + { "ambient.%i.contacts.2.name", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.4.2.1.1.%i.2", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, NULL }, /* digitalInputPolarity.n */ - { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_polarity_info[0] }, - { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.1.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_ambient_drycontacts_polarity_info[0] }, + { "ambient.%i.contacts.2.config", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, + ".1.3.6.1.4.1.534.6.8.1.4.2.1.3.%i.2", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_ambient_drycontacts_polarity_info[0] }, /* XUPS-MIB::xupsContactState.n */ - { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_state_info[0] }, - { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, &marlin_ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.1.status", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.1", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_ambient_drycontacts_state_info[0] }, + { "ambient.%i.contacts.2.status", ST_FLAG_STRING, 1.0, + ".1.3.6.1.4.1.534.6.8.1.4.3.1.3.%i.2", + "", SU_AMBIENT_TEMPLATE | SU_TYPE_DAISY_MASTER_ONLY, + &marlin_ambient_drycontacts_state_info[0] }, /* Outlet collection */ { "outlet.count", 0, 1, @@ -1187,14 +1250,16 @@ static snmp_info_t eaton_marlin_mib[] = { /* groupVA.0.1 = Integer: 3132 */ { "outlet.group.%i.power", 0, 1.0, ".1.3.6.1.4.1.534.6.6.7.5.5.1.2.%i.%i", - NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL }, /* Input to which an outlet-group is connected * groupInputIndex.0.1 = Integer: 1 */ /* FIXME: RFC on key name is needed when backporting to NUT upstream */ { "outlet.group.%i.input", 0, 1, ".1.3.6.1.4.1.534.6.6.7.5.1.1.9.%i.%i", - NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, + NULL, SU_FLAG_NEGINVALID | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL }, /* instant commands. */ /* Notes: From b49634383be855ad396ff8c98f87ddc0c78d27fd Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 18:44:30 +0100 Subject: [PATCH 65/75] drivers/eaton-pdu-marlin-mib.c: resync comments and use of SU_FLAG_SEMI_STATIC --- drivers/eaton-pdu-marlin-mib.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/eaton-pdu-marlin-mib.c b/drivers/eaton-pdu-marlin-mib.c index 59732ccdba..bed4bbef53 100644 --- a/drivers/eaton-pdu-marlin-mib.c +++ b/drivers/eaton-pdu-marlin-mib.c @@ -990,10 +990,14 @@ static snmp_info_t eaton_marlin_mib[] = { /* outlet template definition * Indexes start from 1, ie outlet.1 => .1 */ /* Note: the first definition is used to determine the base index (ie 0 or 1) */ - /* outletName: Outlet friendly name, which can be modified by the user */ + /* Outlet friendly name, which can be modified by the user + * outletName: = OctetString: "Outlet A16" + */ + /* FIXME: SU_FLAG_SEMI_STATIC or SU_FLAG_SETTING => + * refreshed from time to time or upon call to setvar */ { "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.3.%i.%i", - NULL, SU_FLAG_STATIC | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, + NULL, SU_FLAG_SEMI_STATIC | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, { "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.6.1.2.%i.%i", @@ -1015,7 +1019,7 @@ static snmp_info_t eaton_marlin_mib[] = { NULL, SU_FLAG_STATIC | SU_OUTLET | SU_TYPE_DAISY_1, NULL }, - /* Fallback in firmwares issued before Sep 2017: */ + /* Fallback in firmwares issued before Sep 2017 (outletID): */ { "outlet.%i.name", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.6.1.1.2.%i.%i", NULL, SU_FLAG_STATIC | SU_FLAG_UNIQUE | SU_FLAG_OK | SU_OUTLET | SU_TYPE_DAISY_1, @@ -1134,12 +1138,15 @@ static snmp_info_t eaton_marlin_mib[] = { { "outlet.group.%i.id", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.2.%i.%i", NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, - /* groupName.0.1 = OctetString: Factory Group 1 */ - /* FIXME: SU_FLAG_SEMI_STATIC or SU_FLAG_SETTING => refreshed from time to time or upon call to setvar */ - /* User-friendly (writeable) description of the outlet group: */ + /* User-friendly (writeable) description of the outlet group: + * groupName.0.1 = OctetString: Factory Group 1 + * groupName.0.2 = OctetString: Branch Circuit B + */ + /* FIXME: SU_FLAG_SEMI_STATIC or SU_FLAG_SETTING => + * refreshed from time to time or upon call to setvar */ { "outlet.group.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.534.6.6.7.5.1.1.3.%i.%i", - NULL, SU_FLAG_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, + NULL, SU_FLAG_SEMI_STATIC | SU_OUTLET_GROUP | SU_TYPE_DAISY_1, NULL }, /* Outlet-group physical name, a read-only string, * is named groupDesignator (other MIBs groupPhysicalName) From 3aefd12cde469449ad8490471ff2f2381a865580 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Wed, 25 Sep 2019 12:58:49 +0200 Subject: [PATCH 66/75] Fix false positive when communication is lost Signed-off-by: Arnaud Quette --- drivers/snmp-ups.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index ecc85b7047..da65fe79bc 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -166,7 +166,7 @@ static const char *mibname; static const char *mibvers; #define DRIVER_NAME "Generic SNMP UPS driver" -#define DRIVER_VERSION "1.20" +#define DRIVER_VERSION "1.21" /* driver description structure */ upsdrv_info_t upsdrv_info = { @@ -186,6 +186,12 @@ upsdrv_info_t upsdrv_info = { static time_t lastpoll = 0; +/* Communication status handling */ +#define COMM_UNKNOWN 0 +#define COMM_OK 1 +#define COMM_LOST 2 +static int comm_status = COMM_UNKNOWN; + /* template OIDs index start with 0 or 1 (estimated stable for a MIB), * automatically guessed at the first pass */ static int template_index_base = -1; @@ -267,9 +273,11 @@ su_addcmd(su_info_p); /* initialize all other INFO_ fields from list */ if (snmp_ups_walk(SU_WALKMODE_INIT) == TRUE) { dstate_dataok(); + comm_status = COMM_OK; } else { dstate_datastale(); + comm_status = COMM_LOST; } /* setup handlers for instcmd and setvar functions */ @@ -292,10 +300,12 @@ void upsdrv_updateinfo(void) if (snmp_ups_walk(SU_WALKMODE_UPDATE)) { upsdebugx(1, "%s: pollfreq: Data OK", __func__); dstate_dataok(); + comm_status = COMM_OK; } else { upsdebugx(1, "%s: pollfreq: Data STALE", __func__); dstate_datastale(); + comm_status = COMM_LOST; } /* Commit status first, otherwise in daisychain mode, "device.0" may @@ -311,8 +321,11 @@ void upsdrv_updateinfo(void) lastpoll = time(NULL); } else { - /* Just tell everything is ok to upsd */ - dstate_dataok(); + /* Just tell the same status to upsd */ + if (comm_status == COMM_OK) + dstate_dataok(); + else + dstate_datastale(); } } @@ -2298,7 +2311,7 @@ static int base_snmp_template_index(const snmp_info_t *su_info_p) /* we should never fall here! */ upsdebugx(3, "%s: unknown template type '%" PRI_SU_FLAGS "' for %s", __func__, template_type, su_info_p->info_type); - } + } base_index = template_index_base; if (template_index_base == -1) From 406250e2e117f272bedb302f23f3a292aa683596 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 13 Oct 2021 02:22:43 +0200 Subject: [PATCH 67/75] drivers/snmp-ups.c: su_find_strval() should consider #if WITH_SNMP_LKP_FUN --- drivers/snmp-ups.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index da65fe79bc..61687b095e 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -2097,6 +2097,7 @@ long su_find_valinfo(info_lkp_t *oid2info, const char* value) /* String reformating function */ const char *su_find_strval(info_lkp_t *oid2info, void *value) { +#if WITH_SNMP_LKP_FUN /* First test if we have a generic lookup function */ if ( (oid2info != NULL) && (oid2info->fun_vp2s != NULL) ) { upsdebugx(2, "%s: using generic lookup function (string reformatting)", __func__); @@ -2105,6 +2106,9 @@ const char *su_find_strval(info_lkp_t *oid2info, void *value) return retvalue; } upsdebugx(1, "%s: no result value for this OID string value (%s)", __func__, (char*)value); +#else + upsdebugx(1, "%s: no mapping function for this OID string value (%s)", __func__, (char*)value); +#endif // WITH_SNMP_LKP_FUN return NULL; } From 7a128cc063c45bdb931d654f3100314bedca52b4 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 11 Oct 2017 21:51:38 +0200 Subject: [PATCH 68/75] snmp-ups.c : publish device.count==1 too --- drivers/snmp-ups.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 61687b095e..7fc7010553 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -2841,10 +2841,9 @@ bool_t daisychain_init() daisychain_enabled = FALSE; upsdebugx(1, "Devices count is less than 1!"); upsdebugx(1, "Falling back to 1 device and disabling daisychain support!"); - } - - /* Publish the device(s) count */ - if (devices_count > 1) { + } else { + /* Publish the device(s) count - even if just one + * device was recognized at this moment */ dstate_setinfo("device.count", "%ld", devices_count); /* Also publish the default value for mfr and a forged model From 6af7233a3ae66050f7ee6d2148b8e7188c88eb7d Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 19:06:32 +0100 Subject: [PATCH 69/75] drivers/snmp-ups.c: whitespace fix --- drivers/snmp-ups.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 7fc7010553..48fa11de72 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -251,8 +251,8 @@ void upsdrv_initinfo(void) && !(su_info_p->flags & SU_OUTLET_GROUP)) { /* first check that this OID actually exists */ -/* FIXME: daisychain commands support! */ -su_addcmd(su_info_p); + /* FIXME: daisychain commands support! */ + su_addcmd(su_info_p); /* if (nut_snmp_get(su_info_p->OID) != NULL) { dstate_addcmd(su_info_p->info_type); @@ -2118,7 +2118,7 @@ const char *su_find_infoval(info_lkp_t *oid2info, void *raw_value) info_lkp_t *info_lkp; long value = *((long *)raw_value); -#ifdef WITH_SNMP_LKP_FUN +#if WITH_SNMP_LKP_FUN /* First test if we have a generic lookup function */ if ( (oid2info != NULL) && (oid2info->fun_vp2s != NULL) ) { upsdebugx(2, "%s: using generic lookup function", __func__); @@ -2315,7 +2315,7 @@ static int base_snmp_template_index(const snmp_info_t *su_info_p) /* we should never fall here! */ upsdebugx(3, "%s: unknown template type '%" PRI_SU_FLAGS "' for %s", __func__, template_type, su_info_p->info_type); - } + } base_index = template_index_base; if (template_index_base == -1) From 32612832c3d7ca2f735051caa028ac8c9d63f901 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 17 Nov 2021 11:21:26 +0100 Subject: [PATCH 70/75] drivers/snmp-ups.c: su_find_strval(): mark NUT_UNUSED_VARIABLE(oid2info) when not WITH_SNMP_LKP_FUN --- drivers/snmp-ups.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 48fa11de72..9b02be8f09 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -2107,6 +2107,7 @@ const char *su_find_strval(info_lkp_t *oid2info, void *value) } upsdebugx(1, "%s: no result value for this OID string value (%s)", __func__, (char*)value); #else + NUT_UNUSED_VARIABLE(oid2info); upsdebugx(1, "%s: no mapping function for this OID string value (%s)", __func__, (char*)value); #endif // WITH_SNMP_LKP_FUN return NULL; From 161fd3e0549d4b0aff699a0214c94ab7302d30b8 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 18:44:40 +0000 Subject: [PATCH 71/75] drivers/eaton-pdu-marlin-helpers.c: marlin_device_count_fun(): add debug trace --- drivers/eaton-pdu-marlin-helpers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/eaton-pdu-marlin-helpers.c b/drivers/eaton-pdu-marlin-helpers.c index a386e11095..421045f4c8 100644 --- a/drivers/eaton-pdu-marlin-helpers.c +++ b/drivers/eaton-pdu-marlin-helpers.c @@ -36,15 +36,16 @@ #include "eaton-pdu-marlin-helpers.h" #include "dstate.h" +#include "common.h" /* Allow access to temperature_unit */ #include "snmp-ups.h" - /* Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount * of "," separators+1 using an inline function */ long marlin_device_count_fun(const char *daisy_dev_list) { long count = 0, i; + for (i = 0; daisy_dev_list[i] != '\0'; i++) { if (daisy_dev_list[i] == ',') { /* Each comma means a new device in the list */ @@ -55,6 +56,9 @@ long marlin_device_count_fun(const char *daisy_dev_list) /* Non-empty string => at least one device, and no trailing commas */ count ++; } + + upsdebugx(3, "%s: counted devices in '%s', got %ld", + __func__, daisy_dev_list, count); return count; } From cb7f65a051be79025fe539794087b0a9c97a07ae Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 18:45:00 +0000 Subject: [PATCH 72/75] drivers/snmp-ups.c: daisychain_init(): add debug trace --- drivers/snmp-ups.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index 9b02be8f09..a314db66a4 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -2816,6 +2816,8 @@ bool_t daisychain_init() daisychain_enabled = TRUE; /* Try to get the OID value, if it's not a template */ + upsdebugx(3, "OID for device.count is %s", + su_info_p->OID ? su_info_p->OID : ""); if ((su_info_p->OID != NULL) && (strstr(su_info_p->OID, "%i") == NULL)) { From 2d97ab0ef29a60f46080eb80469cdff440006f03 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 27 Feb 2022 19:58:48 +0100 Subject: [PATCH 73/75] drivers/snmp-ups.c: extend daisychain initialization to use optional mapping function Note: ported sub-set of "snmp-ups.[ch] : add support for extended fun/nuf l2s/s2l conversions and use it for daisychain initialization" without the actual 2x2 "fun/nuf l2s/s2l" support here. --- drivers/snmp-ups.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/snmp-ups.c b/drivers/snmp-ups.c index a314db66a4..9cbcf9c9af 100644 --- a/drivers/snmp-ups.c +++ b/drivers/snmp-ups.c @@ -2821,14 +2821,38 @@ bool_t daisychain_init() if ((su_info_p->OID != NULL) && (strstr(su_info_p->OID, "%i") == NULL)) { - if (nut_snmp_get_int(su_info_p->OID, &devices_count) == TRUE) - upsdebugx(1, "There are %ld device(s) present", devices_count); - else - { - upsdebugx(1, "Error: can't get the number of device(s) present!"); - upsdebugx(1, "Falling back to 1 device!"); - devices_count = 1; +#if WITH_SNMP_LKP_FUN + devices_count = -1; + /* First test if we have a generic lookup function + * FIXME: Check if the field type is a string? + */ + /* TODO: backport the 2x2 mapping function support + * and this would be "fun_s2l" in resulting codebase + */ + if ( (su_info_p->oid2info != NULL) && (su_info_p->oid2info->nuf_s2l != NULL) ) { + char buf[1024]; + upsdebugx(2, "%s: using generic string-to-long lookup function", __func__); + if (TRUE == nut_snmp_get_str(su_info_p->OID, buf, sizeof(buf), su_info_p->oid2info)) { + devices_count = su_info_p->oid2info->nuf_s2l(buf); + upsdebugx(2, "%s: got value '%ld'", __func__, devices_count); + } + } + + if (devices_count == -1) { +#endif /* WITH_SNMP_LKP_FUN */ + + if (nut_snmp_get_int(su_info_p->OID, &devices_count) == TRUE) + upsdebugx(1, "There are %ld device(s) present", devices_count); + else + { + upsdebugx(1, "Error: can't get the number of device(s) present!"); + upsdebugx(1, "Falling back to 1 device!"); + devices_count = 1; + } + +#if WITH_SNMP_LKP_FUN } +#endif /* WITH_SNMP_LKP_FUN */ } /* Otherwise (template), use the guesstimation function to get * the number of devices present */ From 5bcf73fc2eee7ec34bc352c548f45aa65823031e Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 2 Mar 2022 22:11:34 +0000 Subject: [PATCH 74/75] drivers/mge-xml.c: mge_drycontact_info(): avoid shadowing global variable --- drivers/mge-xml.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mge-xml.c b/drivers/mge-xml.c index fc2f8d4b3b..4177b693d6 100644 --- a/drivers/mge-xml.c +++ b/drivers/mge-xml.c @@ -577,7 +577,7 @@ static const char *mge_ambient_info(const char *arg_val) } } -static const char *mge_drycontact_info(const char *val) +static const char *mge_drycontact_info(const char *arg_val) { /* these values should theoretically be obtained through * Environment.Input[1].State[x].Description @@ -585,7 +585,7 @@ static const char *mge_drycontact_info(const char *val) * open * closed */ - switch (atoi(val)) + switch (atoi(arg_val)) { case 0: return "opened"; From d710fd814ed056ab3e682568edb61368c6aa42a3 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Wed, 2 Mar 2022 23:32:08 +0000 Subject: [PATCH 75/75] drivers/snmp-ups.h: make sure WITH_SNMP_LKP_FUN_DUMMY is defined --- drivers/snmp-ups.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/snmp-ups.h b/drivers/snmp-ups.h index 0f8c06b75f..c1549870ff 100644 --- a/drivers/snmp-ups.h +++ b/drivers/snmp-ups.h @@ -124,6 +124,10 @@ typedef int bool_t; # endif #endif +#ifndef WITH_SNMP_LKP_FUN_DUMMY +# define WITH_SNMP_LKP_FUN_DUMMY 0 +#endif + /* for lookup between OID values and INFO_ value */ typedef struct { int oid_value; /* SNMP OID value */