Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
dca9db1
snmp-ups.[ch] : introduce SU_FLAG_SEMI_STATIC
jimklimov Oct 11, 2017
a00572c
drivers/apc-iem-mib.h: split some macro definitions away from apc-mib…
jimklimov May 13, 2016
bdfa877
Expel the helper function that interacts with dstate from eaton-pdu-m…
jimklimov Aug 23, 2017
19b52b9
eaton-pdu-marlin-helpers.c : update comments for marlin_outlet_group_…
jimklimov Aug 24, 2017
b2802f8
eaton-pdu-marlin-helpers.c/h fix
jimklimov Aug 24, 2017
e9d45cc
snmp-ups / eaton-marlin : introduce WITH_SNMP_LKP_FUN to separate cod…
jimklimov Aug 24, 2017
a8f6e7a
Fix typo in OID, noticed by aquette
jimklimov Aug 30, 2017
02fb1dc
eaton-pdu-marlin-mib.c : add basic listing of newly defined OIDs (not…
jimklimov Oct 9, 2017
456e623
eaton-pdu-marlin-mib.c / drivers/eaton-pdu-marlin-helpers.[ch] : Impl…
jimklimov Oct 9, 2017
a76861f
eaton-pdu-marlin-mib.c / drivers/eaton-pdu-marlin-helpers.[ch] : Impl…
jimklimov Oct 9, 2017
298445f
eaton-pdu-marlin-mib.c : Revised added OIDs with a single-group ePDU
jimklimov Oct 10, 2017
4ef45b1
eaton-pdu-marlin-mib.c : fix OID and raise questions on input.power.n…
jimklimov Oct 13, 2017
5cfbde7
Problem: Need to fix published feed variables
arnaudquette-eaton Oct 13, 2017
6ab6607
eaton-pdu-marlin-mib.c : updated comments about input/feed relationsh…
jimklimov Oct 13, 2017
184f7fc
eaton-pdu-marlin-* : add support for extended fun/nuf l2s/s2l convers…
jimklimov Oct 11, 2017
a2b8b5e
snmp-ups: simplify Eaton ePDU group phase handling
arnaudquette-eaton Oct 17, 2017
88839b4
snmp-ups: fix Eaton ePDU group phase handling
arnaudquette-eaton Oct 17, 2017
61c5e21
drivers/eaton-pdu-marlin-mib.c: break long lines
jimklimov Feb 25, 2022
6bf88fb
drivers/eaton-pdu-marlin-mib.c: break long lines like in FTY
jimklimov Feb 25, 2022
3c55330
drivers/eaton-pdu-marlin-mib.c: relocate outlet.%i.load.off.delay etc…
jimklimov Feb 25, 2022
bcee36d
eaton-pdu-marlin-mib.c/dmf: add outlet timers
arnaudquette-eaton Oct 30, 2017
84d0d52
snmp-ups: Eaton ePDU input.power.nominal is realpower
arnaudquette-eaton Jun 26, 2018
f917d3d
snmp-ups: Eaton feed color is semi static
arnaudquette-eaton Aug 2, 2018
fe37b22
drivers/snmp-ups.h: avoid "#if" with possibly not-defined macro
jimklimov Feb 25, 2022
f4c44f4
Add support for dry contacts to Eaton ATS16 and UPS
arnaudquette-eaton Nov 3, 2017
d3b6ea4
Modify "open" to "opened" for dry contacts status
arnaudquette-eaton Nov 17, 2017
29c6dea
drivers/eaton-pdu-marlin-mib.c: align with "snmp-ups: Simplify the ma…
jimklimov Feb 27, 2022
53ad5cf
snmp-ups: support newer Genepi management cards
arnaudquette-eaton Aug 7, 2018
8647d18
powerware-mib.c : fix fallout from "snmp-ups: support newer Genepi ma…
jimklimov Aug 7, 2018
a8e12c0
eaton-pdu-marlin-mib.c : preferred templated outlet.%i.name goes last…
jimklimov Oct 11, 2017
27b92d9
drivers/eaton-pdu-marlin-mib.c: align comments around outlet.%i.name …
jimklimov Feb 27, 2022
b8591f8
snmp-ups: support for daisychained ambient sensor
arnaudquette-eaton Sep 9, 2019
ebcac3b
SNMP Eaton ePDU: support for EMPDT1H1C2
arnaudquette-eaton Sep 9, 2019
23054df
eaton-pdu-marlin-helpers.c : in device_count helper do not assume a t…
jimklimov Oct 11, 2017
1cfb809
drivers/eaton-pdu-marlin-helpers.c: fix whitespace
jimklimov Feb 27, 2022
952ab95
SNMP Eaton Gb Network Card: support for EMPDT1H1C2
arnaudquette-eaton Sep 9, 2019
8e181ef
Fix compilation warning
arnaudquette-eaton Sep 12, 2019
43d8c66
Typo fix: sorry Mr Fahrenheit
arnaudquette-eaton Sep 12, 2019
2c1fb1d
powerware-mib - renamed "ietf_*" and "eaton_*" lookups to have "pw_*"…
jimklimov May 25, 2016
41415a8
SNMP Eaton ePDU: always return celsius for temperature
arnaudquette-eaton Sep 19, 2019
33a66d2
drivers/eaton-pdu-marlin-helpers.{c,h}: adjust eaton_sensor_temperatu…
jimklimov Feb 27, 2022
3e25ddb
drivers/snmp-ups.{c,h}: adjust su_temperature_read_fun() API to that …
jimklimov Feb 27, 2022
8ab3116
drivers/eaton-pdu-marlin-mib.c: update comments and implem for dummy …
jimklimov Feb 27, 2022
0a29f94
drivers/powerware-mib.c: update comments and implem for dummy eaton_s…
jimklimov Feb 27, 2022
e280e84
drivers/eaton-pdu-marlin-mib.c: update for new fun_vp2s() type args
jimklimov Oct 13, 2021
968f559
SNMP Eaton EMP002: handle sensor presence
arnaudquette-eaton Sep 19, 2019
4153cd1
SNMP Eaton Gb Network Card: various data completion
arnaudquette-eaton Nov 7, 2019
8930755
Add modbus_address and uuid in snmp-ups/pw driver
ericclappier-eaton Dec 14, 2020
e093c19
Change uid and modbus address name according nut nomenclature
ericclappier-eaton Dec 15, 2020
1114620
Add modbus_address and uuid in eaton_epdu driver
ericclappier-eaton Dec 14, 2020
e2b51e5
snmp-ups: Restore legacy Eaton ePDU switchability info
arnaudquette-eaton Dec 15, 2020
7d0640f
Add ambient.n.parent.serial for marlin epdu
ericclappier-eaton Dec 16, 2020
6f647c2
snmp-ups: fix regression on Eaton ePDU
arnaudquette-eaton Jan 26, 2021
95da25b
Move su_temperature_read_fun() from drivers/snmp-ups.c to snmp-ups-he…
jimklimov Feb 27, 2022
eb7d250
Fix dry contacts status for EMP02
ericclappier-eaton Feb 1, 2021
50dcc41
Add missing outlet objects for master
ericclappier-eaton Jun 14, 2021
6e83f1f
Fix regression on Eaton EMP002 temperature reading (SNMP)
arnaudquette-eaton Nov 15, 2021
79dd957
Eaton XML/PDC: add External Battery Module count
arnaudquette-eaton Nov 22, 2021
9a8c11b
Eaton NMC: fix the non publication of real/power with 3ph
arnaudquette-eaton Jan 12, 2022
015619e
Eaton SNMP: also publish ups.load for 3phase
arnaudquette-eaton Nov 25, 2021
f799e08
drivers/eaton-pdu-marlin-helpers.c: include config.h first
jimklimov Nov 17, 2021
a270795
drivers/snmp-ups.c: avoid stringop-truncation warning
jimklimov Nov 11, 2021
c2f50f0
drivers/snmp-ups.c: avoid stringop-truncation warning: make sure stri…
jimklimov Feb 27, 2022
8df3a97
drivers/eaton-pdu-marlin-mib.c: break long lines
jimklimov Feb 25, 2022
b496343
drivers/eaton-pdu-marlin-mib.c: resync comments and use of SU_FLAG_SE…
jimklimov Feb 27, 2022
3aefd12
Fix false positive when communication is lost
arnaudquette-eaton Sep 25, 2019
406250e
drivers/snmp-ups.c: su_find_strval() should consider #if WITH_SNMP_LK…
jimklimov Oct 13, 2021
7a128cc
snmp-ups.c : publish device.count==1 too
jimklimov Oct 11, 2017
6af7233
drivers/snmp-ups.c: whitespace fix
jimklimov Feb 27, 2022
3261283
drivers/snmp-ups.c: su_find_strval(): mark NUT_UNUSED_VARIABLE(oid2in…
jimklimov Nov 17, 2021
161fd3e
drivers/eaton-pdu-marlin-helpers.c: marlin_device_count_fun(): add de…
jimklimov Feb 27, 2022
cb7f65a
drivers/snmp-ups.c: daisychain_init(): add debug trace
jimklimov Feb 27, 2022
2d97ab0
drivers/snmp-ups.c: extend daisychain initialization to use optional …
jimklimov Feb 27, 2022
5bcf73f
drivers/mge-xml.c: mge_drycontact_info(): avoid shadowing global vari…
jimklimov Mar 2, 2022
d710fd8
drivers/snmp-ups.h: make sure WITH_SNMP_LKP_FUN_DUMMY is defined
jimklimov Mar 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
* Copyright (C) 2017
* Jim Klimov <[email protected]>
*
* 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 <[email protected]>
* 2017 Jim Klimov <[email protected]>
*
* 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