Arnaud, Ivan,

Please find attached a set of patches that represent the changes I made
to fix the issue on NUT ver. 2.6.5.

At least, the UPS now properly reports "OL", "OB DISCHRG" and "OL CHRG"
when appropriate. Of course, it still won't report "Low Batt", as there
doesn't seem to be an OID for that any longer. I'll talk to HP about
that, as I have a support ticket open with them as well.

As you will see in my patch files, I've created a new subdriver called
"cpqpower76" in order for the code to remain backward compatible with
older versions of the MIB.

I'll post this to github as well.

HTH

Cheers. Bye.

Ph. A.


On 07/04/14 13:45, Philippe Andersson wrote:
> Hello Arnaud,
> 
> On 05/04/14 22:01, Arnaud Quette wrote:
>> Philippe, Ivan,
>>
>> please see https://github.com/networkupstools/nut/issues/118
>> and send back your data.
> I've pasted the requested files in github, but the auto-formatting may
> have damaged them, so here they are.
> 
> Also, when I ran gen-snmp-subdriver.sh, it gave me the following message:
> 
> -----------------------<cut>-------------------------
> snmp_build: unknown failuresnmpget: Error building ASN.1 representation
> (Can't build OID for variable)
> -----------------------<cut>-------------------------
> 
> Not sure whether this invalidates the resulting files.
> 
> Ph. A.
> 

-- 

*Philippe Andersson*
Unix System Administrator
IBA Particle Therapy |
Tel: +32-10-475.983
Fax: +32-10-487.707
eMail: p...@iba-group.com
<http://www.iba-worldwide.com>

--- compaq-mib.c	2012-07-31 19:38:59.000000000 +0200
+++ compaq-mib.c	2014-04-07 14:26:46.570307431 +0200
@@ -31,6 +31,7 @@
 #include "compaq-mib.h"
 
 #define CPQPOWER_MIB_VERSION	"1.5"
+#define CPQPOWER_MIB76_VERSION	"1.76"
 
 #define DEFAULT_ONDELAY			30
 #define DEFAULT_OFFDELAY		20
@@ -49,7 +50,7 @@
 #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_RUNTIME     ".1.3.6.1.4.1.232.165.3.2.1.0"	/* UPS-MIB::upsEstimatedSecondsRemaining */
 #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 */
@@ -323,5 +324,161 @@
 	{ NULL, 0, 0, NULL, NULL, 0, NULL }
 };
 
+static snmp_info_t cpqpower_mib76[] = {
+	/* UPS page */
+	/* info_type, info_flags, info_len, OID, dfl, flags, oid2info, setvar */
+	{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_MFR_NAME, "HP/Compaq", SU_FLAG_STATIC, NULL },
+	{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_MODEL_NAME, "SNMP UPS", SU_FLAG_STATIC, NULL },
+	/* { "ups.model.aux", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_OEMCODE, "", SU_FLAG_STATIC, NULL },*/
+	{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.232.165.1.2.7.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
+	/* FIXME: split between firmware and firmware.aux ("00.01.0019;00.01.0004")
+	 * UPS Firmware Revision :	00.01.0004
+	 * Communication Board Firmware Revision :	00.01.0019 */
+	{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_FIRMREV, "", SU_FLAG_STATIC, NULL },
+	{ "ups.load", 0, 1.0, CPQPOWER_OID_LOAD_LEVEL, "", 0, NULL },
+	{ "ups.realpower", 0, 1.0, CPQPOWER_OID_OUT_POWER, "", SU_OUTPUT_1, NULL },
+	{ "ups.realpower", 0, 1.0, ".1.3.6.1.4.1.232.165.3.9.3.0", "", SU_OUTPUT_1, NULL },
+	{ "ups.L1.realpower", 0, 0.1, CPQPOWER_OID_OUT_POWER ".1", "", SU_OUTPUT_3, NULL },
+	{ "ups.L2.realpower", 0, 0.1, CPQPOWER_OID_OUT_POWER ".2", "", SU_OUTPUT_3, NULL },
+	{ "ups.L3.realpower", 0, 0.1, CPQPOWER_OID_OUT_POWER ".3", "", SU_OUTPUT_3, NULL },
+	{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_POWER_STATUS, "OFF", SU_STATUS_PWR, cpqpower_pwr_info },
+	{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_BATT_STATUS, "", SU_STATUS_PWR, cpqpower_battery_abm_status },
+	/* The next two lines are no longer supported by MIB ver. 1.76 (PAN) */
+	/* { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_ALARM_OB, "", SU_STATUS_BATT, cpqpower_alarm_ob }, */
+	/* { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_ALARM_LB, "", SU_STATUS_BATT, cpqpower_alarm_lb }, */
+/*	{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_BATT_STATUS, "", SU_STATUS_BATT, ietf_batt_info }, */
+	/* FIXME: this should use either .1.3.6.1.4.1.232.165.3.11.1.0 (upsTopologyType)
+	 * or .1.3.6.1.4.1.232.165.3.11.2.0 (upsTopoMachineCode) */
+	{ "ups.type", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_POWER_STATUS, "", SU_STATUS_PWR, cpqpower_mode_info },
+	{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, CPQPOWER_OID_UPS_TEST_RES, "", 0, cpqpower_test_res_info },
+	/* FIXME: handle ups.date and ups.time
+	 * - OID: .1.3.6.1.4.1.232.165.3.9.5.0
+	 * - format MM/DD/YYYY HH:MM:SS */
+	/* FIXME: handle upsInputSource.0 (".1.3.6.1.4.1.232.165.3.3.5.0")
+	 * other(1)
+	 * none(2)
+	 * primaryUtility(3)
+	 * bypassFeed(4)
+	 * secondaryUtility(5)
+	 * generator(6)
+	 * flywheel(7)
+	 * fuelcell(8) */
+
+	{ "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.8.1.0", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
+	{ "ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.8.2.0", STR_DEFAULT_ONDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
+	{ "ups.timer.shutdown", 0, 1, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_FLAG_OK, NULL },
+	{ "ups.timer.start", 0, 1, ".1.3.6.1.4.1.232.165.3.8.2.0", "", SU_FLAG_OK, NULL },
+
+	/* Ambient page */
+	{ "ambient.temperature", 0, 1.0, CPQPOWER_OID_AMBIENT_TEMP, "", 0, NULL },
+	{ "ambient.temperature.low", 0, 1.0, ".1.3.6.1.4.1.232.165.3.6.2.0", "", 0, NULL },
+	{ "ambient.temperature.high", 0, 1.0, ".1.3.6.1.4.1.232.165.3.6.3.0", "", 0, NULL },
+
+	/* Battery page */
+	{ "battery.charge", 0, 1.0, CPQPOWER_OID_BATT_CHARGE, "", 0, NULL },
+	{ "battery.runtime", 0, 1.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 },
+	/* FIXME: need the new variable (for ABM)
+	{ "battery.status", 0, 0.1, ".1.3.6.1.4.1.232.165.3.2.5.0", "", 0, NULL }, */
+
+	/* Input page */
+	{ "input.phases", 0, 1.0, CPQPOWER_OID_IN_LINES, "", SU_FLAG_SETINT, NULL, &input_phases },
+/*	{ "input.phase", 0, 1.0, CPQPOWER_OID_IN_PHASE, "", SU_OUTPUT_1, NULL }, */
+	{ "input.frequency", 0, 0.1, CPQPOWER_OID_IN_FREQ , "", 0, NULL },
+	{ "input.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE, "", SU_OUTPUT_1, NULL },
+	{ "input.voltage", 0, 1.0, ".1.3.6.1.4.1.232.165.3.3.4.1.2.1", "", SU_OUTPUT_1, NULL },
+	{ "input.voltage.nominal", ST_FLAG_RW | ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.9.2.0", "", SU_OUTPUT_1, NULL },
+	{ "input.L1-N.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE ".1", "", SU_INPUT_3, NULL },
+	{ "input.L2-N.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE ".2", "", SU_INPUT_3, NULL },
+	{ "input.L3-N.voltage", 0, 1.0, CPQPOWER_OID_IN_VOLTAGE ".3", "", SU_INPUT_3, NULL },
+	{ "input.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT, "", SU_OUTPUT_1, NULL },
+	{ "input.current", 0, 0.1, ".1.3.6.1.4.1.232.165.3.3.4.1.3.1", "", SU_OUTPUT_1, NULL },
+
+	{ "input.L1.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT ".1", "", SU_INPUT_3, NULL },
+	{ "input.L2.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT ".2", "", SU_INPUT_3, NULL },
+	{ "input.L3.current", 0, 0.1, CPQPOWER_OID_IN_CURRENT ".3", "", SU_INPUT_3, NULL },
+	{ "input.realpower", 0, 0.1, CPQPOWER_OID_IN_POWER, "", SU_OUTPUT_1, NULL },
+	{ "input.L1.realpower", 0, 0.1, CPQPOWER_OID_IN_POWER ".1", "", SU_INPUT_3, NULL },
+	{ "input.L2.realpower", 0, 0.1, CPQPOWER_OID_IN_POWER ".2", "", SU_INPUT_3, NULL },
+	{ "input.L3.realpower", 0, 0.1, CPQPOWER_OID_IN_POWER ".3", "", SU_INPUT_3, NULL },
+	{ "input.quality", 0, 1.0, CPQPOWER_OID_IN_LINEBADS, "", 0, NULL },
+
+	/* Output page */
+	{ "output.phases", 0, 1.0, CPQPOWER_OID_OUT_LINES, "", SU_FLAG_SETINT, NULL, &output_phases },
+/*	{ "output.phase", 0, 1.0, CPQPOWER_OID_OUT_PHASE, "", SU_OUTPUT_1, NULL }, */
+	{ "output.frequency", 0, 0.1, CPQPOWER_OID_OUT_FREQUENCY, "", 0, NULL },
+	/* FIXME: handle multiplier (0.1 there) */
+	{ "output.frequency.nominal", ST_FLAG_RW | ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.9.4.0", "", SU_OUTPUT_1, NULL },
+	{ "output.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE, "", SU_OUTPUT_1, NULL },
+	{ "output.voltage", 0, 1.0, ".1.3.6.1.4.1.232.165.3.4.4.1.2.1", "", SU_OUTPUT_1, NULL },
+	{ "output.voltage.nominal", ST_FLAG_RW | ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.9.1.0", "", SU_OUTPUT_1, NULL },
+	{ "output.L1-N.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE ".1", "", SU_OUTPUT_3, NULL },
+	{ "output.L2-N.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE ".2", "", SU_OUTPUT_3, NULL },
+	{ "output.L3-N.voltage", 0, 1.0, CPQPOWER_OID_OUT_VOLTAGE ".3", "", SU_OUTPUT_3, NULL },
+	{ "output.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT, "", SU_OUTPUT_1, NULL },
+	{ "output.current", 0, 0.1, ".1.3.6.1.4.1.232.165.3.4.4.1.3.1", "", SU_OUTPUT_1, NULL },
+	/* { "output.realpower", 0, 1.0, ".1.3.6.1.4.1.232.165.3.4.4.1.4", "", SU_OUTPUT_1, NULL }, */
+	{ "output.L1.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT ".1", "", SU_OUTPUT_3, NULL },
+	{ "output.L2.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT ".2", "", SU_OUTPUT_3, NULL },
+	{ "output.L3.current", 0, 0.1, CPQPOWER_OID_OUT_CURRENT ".3", "", SU_OUTPUT_3, NULL },
+
+	/* FIXME: what to map with these?
+	 * Name/OID: upsConfigLowOutputVoltageLimit.0; Value (Integer): 160
+	 * => input.transfer.low?
+	 * Name/OID: upsConfigHighOutputVoltageLimit.0; Value (Integer): 288
+	 * => input.transfer.high? */
+
+	/* 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.232.165.3.10.1.0", "0", 0, NULL }, /* upsNumReceptacles */
+
+/*	{ "outlet.current", 0, 0.001, AR_OID_UNIT_CURRENT ".0", NULL, 0, NULL, NULL },
+	{ "outlet.voltage", 0, 0.001, AR_OID_UNIT_VOLTAGE ".0", NULL, 0, NULL, NULL },
+	{ "outlet.realpower", 0, 1.0, AR_OID_UNIT_ACTIVEPOWER ".0", NULL, 0, NULL, NULL },
+	{ "outlet.power", 0, 1.0, AR_OID_UNIT_APPARENTPOWER ".0", NULL, 0, NULL, NULL }, */
+
+	/* outlet template definition */
+	/* FIXME always true? */
+	{ "outlet.%i.switchable", ST_FLAG_STRING, 3, ".1.3.6.1.4.1.232.165.3.10.2.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, &cpqpower_outlet_switchability_info[0], NULL },
+	{ "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.232.165.3.10.2.1.1.%i", "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK | SU_OUTLET, NULL, NULL },
+	/* { "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, AR_OID_OUTLET_NAME ".%i", NULL, SU_OUTLET, NULL, NULL }, */
+	{ "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.232.165.3.10.2.1.2.%i", NULL, SU_FLAG_OK | SU_OUTLET, &cpqpower_outlet_status_info[0], NULL },
+	/* FIXME: come up with a suitable varname!
+	 * - The delay after going On Battery until the Receptacle is automatically turned Off.
+	 * A value of -1 means that this Output should never be turned Off automatically, but must be turned Off only by command.
+	 * { "outlet.%i.autoswitch.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.10.2.1.5.%i", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, // upsRecepAutoOffDelay
+	 * - Seconds delay after the Outlet is signaled to turn On before the Output is Automatically turned ON.
+	 * A value of -1 means that this Output should never be turned On automatically, but only when specifically commanded to do so.
+	 * { "outlet.%i.autoswitch.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 6, ".1.3.6.1.4.1.232.165.3.10.2.1.5.%i", STR_DEFAULT_OFFDELAY, SU_FLAG_ABSENT | SU_FLAG_OK, NULL }, // upsRecepAutoOnDelay
+	 */
+	/* FIXME: also define .stop (as for 'shutdown.reboot')
+	 * and .delay */
+	{ "outlet.%i.load.off", 0, 0, ".1.3.6.1.4.1.232.165.3.10.2.1.3.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
+	{ "outlet.%i.load.on", 0, 0, ".1.3.6.1.4.1.232.165.3.10.2.1.4.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
+	/* FIXME: also define a .delay or map to "outlet.%i.delay.shutdown" */
+	{ "outlet.%i.load.cycle", 0, 0, ".1.3.6.1.4.1.232.165.3.10.2.1.7.%i", NULL, SU_TYPE_CMD | SU_OUTLET, NULL, NULL },
+
+	/* instant commands. */
+	/* We need to duplicate load.{on,off} Vs load.{on,off}.delay, since
+	 * "0" cancels the shutdown, so we put "1" (second) for immediate off! */
+	{ "load.off", 0, 1, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_TYPE_CMD, NULL },
+	{ "load.on", 0, 1, ".1.3.6.1.4.1.232.165.3.8.2.0", "", SU_TYPE_CMD, NULL },
+	{ "shutdown.stop", 0, 0, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	/* FIXME: need ups.{timer,delay}.{start,shutdown} param counterparts! */
+
+	{ "load.off.delay", 0, DEFAULT_OFFDELAY, ".1.3.6.1.4.1.232.165.3.8.1.0", "", SU_TYPE_CMD, NULL },
+	{ "load.on.delay", 0, DEFAULT_ONDELAY, ".1.3.6.1.4.1.232.165.3.8.2.0", "", SU_TYPE_CMD, NULL },
+	/*	{ CMD_SHUTDOWN, 0, CPQPOWER_OFF_GRACEFUL, CPQPOWER_OID_OFF, "", 0, NULL }, */
+	{ "shutdown.reboot", 0, 0, ".1.3.6.1.4.1.232.165.3.8.6.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "test.battery.start", 0, CPQPOWER_START_TEST, ".1.3.6.1.4.1.232.165.3.7.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+
+	/* end of structure. */
+	{ NULL, 0, 0, NULL, NULL, 0, NULL }
+};
+
 mib2nut_info_t	compaq = { "cpqpower", CPQPOWER_MIB_VERSION, "", CPQPOWER_OID_MFR_NAME, cpqpower_mib, CPQPOWER_SYSOID };
+mib2nut_info_t	compaq76 = { "cpqpower76", CPQPOWER_MIB76_VERSION, "", CPQPOWER_OID_MFR_NAME, cpqpower_mib76, CPQPOWER_SYSOID };
 
--- compaq-mib.h	2012-07-31 19:38:59.000000000 +0200
+++ compaq-mib.h	2014-04-07 14:27:20.151488579 +0200
@@ -5,5 +5,6 @@
 #include "snmp-ups.h"
 
 extern mib2nut_info_t	compaq;
+extern mib2nut_info_t	compaq76;
 
 #endif /* COMPAQ_MIB_H */
--- snmp-ups.c	2012-07-31 19:38:59.000000000 +0200
+++ snmp-ups.c	2014-04-07 14:27:57.486689844 +0200
@@ -65,6 +65,7 @@
 	&raritan,
 	&baytech,
 	&compaq,
+	&compaq76,
 	&bestpower,
 	&cyberpower,
 	/*

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to