nut/drivers/raritan-pdu-mib.c

131 lines
6.4 KiB
C
Raw Normal View History

2010-03-25 23:20:59 +00:00
/* raritan-mib.c - data to monitor Raritan PDUs (Basic and Complex)
*
2022-06-29 10:37:36 +00:00
* Copyright (C) 2008-2019
2010-03-25 23:20:59 +00:00
* Arnaud Quette <ArnaudQuette@Eaton.com>
*
* Sponsored by Eaton <http://www.eaton.com>
* and 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 "raritan-pdu-mib.h"
2022-06-29 10:37:36 +00:00
#define RARITAN_MIB_VERSION "0.8"
2010-03-25 23:20:59 +00:00
/* Raritan MIB
2011-09-29 18:14:46 +00:00
* this one uses the same MIB as Eaton Revelation,
* but with a different entry point */
2010-03-25 23:20:59 +00:00
#define RARITAN_BASE_OID ".1.3.6.1.4.1.13742"
2011-09-29 18:14:46 +00:00
#define RARITAN_SYSOID RARITAN_BASE_OID
2010-03-25 23:20:59 +00:00
#define RARITAN_OID_MODEL_NAME ".1.3.6.1.4.1.13742.1.1.12.0"
2022-06-29 10:37:36 +00:00
#define DO_OFF "0"
#define DO_ON "1"
#define DO_CYCLE "2"
2010-03-25 23:20:59 +00:00
2022-06-29 10:37:36 +00:00
static info_lkp_t raritan_pdu_outlet_status_info[] = {
{ -1, "error", NULL, NULL },
{ 0, "off", NULL, NULL },
{ 1, "on", NULL, NULL },
{ 2, "cycling", NULL, NULL }, /* transitional status */
{ 0, NULL, NULL, NULL }
2010-03-25 23:20:59 +00:00
};
/* Snmp2NUT lookup table for Raritan MIB */
static snmp_info_t raritan_mib[] = {
2022-06-29 10:37:36 +00:00
/* 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 },
2010-03-25 23:20:59 +00:00
/* Device page */
{ "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Raritan",
2022-06-29 10:37:36 +00:00
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
{ "device.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.12.0",
2022-06-29 10:37:36 +00:00
"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
{ "device.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.2.0", "",
2022-06-29 10:37:36 +00:00
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
{ "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
2022-06-29 10:37:36 +00:00
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
2016-07-18 00:11:41 +00:00
{ "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.6.0", "",
2022-06-29 10:37:36 +00:00
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
/* UPS page */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Raritan",
2022-06-29 10:37:36 +00:00
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.12.0",
2022-06-29 10:37:36 +00:00
"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
{ "ups.id", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.13.0",
2022-06-29 10:37:36 +00:00
"unknown", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.2.0", "",
2022-06-29 10:37:36 +00:00
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
2010-03-25 23:20:59 +00:00
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.1.1.0", "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
2022-06-29 10:37:36 +00:00
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.temperature", 0, 1, ".1.3.6.1.4.1.13742.1.3.1.5.0", NULL, 0, NULL },
2010-03-25 23:20:59 +00:00
/* Outlet page */
{ "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",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "outlet.count", 0, 1, ".1.3.6.1.4.1.13742.1.2.1.0", "0", 0, NULL },
2022-06-29 10:37:36 +00:00
{ "outlet.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.1" ".0", NULL, 0, NULL },
{ "outlet.voltage", 0, 0.001, ".1.3.6.1.4.1.13742.1.3.1.2" ".0", NULL, 0, NULL },
{ "outlet.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.3" ".0", NULL, 0, NULL },
{ "outlet.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.3.1.4" ".0", NULL, 0, NULL },
2010-03-25 23:20:59 +00:00
/* outlet template definition
* Caution: the index of the data start at 0, while the name is +1
* ie outlet.1 => <OID>.0 */
2022-06-29 10:37:36 +00:00
{ "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, NULL },
{ "outlet.%i.id", 0, 1, NULL, "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK | SU_OUTLET, NULL },
{ "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.2.%i", NULL, SU_OUTLET, NULL },
{ "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", NULL, SU_FLAG_OK | SU_OUTLET, &raritan_pdu_outlet_status_info[0] },
{ "outlet.%i.current", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.4.%i", NULL, SU_OUTLET, NULL },
{ "outlet.%i.current.maximum", 0, 0.001, ".1.3.6.1.4.1.13742.1.2.2.1.5.%i", NULL, SU_OUTLET, NULL },
{ "outlet.%i.realpower", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.7.%i", NULL, SU_OUTLET, NULL },
{ "outlet.%i.voltage", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.6.%i", NULL, SU_OUTLET, NULL },
{ "outlet.%i.powerfactor", 0, 0.01, ".1.3.6.1.4.1.13742.1.2.2.1.9.%i", NULL, SU_OUTLET, NULL },
{ "outlet.%i.power", 0, 1.0, ".1.3.6.1.4.1.13742.1.2.2.1.8.%i", NULL, SU_OUTLET, NULL },
2010-03-25 23:20:59 +00:00
/* FIXME:
* - delay for startup/shutdown sequence
* - support for Ambient page
temperatureSensorCount" src="snmp:$sysoid.2.1.0
ambient.temperature src="snmp:$sysoid.2.2.1.3.$indiceSensor => seems dumb!
ambient.humidity src="snmp:$sysoid.2.4.1.3.$indiceSensor
*/
/* instant commands. */
/* Note that load.cycle might be replaced by / mapped on shutdown.reboot */
/* no counterpart found!
2022-06-29 10:37:36 +00:00
{ "outlet.load.off", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", DO_OFF, SU_TYPE_CMD, NULL },
{ "outlet.load.on", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", DO_ON, SU_TYPE_CMD, NULL },
{ "outlet.load.cycle", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.0", DO_CYCLE, SU_TYPE_CMD, NULL }, */
{ "outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", DO_OFF, SU_TYPE_CMD | SU_OUTLET, NULL },
{ "outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", DO_ON, SU_TYPE_CMD | SU_OUTLET, NULL },
{ "outlet.%i.load.cycle", 0, 1, ".1.3.6.1.4.1.13742.1.2.2.1.3.%i", DO_CYCLE, SU_TYPE_CMD | SU_OUTLET, NULL },
2010-03-25 23:20:59 +00:00
/* end of structure. */
2022-06-29 10:37:36 +00:00
{ NULL, 0, 0, NULL, NULL, 0, NULL }
2010-03-25 23:20:59 +00:00
};
2022-06-29 10:37:36 +00:00
mib2nut_info_t raritan = { "raritan", RARITAN_MIB_VERSION, NULL, RARITAN_OID_MODEL_NAME, raritan_mib, RARITAN_SYSOID, NULL };