Skip to content

Commit 13479cc

Browse files
authored
Merge pull request #1319 from jimklimov/42ity-upstream-MIBs
Upstream Eaton/Powerware/MGE data mappings from 42ity/nut
2 parents 590a48f + d710fd8 commit 13479cc

16 files changed

+1399
-223
lines changed

docs/nut-names.txt

+4
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ input: Incoming line/power information
241241
of full) | 25
242242
| input.realpower | Current sum value of all (ePDU)
243243
phases real power (W) | 300
244+
| input.realpower.nominal | Nominal sum value of all (ePDU)
245+
phases real power (W) | 850
244246
| input.power | Current sum value of all (ePDU)
245247
phases apparent power (VA) | 500
246248
| input.source | The current input power source | 1
@@ -632,6 +634,8 @@ Some specific data to outlet groups exists:
632634
|=================================================================================
633635
| Name | Description | Example value
634636
| outlet.group.n.type | Type of outlet group (OPAQUE) | outlet-section
637+
| outlet.group.n.color | Color-coding of the outlets
638+
in this group (OPAQUE) | yellow
635639
| outlet.group.n.count | Number of outlets in the group | 12
636640
| outlet.group.n.phase | Electrical phase to which the
637641
physical outlet group (Gang) is

drivers/Makefile.am

+3-3
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ snmp_ups_SOURCES = snmp-ups.c snmp-ups-helpers.c \
232232
baytech-mib.c bestpower-mib.c \
233233
compaq-mib.c cyberpower-mib.c \
234234
delta_ups-mib.c \
235-
eaton-pdu-genesis2-mib.c eaton-pdu-marlin-mib.c \
235+
eaton-pdu-genesis2-mib.c eaton-pdu-marlin-mib.c eaton-pdu-marlin-helpers.c \
236236
eaton-pdu-pulizzi-mib.c eaton-pdu-revelation-mib.c \
237237
eaton-ats16-nmc-mib.c eaton-ats16-nm2-mib.c apc-ats-mib.c eaton-ats30-mib.c \
238238
emerson-avocent-pdu-mib.c \
@@ -313,7 +313,7 @@ nutdrv_qx_SOURCES += $(NUTDRV_QX_SUBDRIVERS)
313313
# tracking (which is automatic), but to ensure these files are
314314
# distributed by "make dist".
315315

316-
dist_noinst_HEADERS = apc-mib.h apc-hid.h arduino-hid.h baytech-mib.h bcmxcp.h bcmxcp_ser.h \
316+
dist_noinst_HEADERS = apc-mib.h apc-iem-mib.h apc-hid.h arduino-hid.h baytech-mib.h bcmxcp.h bcmxcp_ser.h \
317317
bcmxcp_io.h belkin.h belkin-hid.h bestpower-mib.h blazer.h cps-hid.h dstate.h \
318318
dummy-ups.h explore-hid.h gamatronic.h genericups.h \
319319
hidparser.h hidtypes.h ietf-mib.h libhid.h libshut.h nut_libusb.h liebert-hid.h \
@@ -329,7 +329,7 @@ dist_noinst_HEADERS = apc-mib.h apc-hid.h arduino-hid.h baytech-mib.h bcmxcp.h b
329329
nutdrv_qx_megatec.h nutdrv_qx_megatec-old.h nutdrv_qx_mustek.h nutdrv_qx_q1.h nutdrv_qx_hunnox.h \
330330
nutdrv_qx_voltronic.h nutdrv_qx_voltronic-qs.h nutdrv_qx_voltronic-qs-hex.h nutdrv_qx_zinto.h \
331331
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 \
332-
apc-pdu-mib.h ever-hid.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h \
332+
apc-pdu-mib.h ever-hid.h eaton-pdu-genesis2-mib.h eaton-pdu-marlin-mib.h eaton-pdu-marlin-helpers.h \
333333
eaton-pdu-pulizzi-mib.h eaton-pdu-revelation-mib.h emerson-avocent-pdu-mib.h legrand-hid.h \
334334
hpe-pdu-mib.h powervar-hid.h delta_ups-hid.h generic_modbus.h salicru-hid.h
335335

