Skip to content

Commit

Permalink
DMF remerge 20170825 from master (#467)
Browse files Browse the repository at this point in the history
* gitlog2changelog: Date header only occurs at start of line

Alternative to #427

* gitlog2changelog: log parse errors for Author and Date

Suggested by Jim Klimov.

* configure.ac : move comment to a more relevant line

* docs/man/Makefile.am : small typo in comment

* configure.ac : refer to detailed doc from --with-doc help text; preset explicit nut_with_doc=man=auto value

* m4/nut_check_asciidoc.m4 configure.ac : parametrize the required minimum versions (asciidoc/a2x, dblatex)

* configure.ac docs/man/Makefile.am : track DOC_INSTALL_DISTED_MANS fallback behavior

* docs/man/Makefile.am : do not rebuild docs and do not error out if a prebuilt copy is among sources (not only in builddir as before)

* docs/Makefile.am : make sure the builddir copy of docbook-xsl.css is writeable (file is copied from OS, some distros have it 444 and not 644)

* docs/man/Makefile.am : Fix up manpage source timestamps when dist-ing

* docs/man/Makefile.am : Fix up dist-ed manpage source timestamps regardless of DOC_INSTALL_DISTED_MANS value

* docs/man/Makefile.am : Suffice to have prebuilt docs in dist-ed sources only if DOC_INSTALL_DISTED_MANS is enabled

* usbhid-ups: only check iOEMInformation once for openups2

This prevents the 'libusb_get_string: invalid argument' message from being
logged continously.

Patch provided by Alphonse <alphsteiner@gmail.com>

http://lists.alioth.debian.org/pipermail/nut-upsdev/2017-July/007314.html

* snmp-ups: Introduce values lookup functions

As already used in other drivers, such as usbhid-ups, introduce optional
values lookup functions, beside from values lookup mapping. This allows to have
a more powerful and generic values processing before publication

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* CPS HID: add input.frequency and output.frequency (0.5)

Suggested by Andy Jan:
http://lists.alioth.debian.org/pipermail/nut-upsuser/2017-August/010856.html

* snmp-ups: Fix the phase of outlet groups for Eaton PDU

Compute the phase to which an outlet group is connected WRT the total number of
phase(s) and the considered outlet group number.

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* Extend namespace for iPDU and outlets

Extend NUT namespace to also publish the name of an outlet, using
"outlet.n.name", beside from the existing "outlet.n.desc"

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* snmp-ups: Publish outlet.n.name for Eaton ePDU

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* NUT namespace: fix an extraneous character insertion

A character was wrongly inserted during the previous commit, triggering a
spellcheck error

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* Remove exec bits on SNMP subdrivers

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* apcupsd-ups: interpret "SHUTTING DOWN" as "LB"

Fix issue #460 so NUT with
apcupsd-ups driver will correctly initiate a shut down on low battery.

Bump version to 0.5

Closes: #460
Closes: #461

* snmp-ups: fix the rounding / truncation of some values

The multiplier system of the snmp-ups driver resulted in some values being
rounded to the nearby integer value, thus causing a loss of the decimals and
the value precision in general. This was mainly visible on the value of
currents, but also on some voltages

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* snmp-subdrivers.txt : reference the multitude of eaton subdrivers

* eaton-mib.h renamed into separate constituent headers

* eaton-mib.c renamed into separate constituent sources, earlier history retained in eaton-pdu-genesis2-mib.c

* Re-merged drivers/eaton-mib.c from upstream/master and regenerated DMF

* eaton-pdu-revelation-mib.c eaton-pdu-pulizzi-mib.c eaton-pdu-genesis2-mib.c : no use to include dstate.h here

* eaton-pdu-marlin-mib.c eaton-pdu-revelation-mib.c : port the renamed structure names from original eaton-mib.c evolution

* Integrate recent upstream changes into DMF

* WIP remerge DMF to master so it can compile

* Eaton ePDU SNMP MIB file split in four (#465)

* snmp-subdrivers.txt : reference the multitude of eaton subdrivers

* eaton-mib.h renamed into separate constituent headers

* eaton-mib.c renamed into separate constituent sources, earlier history retained in eaton-pdu-genesis2-mib.c

* eaton-pdu-revelation-mib.c eaton-pdu-pulizzi-mib.c eaton-pdu-genesis2-mib.c : no use to include dstate.h here

* eaton-pdu-marlin-mib.c eaton-pdu-revelation-mib.c : port the renamed structure names from original eaton-mib.c evolution

* automake: only pass net-snmp cflags to snmp-ups (#464)

Other than formerly assumed in the makefile cflags can be more than
includes. And some of them need to be in sync in regard to CFLAGS and
LDFLAGS - for example usage of -fPIE.

This conflicts with a current assumption in the makefile "In any case,
CFLAGS are only -I options, so there is no harm".

On a Distribution where PIE is enabled by default, but disabled for
special cases (like net-snmp) the configure detection gets them as:
LIBNETSNMP_CFLAGS = -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g -O2
-fdebug-prefix-map=/build/net-snmp-nlMQSZ/net-snmp-5.7.3+dfsg=.
-specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong
-Wformat -Werror=format-security -DNETSNMP_USE_INLINE -Ulinux
-Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv
-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE
-Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include
LIBNETSNMP_LIBS = -Wl,-Bsymbolic-functions
-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now
-L/usr/lib/x86_64-linux-gnu -lnetsnmp -lcrypto -lm

Of importance are:
-specs=/usr/share/dpkg/no-pie-compile.specs
-specs=/usr/share/dpkg/no-pie-link.specs

Now when compiling the non-snmp objects incorrectly get the
"-specs=/usr/share/dpkg/no-pie-compile.specs" due to the assumption
that it is safe to add up all CFLAGS to the global one.

LDFLAGS imported that way are only added to snmp.
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
[...]
snmp-ups$(EXEEXT): $(snmp_ups_OBJECTS) $(snmp_ups_DEPENDENCIES)
$(EXTRA_snmp_ups_DEPENDENCIES)
        @rm -f snmp-ups$(EXEEXT)
        $(AM_V_CCLD)$(LINK) $(snmp_ups_OBJECTS) $(snmp_ups_LDADD)
$(LIBS)

That leads to other (all non snmp_ups) objects in drivers failing to build.
They get the no-pie-compile.specs (incorrect) spec but not the
no-pie-link.specs on the link step.

Some other parts like mge_shut and nutdrv_qx already have custom
CFLAGS/LDFLAGS that are not added to the global CFLAGS. So despite the
commend in the makefile this doesn't seem to be new in general to nut.

I don't want to mess too much with your build system for now as I don't
know many of its implications. So I chose not the full drop of that
global CFLAGS merge, but a minimal patch for now which fixes the issue
described.

Thereby closes #463

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>

* snmp-ups: add support for input.phase.shift (#433)

* snmp-ups: add support for input.phase.shift

ATS can now publish the electrical dephasing between input sources

Signed-off-by: Arnaud Quette <ArnaudQuette@Eaton.com>

* Make spellchecker happy about "dephasing"

* Expel the helper function that interacts with dstate from eaton-pdu-marlin-mib.c to eaton-pdu-marlin-helpers.c/.h

* eaton-pdu-marlin-helpers.c : update comments for marlin_outlet_group_phase_fun()

* snmp-ups / eaton-marlin : introduce WITH_SNMP_LKP_FUN to separate codebases that support these callbacks from those that currently do not

* eaton-marlin : cosmetic whitespace fixes

* snmp-ups : update copyrights from Eaton staffers

* eaton-ats16-mib.dmf : updated to include phase.shift from new C MIB mapping

* dstate.h : use our timehead.h to have "struct timeval" defined

* eaton-pdu-marlin-helpers.c/h fix

* snmp-ups / eaton-marlin : introduce WITH_SNMP_LKP_FUN to separate codebases that support these callbacks from those that currently do not

* drivers/Makefile.am : adapt to solution of #464 / #463

* scripts/DMF/Makefile.am : use WITH_DMFMIB to trigger WITH_SNMP_LKP_FUN in snmp-ups codebase, in particular

* scripts/DMF/Makefile.am : rearrange long line for readability

* scripts/DMF/Makefile.am : revert the magic with dstate.o in DMF selftests

* jsonify-mib.py : pass LDFLAGS after the output and original source file

* Add newly reorganized and generated eaton-pdu-*-mib.dmf files to SCM

* drivers/Makefile.am : adapt to solution of #464 / #463

* drivers/Makefile.am : adapt to solution of #464 / #463

* drivers/Makefile.am : cosmetic fix in DMF branch

* scripts/DMF/dmf-test.c : introduce and comment WITH_SNMP_LKP_FUN to separate codebases that support these callbacks from those that currently do not

* configure.ac : make sure to remove temp dir from dmfify tests
  • Loading branch information
jimklimov authored and aquette committed Aug 25, 2017
1 parent c1a853e commit 6ad3412
Show file tree
Hide file tree
Showing 31 changed files with 978 additions and 560 deletions.
3 changes: 1 addition & 2 deletions clients/upsclient.c
Expand Up @@ -25,7 +25,7 @@
#ifdef HAVE_PTHREAD
/* this include is needed on AIX to have errno stored in thread local storage */
#include <pthread.h>
#endif
#endif

#include <errno.h>
#include <netdb.h>
Expand All @@ -37,7 +37,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/time.h>

#include "upsclient.h"
#include "common.h"
Expand Down
7 changes: 4 additions & 3 deletions configure.ac
Expand Up @@ -1781,8 +1781,9 @@ if test "${want_regenerate_dmf_snmp}" != no ; then
can_generate_dmf_snmp=no
CURDIR="$(pwd)" && \
if test "${nut_with_dmf}" = "yes"; then
{ OUTDIR="$(mktemp -d configure-test.dmfify.$$.XXXXXXX)" && \
( OUTDIR="$(mktemp -d configure-test.dmfify.$$.XXXXXXX)" && \
test -d "$OUTDIR" && OUTDIR="$(cd "${OUTDIR}" && pwd)" && \
trap "cd '${CURDIR}' && rm -rf '${OUTDIR}'" 0 1 2 3 15 && \
if test -z "${srcdir}" -o "${srcdir}" = . ; then SRCDIR="${CURDIR}"; else SRCDIR="$(cd "${srcdir}" && pwd)"; fi && \
DMFDIR="$(cd "${SRCDIR}/scripts/DMF" && pwd)" && \
{ cd "${DMFDIR}" && \
Expand All @@ -1802,8 +1803,8 @@ if test "${want_regenerate_dmf_snmp}" != no ; then
|| { can_generate_dmf_snmp="no: ERROR: Failed nut_cpp parse of a test C to DMF for '$F'"; false ; break; } \
done ; } ; \
}
RES=$?; rm -rf "$OUTDIR"; test "${RES}" = 0
} >&5 2>&5 \
RES=$?; cd "${CURDIR}"; rm -rf "${OUTDIR}"; test "${RES}" = 0
) >&5 2>&5 \
&& can_generate_dmf_snmp=yes
fi
if test -n "${CURDIR}" ; then cd "${CURDIR}" ; fi
Expand Down
7 changes: 5 additions & 2 deletions docs/nut-names.txt
Expand Up @@ -194,7 +194,9 @@ input: Incoming line/power information
| input.power | Current sum value of all (ePDU)
phases apparent power (VA) | 500
| input.source | The current input power source | 1
| input.source.preferred | The preferred power source | 1
| input.source.preferred | The preferred power source | 1
| input.phase.shift | Voltage dephasing between input
sources (degrees) | 181
|=================================================================================

output: Outgoing power/inverter information
Expand Down Expand Up @@ -486,7 +488,8 @@ of the user manual.
| outlet.count | Total number of outlets | 12
| outlet.n.id | Outlet system identifier
(opaque string) | 1
| outlet.n.desc | Outlet name / description
| outlet.n.name | Outlet name (opaque string) | A1
| outlet.n.desc | Outlet description
(opaque string) | Main outlet
| outlet.n.groupid | Identifier of the group to
which the outlet belongs to | 1
Expand Down
3 changes: 2 additions & 1 deletion docs/nut.dict
@@ -1,4 +1,4 @@
personal_ws-1.1 en 2458 utf-8
personal_ws-1.1 en 2459 utf-8
AAS
ACFAIL
ACFREQ
Expand Down Expand Up @@ -1413,6 +1413,7 @@ decrement
decrypt
defun
dep
dephasing
deps
desc
deschis
Expand Down
4 changes: 2 additions & 2 deletions docs/snmp-subdrivers.txt
Expand Up @@ -205,14 +205,14 @@ you must examine the NUT variables of the form "unmapped.*" in the
hid_info_t data structure, and map them to actual NUT variables and
instant commands. There are currently no step-by-step instructions for
how to do this. Please look at the files to see how the currently implemented
subdrivers are written.:
subdrivers are written:

- apc-mib.c/h
- baytech-mib.c/h
- bestpower-mib.c/h
- compaq-mib.c/h
- cyberpower-mib.c/h
- eaton-mib.c/h
- eaton-*-mib.c/h
- ietf-mib.c/h
- mge-mib.c/h
- netvision-mib.c/h
Expand Down
17 changes: 10 additions & 7 deletions drivers/Makefile.am
Expand Up @@ -16,9 +16,6 @@ AM_CFLAGS = -I$(top_srcdir)/include
if WITH_USB
AM_CFLAGS += $(LIBUSB_CFLAGS)
endif
if WITH_SNMP
AM_CFLAGS += $(LIBNETSNMP_CFLAGS)
endif
if WITH_NEON
AM_CFLAGS += $(LIBNEON_CFLAGS)
endif
Expand Down Expand Up @@ -207,13 +204,17 @@ mge_shut_CFLAGS = $(AM_CFLAGS) -DSHUT_MODE
mge_shut_LDADD = $(LDADD)

# SNMP
snmp_ups_SOURCES = snmp-ups.c apc-mib.c baytech-mib.c compaq-mib.c eaton-mib.c \
snmp_ups_SOURCES = snmp-ups.c apc-mib.c baytech-mib.c compaq-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 \
ietf-mib.c mge-mib.c netvision-mib.c powerware-mib.c raritan-pdu-mib.c \
bestpower-mib.c cyberpower-mib.c delta_ups-mib.c xppc-mib.c huawei-mib.c \
eaton-ats16-mib.c apc-ats-mib.c raritan-px2-mib.c eaton-ats30-mib.c \
apc-pdu-mib.c
snmp_ups_CFLAGS = $(AM_CFLAGS)
snmp_ups_CFLAGS += $(LIBNETSNMP_CFLAGS)
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
snmp_ups_CFLAGS = $(AM_CFLAGS) -DWITH_DMFMIB=0 -DWITH_DMF_LUA=0 -DWITH_DMF_FUNCTIONS=0
snmp_ups_CFLAGS += -DWITH_DMFMIB=0 -DWITH_DMF_LUA=0 -DWITH_DMF_FUNCTIONS=0

# DMF SNMP - ok to define this in the open, it is only built if enabled above
snmp_ups_dmf_SOURCES = snmp-ups.c
Expand All @@ -222,6 +223,7 @@ snmp_ups_dmf_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS) \
$(top_builddir)/common/libcommon.la
snmp_ups_dmf_CFLAGS = $(AM_CFLAGS) \
-I$(top_srcdir)/tools/nut-scanner -DWITH_DMFMIB=1
snmp_ups_dmf_CFLAGS += $(LIBNETSNMP_CFLAGS)
if WITH_DMF_LUA
LUA_INCLUDE ?= -I/usr/include/lua5.1
snmp_ups_dmf_CFLAGS += -DWITH_DMF_LUA=1 -DWITH_DMF_FUNCTIONS=1 $(LUA_INCLUDE)
Expand Down Expand Up @@ -299,7 +301,7 @@ nutdrv_qx_SOURCES += $(NUTDRV_QX_SUBDRIVERS)

dist_noinst_HEADERS = apc-mib.h apc-iem-mib.h apc-hid.h baytech-mib.h bcmxcp.h \
bcmxcp_io.h belkin.h belkin-hid.h bestpower-mib.h blazer.h cps-hid.h dstate.h \
dummy-ups.h eaton-mib.h explore-hid.h gamatronic.h genericups.h \
dummy-ups.h explore-hid.h gamatronic.h genericups.h \
hidparser.h hidtypes.h ietf-mib.h libhid.h libshut.h libusb.h liebert-hid.h \
main.h mge-hid.h mge-mib.h mge-utalk.h \
mge-xml.h microdowell.h netvision-mib.h netxml-ups.h nut-ipmi.h oneac.h \
Expand All @@ -311,7 +313,8 @@ dist_noinst_HEADERS = apc-mib.h apc-iem-mib.h apc-hid.h baytech-mib.h bcmxcp.h \
nutdrv_qx_megatec.h nutdrv_qx_megatec-old.h nutdrv_qx_mustek.h nutdrv_qx_q1.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-mib.h apc-ats-mib.h raritan-px2-mib.h eaton-ats30-mib.h \
apc-pdu-mib.h
apc-pdu-mib.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

# Define a dummy library so that Automake builds rules for the
# corresponding object files. This library is not actually built,
Expand Down
10 changes: 5 additions & 5 deletions drivers/apcupsd-ups.c
Expand Up @@ -26,7 +26,7 @@
#include "apcupsd-ups.h"

#define DRIVER_NAME "apcupsd network client UPS driver"
#define DRIVER_VERSION "0.04"
#define DRIVER_VERSION "0.5"

/* driver description structure */
upsdrv_info_t upsdrv_info = {
Expand Down Expand Up @@ -54,9 +54,8 @@ static void process(char *item,char *data)
{
case DU_FLAG_STATUS:
status_init();
if(!strcmp(data,"COMMLOST")||!strcmp(data,"SHUTTING DOWN")||
!strcmp(data,"NETWORK ERROR")||!strcmp(data,"ERROR"))
status_set("OFF");
if(!strcmp(data,"COMMLOST")||!strcmp(data,"NETWORK ERROR")||
!strcmp(data,"ERROR"))status_set("OFF");
else if(!strcmp(data,"SELFTEST"))status_set("OB");
else for(;(data=strtok(data," "));data=NULL)
{
Expand All @@ -66,7 +65,8 @@ static void process(char *item,char *data)
else if(!strcmp(data,"ONLINE"))status_set("OL");
else if(!strcmp(data,"ONBATT"))status_set("OB");
else if(!strcmp(data,"OVERLOAD"))status_set("OVER");
else if(!strcmp(data,"LOWBATT"))status_set("LB");
else if(!strcmp(data,"SHUTTING DOWN")||
!strcmp(data,"LOWBATT"))status_set("LB");
else if(!strcmp(data,"REPLACEBATT"))status_set("RB");
else if(!strcmp(data,"NOBATT"))status_set("BYPASS");
}
Expand Down
4 changes: 3 additions & 1 deletion drivers/cps-hid.c
Expand Up @@ -28,7 +28,7 @@
#include "cps-hid.h"
#include "usb-common.h"

#define CPS_HID_VERSION "CyberPower HID 0.4"
#define CPS_HID_VERSION "CyberPower HID 0.5"

/* Cyber Power Systems */
#define CPS_VENDORID 0x0764
Expand Down Expand Up @@ -193,12 +193,14 @@ static hid_info_t cps_hid2nut[] = {
{ "BOOL", 0, 0, "UPS.Output.Overload", NULL, NULL, 0, overload_info },

/* Input page */
{ "input.frequency", 0, 0, "UPS.Input.Frequency", NULL, "%.1f", 0, NULL },
{ "input.voltage.nominal", 0, 0, "UPS.Input.ConfigVoltage", NULL, "%.0f", 0, NULL },
{ "input.voltage", 0, 0, "UPS.Input.Voltage", NULL, "%.1f", 0, NULL },
{ "input.transfer.low", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.Input.LowVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },
{ "input.transfer.high", ST_FLAG_RW | ST_FLAG_STRING, 10, "UPS.Input.HighVoltageTransfer", NULL, "%.0f", HU_FLAG_SEMI_STATIC, NULL },

/* Output page */
{ "output.frequency", 0, 0, "UPS.Output.Frequency", NULL, "%.1f", 0, NULL },
{ "output.voltage", 0, 0, "UPS.Output.Voltage", NULL, "%.1f", 0, NULL },
{ "output.voltage.nominal", 0, 0, "UPS.Output.ConfigVoltage", NULL, "%.0f", 0, NULL },

Expand Down
1 change: 1 addition & 0 deletions drivers/dstate.h
Expand Up @@ -22,6 +22,7 @@
#ifndef DSTATE_H_SEEN
#define DSTATE_H_SEEN 1

#include "timehead.h"
#include "state.h"
#include "attribute.h"

Expand Down
4 changes: 3 additions & 1 deletion drivers/eaton-ats16-mib.c
Expand Up @@ -24,7 +24,7 @@

#include "eaton-ats16-mib.h"

#define EATON_ATS16_MIB_VERSION "0.13"
#define EATON_ATS16_MIB_VERSION "0.14"

#define EATON_ATS16_SYSOID ".1.3.6.1.4.1.534.10"
#define EATON_ATS16_MODEL ".1.3.6.1.4.1.534.10.2.1.2.0"
Expand Down Expand Up @@ -128,6 +128,8 @@ static snmp_info_t eaton_ats16_mib[] = {
{ "input.source", ST_FLAG_STRING, 1, ".1.3.6.1.4.1.534.10.2.2.4.0", NULL, SU_FLAG_OK, eaton_ats16_source_info, NULL },
/* ats2ConfigPreferred.0 = INTEGER: source1(1) */
{ "input.source.preferred", ST_FLAG_RW, 1, ".1.3.6.1.4.1.534.10.2.4.5.0", NULL, SU_FLAG_OK, NULL, NULL },
/* ats2InputDephasing = INTEGER: 181 */
{ "input.phase.shift", 0, 1, ".1.3.6.1.4.1.534.10.2.2.1.1.0", NULL, SU_FLAG_OK, NULL, NULL },

/* Output collection */
/* ats2OutputVoltage.0 = INTEGER: 2304 0.1 V */
Expand Down
13 changes: 0 additions & 13 deletions drivers/eaton-mib.h

This file was deleted.

89 changes: 89 additions & 0 deletions drivers/eaton-pdu-genesis2-mib.c
@@ -0,0 +1,89 @@
/* eaton-pdu-genesis2-mib.c - data to monitor Eaton ePDUs branded as:
* G1 Aphel based ePDUs (Basic) - GenesisII
*
* Copyright (C) 2008 - 2017
* Arnaud Quette <arnaud.quette@gmail.com>
* Arnaud Quette <ArnaudQuette@Eaton.com>
* Copyright (C) 2015 - 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 "eaton-pdu-genesis2-mib.h"

#define EATON_APHEL_GENESIS2_MIB_VERSION "0.49"

/* APHEL-GENESIS-II-MIB (monitored ePDU)
* *************************************
* Note: There is also a basic XML interface, but not worth
* implementing in netxml-ups!
*/

#define APHEL1_OID_MIB ".1.3.6.1.4.1.17373"
#define APHEL1_SYSOID APHEL1_OID_MIB
#define APHEL1_OID_MODEL_NAME ".1.3.6.1.4.1.17373.3.1.1.0"
#define APHEL1_OID_FIRMREV ".1.3.6.1.4.1.17373.3.1.2.0"
#define APHEL1_OID_DEVICE_NAME ".1.3.6.1.4.1.17373.3.1.3.0"
#define APHEL1_OID_UNIT_MACADDR ".1.3.6.1.4.1.17373.3.1.4.0"
/* needs concat .<outlet-index>.0 */
#define APHEL1_OID_OUTLET_CURRENT ".1.3.6.1.4.1.17373.3.2"

/* Snmp2NUT lookup table for GenesisII MIB */
static snmp_info_t eaton_aphel_genesisII_mib[] = {
/* Device page */
{ "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON | Powerware",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
{ "device.model", ST_FLAG_STRING, SU_INFOSIZE, APHEL1_OID_MODEL_NAME,
"Eaton Powerware ePDU Monitored", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
{ "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
{ "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, APHEL1_OID_UNIT_MACADDR, "unknown",
0, NULL, NULL },

/* UPS page */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON | Powerware",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, APHEL1_OID_MODEL_NAME,
"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
{ "ups.id", ST_FLAG_STRING, SU_INFOSIZE, APHEL1_OID_DEVICE_NAME,
"unknown", SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, APHEL1_OID_FIRMREV, "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL, NULL },
{ "ups.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL, NULL },

/* Outlet page */
/* we can't use template since there is no counterpart to outlet.count */
{ "outlet.1.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".1.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
{ "outlet.2.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".2.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
{ "outlet.3.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".3.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
{ "outlet.4.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".4.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
{ "outlet.5.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".5.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
{ "outlet.6.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".6.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
{ "outlet.7.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".7.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },
{ "outlet.8.current", 0, 0.1, APHEL1_OID_OUTLET_CURRENT ".8.0", NULL, SU_FLAG_NEGINVALID, NULL, NULL },

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


mib2nut_info_t aphel_genesisII = { "aphel_genesisII", EATON_APHEL_GENESIS2_MIB_VERSION, NULL, APHEL1_OID_MODEL_NAME, eaton_aphel_genesisII_mib, APHEL1_SYSOID };
32 changes: 32 additions & 0 deletions drivers/eaton-pdu-genesis2-mib.h
@@ -0,0 +1,32 @@
/* eaton-pdu-genesis2-mib.h - subdriver to monitor Eaton ePDU SNMP devices with NUT
*
* Copyright (C)
* 2010 Arjen de Korte <adkorte-guest@alioth.debian.org>
* 2011 - 2012 Arnaud Quette <arnaud.quette@free.fr>
* 2017 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_GENESIS_MIB_H
#define EATON_EPDU_GENESIS_MIB_H

#include "main.h"
#include "snmp-ups.h"

extern mib2nut_info_t aphel_genesisII;

#endif /* EATON_EPDU_GENESIS_MIB_H */

0 comments on commit 6ad3412

Please sign in to comment.