Skip to content

Commit

Permalink
Merge pull request #1319 from jimklimov/42ity-upstream-MIBs
Browse files Browse the repository at this point in the history
Upstream Eaton/Powerware/MGE data mappings from 42ity/nut
  • Loading branch information
jimklimov committed Mar 8, 2022
2 parents 590a48f + d710fd8 commit 13479cc
Show file tree
Hide file tree
Showing 16 changed files with 1,399 additions and 223 deletions.
4 changes: 4 additions & 0 deletions docs/nut-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -632,6 +634,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
Expand Down
6 changes: 3 additions & 3 deletions drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -329,7 +329,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h arduino-hid.h baytech-mib.h bcmxcp.h b
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

Expand Down
19 changes: 19 additions & 0 deletions drivers/apc-iem-mib.h
Original file line number Diff line number Diff line change
@@ -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 */
6 changes: 0 additions & 6 deletions drivers/apc-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },

Expand Down
10 changes: 1 addition & 9 deletions drivers/apc-mib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
20 changes: 19 additions & 1 deletion drivers/eaton-ats16-nm2-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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[] = {

Expand Down Expand Up @@ -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) */
Expand Down
25 changes: 19 additions & 6 deletions drivers/eaton-ats16-nmc-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -167,6 +175,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) */
Expand Down Expand Up @@ -236,10 +253,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 */
Expand Down
91 changes: 91 additions & 0 deletions drivers/eaton-pdu-marlin-helpers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* 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-2019
* Arnaud Quette <ArnaudQuette@Eaton.com>
* Copyright (C) 2017
* Jim Klimov <EvgenyKlimov@Eaton.com>
*
* Supported by Eaton <http://www.eaton.com>
* and previously MGE Office Protection Systems <http://www.mgeops.com>
*
* 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 "config.h" /* must be the first header */

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>

#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 */
count ++;
}
}
if (i > 0 && (daisy_dev_list[i - 1] != ',') ) {
/* 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;
}

/* 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(void *raw_snmp_value)
{
long snmp_value = *((long*)raw_snmp_value);
switch (snmp_value) {
case 0:
/* store the value, for temperature processing */
temperature_unit = TEMPERATURE_KELVIN;
break;
case 1:
/* store the value, for temperature processing */
temperature_unit = TEMPERATURE_CELSIUS;
break;
case 2:
/* store the value, for temperature processing */
temperature_unit = TEMPERATURE_FAHRENHEIT;
break;
default:
/* store the value, for temperature processing */
temperature_unit = TEMPERATURE_UNKNOWN;
break;
}
return "celsius";
}
29 changes: 29 additions & 0 deletions drivers/eaton-pdu-marlin-helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eaton-pdu-marlin-helpers.h - helper for subdriver to monitor certain
* Eaton ePDU SNMP devices with NUT
*
* Copyright (C)
* 2017-2019 Arnaud Quette <ArnaudQuette@eaton.com>
* 2017 Jim Klimov <EvgenyKlimov@eaton.com>
*
* 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

long marlin_device_count_fun(const char *daisy_dev_list);
const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value);

#endif /* EATON_EPDU_MARLIN_HELPERS_H */
Loading

0 comments on commit 13479cc

Please sign in to comment.