drivers/apc-iem-mib.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef APC_IEM_MIB_H
2+
#define APC_IEM_MIB_H
3+
4+
/*
5+
* FIXME: The below is needed because the main driver body uses this to determine
6+
* whether a conversion from Fahrenheit to Celsius is needed (which really should
7+
* be solved in subdriver specific formatting functions, like we do in usbhid-ups
8+
* This is used in both snmp-ups.c and apc.c logics.
9+
*/
10+
11+
/* IEM ambient variables */
12+
/* IEM: integrated environment monitor probe */
13+
14+
#define APCC_OID_IEM_TEMP ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1"
15+
#define APCC_OID_IEM_TEMP_UNIT ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.1"
16+
#define APCC_IEM_FAHRENHEIT 2
17+
#define APCC_OID_IEM_HUMID ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.1"
18+
19+
#endif /* APC_IEM_MIB_H */

drivers/apc-mib.c

-6
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,7 @@ static snmp_info_t apcc_mib[] = {
276276
{ "ambient.humidity", 0, 1, ".1.3.6.1.4.1.318.1.1.2.1.2.0", "", SU_FLAG_OK, NULL },
277277
{ "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 },
278278
{ "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 },
279-
280-
/* IEM ambient variables */
281279
/* IEM: integrated environment monitor probe */
282-
#define APCC_OID_IEM_TEMP ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1"
283-
#define APCC_OID_IEM_TEMP_UNIT ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.1"
284-
#define APCC_IEM_FAHRENHEIT 2
285-
#define APCC_OID_IEM_HUMID ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6.1"
286280
{ "ambient.temperature", 0, 1, APCC_OID_IEM_TEMP, "", SU_FLAG_OK, NULL },
287281
{ "ambient.humidity", 0, 1, APCC_OID_IEM_HUMID, "", SU_FLAG_OK, NULL },
288282

drivers/apc-mib.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@
33

44
#include "main.h"
55
#include "snmp-ups.h"
6-
7-
/*
8-
* FIXME: The below is needed because the main driver body uses this to determine
9-
* whether a conversion from Fahrenheit to Celsius is needed (which really should
10-
* be solved in subdriver specific formatting functions, like we do in usbhid-ups
11-
*/
12-
#define APCC_OID_IEM_TEMP ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.4.1"
13-
#define APCC_OID_IEM_TEMP_UNIT ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.1"
14-
#define APCC_IEM_FAHRENHEIT 2
6+
#include "apc-iem-mib.h"
157

168
extern mib2nut_info_t apc;
179

drivers/eaton-ats16-nm2-mib.c

+19-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "eaton-ats16-nm2-mib.h"
2727

28-
#define EATON_ATS16_NM2_MIB_VERSION "0.21"
28+
#define EATON_ATS16_NM2_MIB_VERSION "0.22"
2929

3030
#define EATON_ATS16_NM2_SYSOID ".1.3.6.1.4.1.534.10.2" /* newer Network-M2 */
3131
#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[] = {
7878
{ 0, NULL, NULL, NULL }
7979
};
8080

81+
static info_lkp_t eaton_ats16_ambient_drycontacts_info[] = {
82+
{ -1, "unknown", NULL, NULL },
83+
{ 1, "opened", NULL, NULL },
84+
{ 2, "closed", NULL, NULL },
85+
{ 3, "opened", NULL, NULL }, /* openWithNotice */
86+
{ 4, "closed", NULL, NULL }, /* closedWithNotice */
87+
{ 0, NULL, NULL, NULL }
88+
};
89+
8190
/* EATON_ATS Snmp2NUT lookup table */
8291
static snmp_info_t eaton_ats16_nm2_mib[] = {
8392

@@ -167,6 +176,15 @@ static snmp_info_t eaton_ats16_nm2_mib[] = {
167176
{ "ambient.humidity.low", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.7.0", NULL, SU_FLAG_OK, NULL },
168177
/* ats2EnvRemoteHumidityUpperLimit.0 = INTEGER: 90 percent */
169178
{ "ambient.humidity.high", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.8.0", NULL, SU_FLAG_OK, NULL },
179+
/* Dry contacts on EMP001 TH module */
180+
/* ats2ContactState.1 = INTEGER: open(1) */
181+
{ "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE,
182+
".1.3.6.1.4.1.534.10.2.5.4.1.3.1",
183+
NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0] },
184+
/* ats2ContactState.2 = INTEGER: open(1) */
185+
{ "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE,
186+
".1.3.6.1.4.1.534.10.2.5.4.1.3.2",
187+
NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0] },
170188

171189
#if 0 /* FIXME: Remaining data to be processed */
172190
/* ats2InputStatusDephasing.0 = INTEGER: normal(1) */

drivers/eaton-ats16-nmc-mib.c

+19-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "eaton-ats16-nmc-mib.h"
2727

28-
#define EATON_ATS16_NMC_MIB_VERSION "0.20"
28+
#define EATON_ATS16_NMC_MIB_VERSION "0.21"
2929

3030
#define EATON_ATS16_NMC_SYSOID ".1.3.6.1.4.1.705.1" /* legacy NMC */
3131
#define EATON_ATS16_NMC_MODEL ".1.3.6.1.4.1.534.10.2.1.2.0"
@@ -78,9 +78,17 @@ static info_lkp_t eaton_ats16_nmc_output_status_info[] = {
7878
{ 0, NULL, NULL, NULL }
7979
};
8080

81+
static info_lkp_t eaton_ats16_ambient_drycontacts_info[] = {
82+
{ -1, "unknown", NULL, NULL },
83+
{ 1, "opened", NULL, NULL },
84+
{ 2, "closed", NULL, NULL },
85+
{ 3, "opened", NULL, NULL }, /* openWithNotice */
86+
{ 4, "closed", NULL, NULL }, /* closedWithNotice */
87+
{ 0, NULL, NULL, NULL }
88+
};
89+
8190
/* EATON_ATS_NMC Snmp2NUT lookup table */
8291
static snmp_info_t eaton_ats16_nmc_mib[] = {
83-
8492
/* standard MIB items */
8593
{ "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL },
8694
{ "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL },
@@ -167,6 +175,15 @@ static snmp_info_t eaton_ats16_nmc_mib[] = {
167175
{ "ambient.humidity.low", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.7.0", NULL, SU_FLAG_OK, NULL },
168176
/* ats2EnvRemoteHumidityUpperLimit.0 = INTEGER: 90 percent */
169177
{ "ambient.humidity.high", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.5.8.0", NULL, SU_FLAG_OK, NULL },
178+
/* Dry contacts on EMP001 TH module */
179+
/* ats2ContactState.1 = INTEGER: open(1) */
180+
{ "ambient.contacts.1.status", ST_FLAG_STRING, SU_INFOSIZE,
181+
".1.3.6.1.4.1.534.10.2.5.4.1.3.1",
182+
NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0] },
183+
/* ats2ContactState.2 = INTEGER: open(1) */
184+
{ "ambient.contacts.2.status", ST_FLAG_STRING, SU_INFOSIZE,
185+
".1.3.6.1.4.1.534.10.2.5.4.1.3.2",
186+
NULL, SU_FLAG_OK, &eaton_ats16_ambient_drycontacts_info[0]},
170187

171188
#if 0 /* FIXME: Remaining data to be processed */
172189
/* ats2InputStatusDephasing.0 = INTEGER: normal(1) */
@@ -236,10 +253,6 @@ static snmp_info_t eaton_ats16_nmc_mib[] = {
236253
{ "unmapped.ats2ContactType", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.2.1", NULL, SU_FLAG_OK, NULL },
237254
/* ats2ContactType.2 = INTEGER: notUsed(4) */
238255
{ "unmapped.ats2ContactType", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.2.2", NULL, SU_FLAG_OK, NULL },
239-
/* ats2ContactState.1 = INTEGER: open(1) */
240-
{ "unmapped.ats2ContactState", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.3.1", NULL, SU_FLAG_OK, NULL },
241-
/* ats2ContactState.2 = INTEGER: open(1) */
242-
{ "unmapped.ats2ContactState", 0, 1, ".1.3.6.1.4.1.534.10.2.5.4.1.3.2", NULL, SU_FLAG_OK, NULL },
243256
/* ats2ContactDescr.1 = STRING: Input #1 */
244257
{ "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 },
245258
/* ats2ContactDescr.2 = STRING: Input #2 */

drivers/eaton-pdu-marlin-helpers.c

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/* eaton-pdu-marlin-helpers.c - helper routines for eaton-pdu-marlin-mib.c
2+
* to monitor Eaton ePDUs branded as:
3+
* G2 Marlin SW / MI / MO / MA
4+
* G3 Shark SW / MI / MO / MA
5+
*
6+
* Copyright (C) 2017-2019
7+
* Arnaud Quette <ArnaudQuette@Eaton.com>
8+
* Copyright (C) 2017
9+
* Jim Klimov <EvgenyKlimov@Eaton.com>
10+
*
11+
* Supported by Eaton <http://www.eaton.com>
12+
* and previously MGE Office Protection Systems <http://www.mgeops.com>
13+
*
14+
* This program is free software; you can redistribute it and/or modify
15+
* it under the terms of the GNU General Public License as published by
16+
* the Free Software Foundation; either version 2 of the License, or
17+
* (at your option) any later version.
18+
*
19+
* This program is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
* GNU General Public License for more details.
23+
*
24+
*
25+
* You should have received a copy of the GNU General Public License
26+
* along with this program; if not, write to the Free Software
27+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28+
*
29+
*/
30+
31+
#include "config.h" /* must be the first header */
32+
33+
#include <stdlib.h>
34+
#include <stdio.h>
35+
#include <stdint.h>
36+
37+
#include "eaton-pdu-marlin-helpers.h"
38+
#include "dstate.h"
39+
#include "common.h"
40+
/* Allow access to temperature_unit */
41+
#include "snmp-ups.h"
42+
43+
/* Take string "unitsPresent" (ex: "0,3,4,5"), and count the amount
44+
* of "," separators+1 using an inline function */
45+
long marlin_device_count_fun(const char *daisy_dev_list)
46+
{
47+
long count = 0, i;
48+
49+
for (i = 0; daisy_dev_list[i] != '\0'; i++) {
50+
if (daisy_dev_list[i] == ',') {
51+
/* Each comma means a new device in the list */
52+
count ++;
53+
}
54+
}
55+
if (i > 0 && (daisy_dev_list[i - 1] != ',') ) {
56+
/* Non-empty string => at least one device, and no trailing commas */
57+
count ++;
58+
}
59+
60+
upsdebugx(3, "%s: counted devices in '%s', got %ld",
61+
__func__, daisy_dev_list, count);
62+
return count;
63+
}
64+
65+
/* Temperature unit consideration:
66+
* only store the device unit, for converting to Celsius.
67+
* Don't publish the device unit, since NUT will publish
68+
* as Celsius in all cases */
69+
const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value)
70+
{
71+
long snmp_value = *((long*)raw_snmp_value);
72+
switch (snmp_value) {
73+
case 0:
74+
/* store the value, for temperature processing */
75+
temperature_unit = TEMPERATURE_KELVIN;
76+
break;
77+
case 1:
78+
/* store the value, for temperature processing */
79+
temperature_unit = TEMPERATURE_CELSIUS;
80+
break;
81+
case 2:
82+
/* store the value, for temperature processing */
83+
temperature_unit = TEMPERATURE_FAHRENHEIT;
84+
break;
85+
default:
86+
/* store the value, for temperature processing */
87+
temperature_unit = TEMPERATURE_UNKNOWN;
88+
break;
89+
}
90+
return "celsius";
91+
}

drivers/eaton-pdu-marlin-helpers.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eaton-pdu-marlin-helpers.h - helper for subdriver to monitor certain
2+
* Eaton ePDU SNMP devices with NUT
3+
*
4+
* Copyright (C)
5+
* 2017-2019 Arnaud Quette <ArnaudQuette@eaton.com>
6+
* 2017 Jim Klimov <EvgenyKlimov@eaton.com>
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*/
22+
23+
#ifndef EATON_EPDU_MARLIN_HELPERS_H
24+
#define EATON_EPDU_MARLIN_HELPERS_H
25+
26+
long marlin_device_count_fun(const char *daisy_dev_list);
27+
const char *eaton_sensor_temperature_unit_fun(void *raw_snmp_value);
28+
29+
#endif /* EATON_EPDU_MARLIN_HELPERS_H */

0 commit comments

Comments
 (0)