Hi Folks,
I've tested and tidied it up. Please accept this contribution for
consideration. The patch for snmp-ups.c is against the latest (at 10 am
GMT) svn.
Any changes you'd like made and tested, please let me know.
Regards,
-
Philip Ward
Unix Systems Administrator
Ext 7274
--
The Sunday Times Scottish University of the Year 2009/2010
The University of Stirling is a charity registered in Scotland,
number SC 011159.
/* cpqpowermib.h - data to monitor SNMP UPS with NUT
*
* Copyright (C) 2002-2006
* Arnaud Quette <[email protected]>
* Niels Baggesen <[email protected]>
* Philip Ward <[email protected]>
*
* Sponsored by MGE UPS SYSTEMS <http://www.mgeups.com>
*
* This version has been tested using an HP R5500XR UPS with AF401A
* management card and a single phase input.
*
* 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
*
*/
#define CPQPOWER_MIB_VERSION "1.0"
/* SNMP OIDs set */
#define CPQPOWER_OID_UPS_MIB "1.3.6.1.4.1.232.165.3"
#define CPQPOWER_OID_MFR_NAME "1.3.6.1.4.1.232.165.3.1.1.0" /* UPS-MIB::upsIdentManufacturer */
#define CPQPOWER_OID_MODEL_NAME "1.3.6.1.4.1.232.165.3.1.2.0" /* UPS-MIB::upsIdentModel */
#define CPQPOWER_OID_FIRMREV "1.3.6.1.4.1.232.165.3.1.3.0" /* UPS-MIB::upsIdentUPSSoftwareVersion */
#define CPQPOWER_OID_OEMCODE "1.3.6.1.4.1.232.165.3.1.4.0" /* UPS-MIB::upsIdentAgentSoftwareVersion */
#define CPQPOWER_OID_BATT_RUNTIME "1.3.6.1.4.1.232.165.3.2.1.0" /* UPS-MIB::upsEstimatedMinutesRemaining */
#define CPQPOWER_OID_BATT_VOLTAGE "1.3.6.1.4.1.232.165.3.2.2.0" /* UPS-MIB::upsBatteryVoltage */
#define CPQPOWER_OID_BATT_CURRENT "1.3.6.1.4.1.232.165.3.2.3.0" /* UPS-MIB::upsBatteryCurrent */
#define CPQPOWER_OID_BATT_CHARGE "1.3.6.1.4.1.232.165.3.2.4.0" /* UPS-MIB::upsBattCapacity */
#define CPQPOWER_OID_BATT_STATUS "1.3.6.1.4.1.232.165.3.2.5.0" /* UPS-MIB::upsBatteryAbmStatus */
#define CPQPOWER_OID_IN_FREQ "1.3.6.1.4.1.232.165.3.3.1.0" /* UPS-MIB::upsInputFrequency */
#define CPQPOWER_OID_IN_LINEBADS "1.3.6.1.4.1.232.165.3.3.2.0" /* UPS-MIB::upsInputLineBads */
#define CPQPOWER_OID_IN_LINES "1.3.6.1.4.1.232.165.3.3.3.0" /* UPS-MIB::upsInputNumPhases */
#define CPQPOWER_OID_IN_PHASE "1.3.6.1.4.1.232.165.3.3.4.1.1" /* UPS-MIB::upsInputPhase */
#define CPQPOWER_OID_IN_VOLTAGE "1.3.6.1.4.1.232.165.3.3.4.1.2" /* UPS-MIB::upsInputVoltage */
#define CPQPOWER_OID_IN_CURRENT "1.3.6.1.4.1.232.165.3.3.4.1.3" /* UPS-MIB::upsInputCurrent */
#define CPQPOWER_OID_IN_POWER "1.3.6.1.4.1.232.165.3.3.4.1.4" /* UPS-MIB::upsInputWatts */
#define CPQPOWER_OID_LOAD_LEVEL "1.3.6.1.4.1.232.165.3.4.1.0" /* UPS-MIB::upsOutputLoad */
#define CPQPOWER_OID_OUT_FREQUENCY "1.3.6.1.4.1.232.165.3.4.2.0" /* UPS-MIB::upsOutputFrequency */
#define CPQPOWER_OID_OUT_LINES "1.3.6.1.4.1.232.165.3.4.3.0" /* UPS-MIB::upsOutputNumPhases */
#define CPQPOWER_OID_OUT_PHASE "1.3.6.1.4.1.232.165.3.4.4.1.1" /* UPS-MIB::upsOutputPhase */
#define CPQPOWER_OID_OUT_VOLTAGE "1.3.6.1.4.1.232.165.3.4.4.1.2" /* UPS-MIB::upsOutputVoltage */
#define CPQPOWER_OID_OUT_CURRENT "1.3.6.1.4.1.232.165.3.4.4.1.3" /* UPS-MIB::upsOutputCurrent */
#define CPQPOWER_OID_OUT_POWER "1.3.6.1.4.1.232.165.3.4.4.1.4" /* UPS-MIB::upsOutputWatts */
#define CPQPOWER_OID_POWER_STATUS "1.3.6.1.4.1.232.165.3.4.5.0" /* UPS-MIB::upsOutputSource */
#define CPQPOWER_OID_AMBIENT_TEMP "1.3.6.1.4.1.232.165.3.6.1.0" /* UPS-MIB::upsEnvAmbientTemp */
#define CPQPOWER_OID_UPS_TEST_BATT "1.3.6.1.4.1.232.165.3.7.1.0" /* UPS-MIB::upsTestBattery */
#define CPQPOWER_OID_UPS_TEST_RES "1.3.6.1.4.1.232.165.3.7.2.0" /* UPS-MIB::upsTestBatteryStatus */
/* Defines for CPQPOWER_OID_POWER_STATUS (1) */
info_lkp_t cpqpower_pwr_info[] = {
{ 1, "" /* other */ },
{ 2, "OFF" /* none */ },
{ 3, "OL" /* normal */ },
{ 4, "BYPASS" /* bypass */ },
{ 5, "OB" /* battery */ },
{ 6, "BOOST" /* booster */ },
{ 7, "TRIM" /* reducer */ },
{ 8, "PCAP" /* parallelCapacity */ },
{ 9, "PRED" /* parallelRedundant */ },
{ 10, "HIEFF" /* HighEfficiencyMode */ },
{ 0, "NULL" }
} ;
/* Defines for CPQPOWER_OID_BATT_STATUS (2) */
info_lkp_t cpqpower_batt_info[] = {
{ 100, "" /* batteryNormal */ },
{ 99, "" /* batteryNormal */ },
{ 98, "" /* batteryNormal */ },
{ 97, "" /* batteryNormal */ },
{ 96, "" /* batteryNormal */ },
{ 95, "" /* batteryNormal */ },
{ 94, "" /* batteryNormal */ },
{ 93, "" /* batteryNormal */ },
{ 92, "" /* batteryNormal */ },
{ 91, "" /* batteryNormal */ },
{ 90, "" /* batteryNormal */ },
{ 89, "" /* batteryNormal */ },
{ 88, "" /* batteryNormal */ },
{ 87, "" /* batteryNormal */ },
{ 86, "" /* batteryNormal */ },
{ 85, "" /* batteryNormal */ },
{ 84, "" /* batteryNormal */ },
{ 83, "" /* batteryNormal */ },
{ 82, "" /* batteryNormal */ },
{ 81, "" /* batteryNormal */ },
{ 80, "" /* batteryNormal */ },
{ 79, "" /* batteryNormal */ },
{ 78, "" /* batteryNormal */ },
{ 77, "" /* batteryNormal */ },
{ 76, "" /* batteryNormal */ },
{ 75, "" /* batteryNormal */ },
{ 74, "" /* batteryNormal */ },
{ 73, "" /* batteryNormal */ },
{ 72, "" /* batteryNormal */ },
{ 71, "" /* batteryNormal */ },
{ 70, "" /* batteryNormal */ },
{ 69, "" /* batteryNormal */ },
{ 68, "" /* batteryNormal */ },
{ 67, "" /* batteryNormal */ },
{ 66, "" /* batteryNormal */ },
{ 65, "" /* batteryNormal */ },
{ 64, "" /* batteryNormal */ },
{ 63, "" /* batteryNormal */ },
{ 62, "" /* batteryNormal */ },
{ 61, "" /* batteryNormal */ },
{ 60, "" /* batteryNormal */ },
{ 59, "" /* batteryNormal */ },
{ 58, "" /* batteryNormal */ },
{ 57, "" /* batteryNormal */ },
{ 56, "" /* batteryNormal */ },
{ 55, "" /* batteryNormal */ },
{ 54, "" /* batteryNormal */ },
{ 53, "" /* batteryNormal */ },
{ 52, "" /* batteryNormal */ },
{ 51, "" /* batteryNormal */ },
{ 50, "" /* batteryNormal */ },
{ 49, "" /* batteryNormal */ },
{ 48, "" /* batteryNormal */ },
{ 47, "" /* batteryNormal */ },
{ 46, "" /* batteryNormal */ },
{ 45, "" /* batteryNormal */ },
{ 44, "" /* batteryNormal */ },
{ 43, "" /* batteryNormal */ },
{ 42, "" /* batteryNormal */ },
{ 41, "" /* batteryNormal */ },
{ 40, "" /* batteryNormal */ },
{ 39, "" /* batteryNormal */ },
{ 38, "" /* batteryNormal */ },
{ 37, "" /* batteryNormal */ },
{ 36, "" /* batteryNormal */ },
{ 35, "" /* batteryNormal */ },
{ 34, "" /* batteryNormal */ },
{ 33, "" /* batteryNormal */ },
{ 32, "" /* batteryNormal */ },
{ 31, "" /* batteryNormal */ },
{ 30, "" /* batteryNormal */ },
{ 29, "" /* batteryNormal */ },
{ 28, "" /* batteryNormal */ },
{ 27, "" /* batteryNormal */ },
{ 26, "" /* batteryNormal */ },
{ 25, "" /* batteryNormal */ },
{ 24, "" /* batteryNormal */ },
{ 23, "" /* batteryNormal */ },
{ 22, "" /* batteryNormal */ },
{ 21, "" /* batteryNormal */ },
{ 20, "LB" /* batteryLow */ },
{ 19, "LB" /* batteryLow */ },
{ 18, "LB" /* batteryLow */ },
{ 17, "LB" /* batteryLow */ },
{ 16, "LB" /* batteryLow */ },
{ 15, "LB" /* batteryLow */ },
{ 14, "LB" /* batteryLow */ },
{ 13, "LB" /* batteryLow */ },
{ 12, "LB" /* batteryLow */ },
{ 11, "LB" /* batteryLow */ },
{ 10, "LB" /* batteryLow */ },
{ 9, "LB" /* batteryLow */ },
{ 8, "LB" /* batteryLow */ },
{ 7, "LB" /* batteryLow */ },
{ 6, "LB" /* batteryLow */ },
{ 5, "LB" /* batteryLow */ },
{ 4, "LB" /* batteryLow */ },
{ 3, "LB" /* batteryLow */ },
{ 2, "LB" /* batteryLow */ },
{ 1, "LB" /* batteryLow */ },
} ;
/* Defines for CPQPOWER_OID_TEST_RES */
info_lkp_t cpqpower_test_res_info[] = {
{ 1, "Unknown" },
{ 2, "Done and passed" },
{ 3, "Done and error" },
{ 4, "In progress" },
{ 5, "Not supported" },
{ 6, "Inhibited" },
{ 7, "Scheduled" },
{ 0, "NULL" }
} ;
#define CPQPOWER_OID_SD_AFTER_DELAY "1.3.6.1.4.1.232.165.3.8.1.0" /* UPS-MIB::upsShutdownAfterDelay */
#define CPQPOWER_OFF_DO 0
/* Snmp2NUT lookup table */
snmp_info_t cpqpower_mib[] = {
/* UPS page */
/* info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_MFR_NAME, "Generic",
SU_FLAG_STATIC, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_MODEL_NAME, "Generic SNMP UPS",
SU_FLAG_STATIC, NULL },
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_FIRMREV, "",
SU_FLAG_STATIC, NULL },
{ "ups.oemcode", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_OEMCODE, "",
SU_FLAG_STATIC, NULL },
{ "ups.load", 0, 1.0, CPQPOWER_OID_LOAD_LEVEL, "",
SU_OUTPUT_1, NULL },
{ "ups.power", 0, 1.0, CPQPOWER_OID_OUT_POWER, "",
SU_OUTPUT_1, NULL },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_POWER_STATUS, "OFF",
SU_STATUS_PWR, &cpqpower_pwr_info[0] },
{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_BATT_CHARGE, "",
SU_STATUS_BATT, &cpqpower_batt_info[0] },
{ "ambient.temperature", 0, 1.0, CPQPOWER_OID_AMBIENT_TEMP, "",
0, NULL },
/* Battery page */
{ "battery.charge", 0, 1.0, CPQPOWER_OID_BATT_CHARGE, "",
0, NULL },
{ "battery.runtime", 0, 60.0, CPQPOWER_OID_BATT_RUNTIME, "",
0, NULL },
{ "battery.voltage", 0, 0.1, CPQPOWER_OID_BATT_VOLTAGE, "",
0, NULL },
{ "battery.current", 0, 0.1, CPQPOWER_OID_BATT_CURRENT, "",
0, NULL },
/* Output page */
{ "output.phases", 0, 1.0, CPQPOWER_OID_OUT_LINES, "",
SU_FLAG_SETINT, NULL, &output_phases },
{ "output.frequency", 0, 0.1, CPQPOWER_OID_OUT_FREQUENCY, "",
0, NULL },
{ "output.phase", 0, 1.0, CPQPOWER_OID_OUT_PHASE, "",
0, NULL },
{ "output.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE, "",
0, NULL },
{ "output.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT, "",
0, NULL },
{ "output.realpower", 0, 1.0, CPQPOWER_OID_OUT_POWER, "",
0, NULL },
{ "output.power.percent", 0, 1.0, CPQPOWER_OID_LOAD_LEVEL , "",
0, NULL },
/* Input page */
{ "input.phases", 0, 1.0, CPQPOWER_OID_IN_LINES, "",
SU_FLAG_SETINT, NULL, &input_phases },
{ "input.frequency", 0, 0.1, CPQPOWER_OID_IN_FREQ , "",
0, NULL },
{ "input.phase", 0, 1.0, CPQPOWER_OID_IN_PHASE, "",
0, NULL },
{ "input.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE, "",
0, NULL },
{ "input.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT, "",
0, NULL },
{ "input.quality", 0, 1.0, CPQPOWER_OID_IN_LINEBADS, "",
0, NULL },
/* instant commands. */
{ "load.off", 0, CPQPOWER_OFF_DO, CPQPOWER_OID_SD_AFTER_DELAY, "",
SU_TYPE_CMD, NULL },
/* { CMD_SHUTDOWN, 0, CPQPOWER_OFF_GRACEFUL, CPQPOWER_OID_OFF, "", 0, NULL }, */
/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL }
};
--- snmp-ups.c.old 2010-02-01 10:02:38.000000000 +0000
+++ snmp-ups.c 2010-02-01 10:06:05.000000000 +0000
@@ -43,6 +43,7 @@
#include "netvisionmib.h"
#include "pwmib.h"
#include "baytechmib.h"
+#include "cpqpowermib.h"
mib2nut_info_t mib2nut[] = {
@@ -62,6 +63,8 @@
RARITAN_OID_MODEL_NAME, raritan_mib },
{ "baytech", BAYTECH_MIB_VERSION, "",
BAYTECH_OID_MODEL_NAME, baytech_mib },
+ { "cpqpower", CPQPOWER_MIB_VERSION, "",
+ CPQPOWER_OID_MFR_NAME, cpqpower_mib },
/*
* Prepend vendor specific MIB mappings before IETF, so that
* if a device supports both IETF and vendor specific MIB,
@@ -186,7 +189,7 @@
upsdebugx(1, "entering upsdrv_makevartable()");
addvar(VAR_VALUE, SU_VAR_MIBS,
- "Set MIB compliance (default=ietf, allowed mge,apcc,netvision,pw)");
+ "Set MIB compliance (default=ietf, allowed mge,apcc,netvision,pw,cpqpower)");
addvar(VAR_VALUE | VAR_SENSITIVE, SU_VAR_COMMUNITY,
"Set community name (default=public)");
addvar(VAR_VALUE, SU_VAR_VERSION,
_______________________________________________
Nut-upsdev mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev