[Nut-upsdev] snmp-ups hacking

Niklas Edmundsson nikke at acc.umu.se
Tue Jan 24 13:36:01 UTC 2006


On Sun, 22 Jan 2006, Niklas Edmundsson wrote:

> Hi all!
>
> I'm wondering if there's anyone doing any hacking on the snmp-ups driver at 
> the moment.

Obviously not, since noone has replied to my mail.

> I've started looking at implementing 3phase-support, and this uncovered some 
> rather unpleasant stuff in the snmp-ups driver that I really need to fix in 
> order to get things sane.

Attached is a patch that does the following:
* Changes snmp-ups to use SNMP_MSG_GET instead of SNMP_MSG_GETNEXT.
* Rips out the kludges caused by using getnext instead of get.
* Fixes a couple of bugs and missing features in snmp-ups.
* Updates the APC mib to work and report 3phase values.
* Updates the other mibs to hopefully work, needs testing by people
   with hardware.

The intent of submitting this patch to the list is to get feedback. If 
noone has any objections I will continue work on it to include a patch 
for new-names.txt that includes the documentation of the 3phase 
related stuff.

Below is the output from our APC Silcon 120kW (3phase-3phase):
--------------8<-------------
ambient.humidity: 032.0
ambient.temperature: 025.0
battery.charge: 100.0
battery.charge.low: 120
battery.charge.restart: 0
battery.runtime: 1080.0
battery.voltage: 439.0
driver.name: snmp-ups
driver.parameter.mibs: apcc
driver.parameter.port: ups.hpc2n.umu.se
driver.parameter.snmp_version: v1
driver.version: 2.1.0
driver.version.internal: 0.41
input.frequency: 000.0
input.L1-L2.voltage: 393.0
input.L1-L2.voltage.maximum: 413.0
input.L1-L2.voltage.minimum: 000.0
input.L1.current: 137.0
input.L1.current.maximum: 160.0
input.L1.current.minimum: 000.0
input.L2-L3.voltage: 397.0
input.L2-L3.voltage.maximum: 499.0
input.L2-L3.voltage.minimum: 000.0
input.L2.current: 154.0
input.L2.current.maximum: 178.0
input.L2.current.minimum: 000.0
input.L3-L1.voltage: 390.0
input.L3-L1.voltage.maximum: 409.0
input.L3-L1.voltage.minimum: 000.0
input.L3.current: 146.0
input.L3.current.maximum: 170.0
input.L3.current.minimum: 000.0
input.phases: 3
input.sensitivity: high
input.transfer.high: 460
input.transfer.low: 340
input.voltage: 227.0
output.current: 099.0
output.frequency: 051.0
output.L1-L2.voltage: 403.0
output.L1.current: 133.0
output.L1.current.maximum: 154.0
output.L1.current.minimum: 002.0
output.L1.power: 30900.0
output.L1.power.maximum: 36100.0
output.L1.power.maximum.percent: 090.0
output.L1.power.minimum: 500.0
output.L1.power.minimum.percent: 001.0
output.L1.power.percent: 077.0
output.L2-L3.voltage: 402.0
output.L2.current: 153.0
output.L2.current.maximum: 178.0
output.L2.current.minimum: 002.0
output.L2.power: 35300.0
output.L2.power.maximum: 41300.0
output.L2.power.maximum.percent: 103.0
output.L2.power.minimum: 500.0
output.L2.power.minimum.percent: 001.0
output.L2.power.percent: 088.0
output.L3-L1.voltage: 400.0
output.L3.current: 141.0
output.L3.current.maximum: 154.0
output.L3.current.minimum: 002.0
output.L3.power: 32600.0
output.L3.power.maximum: 35700.0
output.L3.power.maximum.percent: 089.0
output.L3.power.minimum: 500.0
output.L3.power.minimum.percent: 001.0
output.L3.power.percent: 081.0
output.phases: 3
output.voltage: 231.0
output.voltage.target.battery: 400
ups.delay.shutdown: 20
ups.delay.start: 0
ups.firmware: 329.15.I
ups.load: 088.0
ups.mfr: APC
ups.mfr.date: 00/00/00
ups.model: Silcon DP3120E
ups.serial: JA0323051572
ups.status: OL
ups.temperature: 021.0
ups.test.result: InvalidTest
--------------8<-------------

/Nikke
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  Niklas Edmundsson, Admin @ {acc,hpc2n}.umu.se      |     nikke at acc.umu.se
---------------------------------------------------------------------------
  Q-Tip: Advice from the Continuum.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-------------- next part --------------
Index: drivers/apccmib.h
===================================================================
RCS file: /cvsroot/nut/nut/drivers/apccmib.h,v
retrieving revision 1.1.1.1.8.1.2.1
diff -u -r1.1.1.1.8.1.2.1 apccmib.h
--- drivers/apccmib.h	28 Jun 2005 15:04:38 -0000	1.1.1.1.8.1.2.1
+++ drivers/apccmib.h	24 Jan 2006 13:04:24 -0000
@@ -25,15 +25,9 @@
 
 #define APCC_MIB_VERSION	"1.1"
 
-/* SNMP OIDs set */
-#define APCC_OID_POWERNET_MIB	".1.3.6.1.4.1.318"
 /* info elements */
-#define APCC_OID_MODEL_NAME		".1.3.6.1.4.1.318.1.1.1.1.1.1"
-#define APCC_OID_UPSIDEN		".1.3.6.1.4.1.318.1.1.1.1.1.2"
-#define APCC_OID_FIRMREV		".1.3.6.1.4.1.318.1.1.1.1.2.1"
-#define APCC_OID_MFRDATE		".1.3.6.1.4.1.318.1.1.1.1.2.2"
-#define APCC_OID_SERIAL			".1.3.6.1.4.1.318.1.1.1.1.2.3"
-#define APCC_OID_BATT_STATUS	".1.3.6.1.4.1.318.1.1.1.2.1.1"
+
+#define APCC_OID_BATT_STATUS	".1.3.6.1.4.1.318.1.1.1.2.1.1.0"
 /* Defines for APCC_OID_BATT_STATUS */
 info_lkp_t apcc_batt_info[] = {
 	{ 1, "" },	/* unknown */
@@ -42,57 +36,61 @@
 	{ 0, "NULL" }
 } ;
 
-#define APCC_OID_BATTDATE		".1.3.6.1.4.1.318.1.1.1.2.1.3"
-#define APCC_OID_BATT_CHARGE	".1.3.6.1.4.1.318.1.1.1.2.2.1"
-#define APCC_OID_UPSTEMP		".1.3.6.1.4.1.318.1.1.1.2.2.2"
-#define APCC_OID_BATT_RUNTIME	".1.3.6.1.4.1.318.1.1.1.2.2.3"
-#define APCC_OID_INVOLT			".1.3.6.1.4.1.318.1.1.1.3.2.1"
-#define APCC_OID_INFREQ			".1.3.6.1.4.1.318.1.1.1.3.2.4"
-#define APCC_OID_POWER_STATUS	".1.3.6.1.4.1.318.1.1.1.4.1.1"
-
+#define APCC_OID_POWER_STATUS	".1.3.6.1.4.1.318.1.1.1.4.1.1.0"
 /* Defines for APCC_OID_POWER_STATUS */
 info_lkp_t apcc_pwr_info[] = {
-	{ 1, "" },		/* other  */
-	{ 2, "OL" },		/* normal */
-	{ 3, "OB" },		/* battery */
-	{ 4, "BOOST" },	/* booster */
-	{ 5, "OFF" },		/* timedSleeping */
-	{ 6, "OFF" },		/* bypass  */
-	{ 7, "" },		/* none */
-	{ 8, "" },		/* rebooting */
-	{ 9, "" },		/* Pwr Hard Bypass */
-	{ 10, "" },		/* Pwr Fail Bypass */
-	{ 11, "OFF" },	/* sleepingUntilPowerReturn */
-	{ 12, "TRIM" },	/* reducer */
-	{ 0, "NULL" }
+    { 1, "" },          /* unknown  */
+    { 2, "OL" },        /* onLine */
+    { 3, "OB" },        /* onBattery */
+    { 4, "BOOST" },     /* onSmartBoost */
+    { 5, "OFF" },       /* timedSleeping */
+    { 6, "OFF" },       /* softwareBypass  */
+    { 7, "OFF" },       /* off */
+    { 8, "" },          /* rebooting */
+    { 9, "BYPASS" },    /* switchedBypass */
+    { 10, "BYPASS" },   /* hardwareFailureBypass */
+    { 11, "OFF" },      /* sleepingUntilPowerReturn */
+    { 12, "TRIM" },     /* onSmartTrim */
+    { 0, "NULL" }
 } ;
 
-#define APCC_OID_OUTVOLT		".1.3.6.1.4.1.318.1.1.1.4.2.1"
-#define APCC_OID_LOADPCT		".1.3.6.1.4.1.318.1.1.1.4.2.3"
-
-/* PowerNet-MIB::upsAdvConfigHighTransferVolt */
-#define APCC_OID_HIGHXFER		".1.3.6.1.4.1.318.1.1.1.5.2.2"
+#define APCC_OID_CAL_RESULTS	".1.3.6.1.4.1.318.1.1.1.7.2.6.0"
+info_lkp_t apcc_cal_info[] = {
+    { 1, "" },          /* Calibration Successful */
+    { 2, "" },          /* Calibration not done, battery capacity below 100% */
+    { 3, "CAL" },       /* Calibration in progress */
+    { 0, "NULL" }
+};
 
-/* PowerNet-MIB::upsAdvConfigLowTransferVolt */
-#define APCC_OID_LOWXFER		".1.3.6.1.4.1.318.1.1.1.5.2.3"
+#define APCC_OID_NEEDREPLBATT	".1.3.6.1.4.1.318.1.1.1.2.2.4.0"
+info_lkp_t apcc_battrepl_info[] = {
+    { 1, "" },          /* No battery needs replacing */
+    { 2, "RB" },        /* Batteries need to be replaced */
+    { 0, "NULL" }
+};
 
-/* --- future OIDs which are not mapped to anything yet */
+#define APCC_OID_TESTDIAGRESULTS ".1.3.6.1.4.1.318.1.1.1.7.2.3.0"
+info_lkp_t apcc_testdiag_results[] = {
+    { 1, "Ok" },
+    { 2, "Failed" },
+    { 3, "InvalidTest" },
+    { 4, "TestInProgress"},
+    { 0, "NULL" }
+};
 
-/* PowerNet-MIB::upsAdvInputMaxLineVoltage */
-#define FUTURE_OID_MAX_INVOLT		".1.3.6.1.4.1.318.1.1.1.3.2.2"
+#define APCC_OID_SENSITIVITY ".1.3.6.1.4.1.318.1.1.1.5.2.7.0"
+info_lkp_t apcc_sensitivity_modes[] = {
+    { 1, "auto" },
+    { 2, "low" },
+    { 3, "medium" },
+    { 4, "high" },
+    { 0, "NULL" }
+};
 
-/* PowerNet-MIB::upsAdvInputMinLineVoltage */
-#define FUTURE_OID_MIN_INVOLT		".1.3.6.1.4.1.318.1.1.1.3.2.3"
 
 /* --- */
 
-#define APCC_OID_SLFTSTRES		".1.3.6.1.4.1.318.1.1.1.7.2.3"
-/* XXX can't find appropriate OID for INFO_BATTVOLT. */
-/*#define APCC_OID_BATT_VOLTAGE	".1.3.6.1.4.1.318.???"*/
 /* commands */
-#define APCC_OID_OFF			".1.3.6.1.4.1.318.1.1.1.6.2.1"
-#define APCC_OFF_DO 2
-#define APCC_OFF_GRACEFUL 3
 #define APCC_OID_REBOOT			".1.3.6.1.4.1.318.1.1.1.6.2.2"
 #define APCC_REBOOT_DO			2
 #define APCC_REBOOT_GRACEFUL	3
@@ -101,125 +99,133 @@
 	#define APCC_SLEEP_ON			"2"
 	#define APCC_SLEEP_GRACEFUL		"3"
 #endif
-#define APCC_OID_SIMPWF			".1.3.6.1.4.1.318.1.1.1.6.2.4"
-#define APCC_SIMPWF_DO			2
-#define APCC_OID_FPTEST			".1.3.6.1.4.1.318.1.1.1.6.2.5"
-#define APCC_FPTEST_DO			2
-#define APCC_OID_ON				".1.3.6.1.4.1.318.1.1.1.6.2.6"
-#define APCC_ON_DO				2
-#define APCC_OID_BYPASS			".1.3.6.1.4.1.318.1.1.1.6.2.7"
-#define APCC_BYPASS_ON			2
-#define APCC_BYPASS_OFF			3
-#define APCC_OID_SELFTEST		".1.3.6.1.4.1.318.1.1.1.7.2.2"
-#define APCC_SELFTEST_DO		2
-#define APCC_OID_CAL			".1.3.6.1.4.1.318.1.1.1.7.2.5"
-#define APCC_CAL_DO				2
-#define APCC_CAL_CANCEL			3
-#define APCC_OID_CAL_RESULTS	".1.3.6.1.4.1.318.1.1.1.7.2.6"
-#define APCC_CAL_OK				1
-#define APCC_CAL_INVALID		2
-#define APCC_CAL_INPROGRESS		3
-/*#define APCC_OID_OUTPUT_TAB	"XXX"*/
-#define APCC_OID_OUTCURRENT		".1.3.6.1.4.1.318.1.1.1.4.2.4"
-#define APCC_OID_REQOUTVOLT		".1.3.6.1.4.1.318.1.1.1.5.2.1"
-#define APCC_OID_RETCAPACITY	".1.3.6.1.4.1.318.1.1.1.5.2.6"
-#define APCC_OID_CONSERVE		".1.3.6.1.4.1.318.1.1.1.6.1.1"
-#define APCC_CONSERVE_DO		2
-#define APCC_OID_NEEDREPLBATT	".1.3.6.1.4.1.318.1.1.1.2.2.4"
-#define APCC_RB_NONEED			1
-#define APCC_RB_NEED			2
-#define APCC_OID_SENS			".1.3.6.1.4.1.318.1.1.1.5.2.7"
-#define APCC_OID_GRACEDELAY		".1.3.6.1.4.1.318.1.1.1.5.2.10"
-#define APCC_OID_RETDELAY		".1.3.6.1.4.1.318.1.1.1.5.2.9"
-#define APCC_OID_LOBATTIME		".1.3.6.1.4.1.318.1.1.1.5.2.8"
-/* Environmental sensors (AP9612TH and others) */
-#define APCC_OID_AMBTEMP		".1.3.6.1.4.1.318.1.1.2.1.1"
-#define APCC_OID_AMBHUMID		".1.3.6.1.4.1.318.1.1.2.1.2"
 
-/* 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"
-#define APCC_OID_IEM_TEMP_UNIT  ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5"
-#define TEMP_UNIT_FAHRENHEIT	2
-#define APCC_OID_IEM_HUMID      ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.6"
 
 snmp_info_t apcc_mib[] = {
 
 	/* info elements. */
 	{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "APC",
 		SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
-	{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_MODEL_NAME,
-		"Generic Powernet SNMP device", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
-	{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_SERIAL, "",
-		SU_FLAG_STATIC | SU_FLAG_OK, NULL },
-	{ "ups.mfr.date", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_BATTDATE, "",
-		SU_FLAG_OK | SU_FLAG_STATIC, NULL },
-	{ "input.voltage", 0, 1, APCC_OID_INVOLT, "", SU_FLAG_OK, NULL },
-	{ "battery.charge", 0, 1, APCC_OID_BATT_CHARGE, "", SU_FLAG_OK, NULL },
+	{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.318.1.1.1.1.1.1.0", "Generic Powernet SNMP device", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
+	{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.318.1.1.1.1.2.3.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
+	{ "ups.mfr.date", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.318.1.1.1.1.2.2.0", "", SU_FLAG_OK | SU_FLAG_STATIC, NULL },
+	{ "input.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.3.2.1.0", "", SU_FLAG_OK, NULL },
+	{ "input.phases", ST_FLAG_STRING, 2, ".1.3.6.1.4.1.318.1.1.1.9.2.2.1.2.1", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
+	{ "input.L1-L2.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.3.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "input.L2-L3.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.3.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "input.L3-L1.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.3.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "input.L1-L2.voltage.maximum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.4.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "input.L2-L3.voltage.maximum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.4.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "input.L3-L1.voltage.maximum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.4.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "input.L1-L2.voltage.minimum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.5.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "input.L2-L3.voltage.minimum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.5.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "input.L3-L1.voltage.minimum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.5.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "input.L1.current", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.6.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "input.L2.current", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.6.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "input.L3.current", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.6.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "input.L1.current.maximum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.7.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "input.L2.current.maximum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.7.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "input.L3.current.maximum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.7.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "input.L1.current.minimum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.8.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "input.L2.current.minimum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.8.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "input.L3.current.minimum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.2.3.1.8.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "battery.charge", 0, 1, ".1.3.6.1.4.1.318.1.1.1.2.2.1.0", "", SU_FLAG_OK, NULL },
 	{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_POWER_STATUS, "OFF",
-		SU_FLAG_OK | SU_STATUS_PWR, &apcc_pwr_info[0] },
+		SU_FLAG_OK | SU_STATUS_PWR, apcc_pwr_info },
 	{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_BATT_STATUS, "",
-		SU_FLAG_OK | SU_STATUS_BATT, &apcc_batt_info[0] },
+		SU_FLAG_OK | SU_STATUS_BATT, apcc_batt_info },
 	{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_CAL_RESULTS, "",
-		SU_FLAG_OK | SU_STATUS_CAL, NULL },
+		SU_FLAG_OK | SU_STATUS_CAL, apcc_cal_info },
 	{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_NEEDREPLBATT, "",
-		SU_FLAG_OK | SU_STATUS_RB, NULL },
-	{ "ups.temperature", 0, 1, APCC_OID_UPSTEMP, "", SU_FLAG_OK, NULL },
-	{ "input.frequency", 0, 1, APCC_OID_INFREQ, "", SU_FLAG_OK, NULL },
-	{ "ups.load", 0, 1, APCC_OID_LOADPCT, "", SU_FLAG_OK, NULL },
-	{ "ups.firmware", ST_FLAG_STRING, 16, APCC_OID_FIRMREV, "",
-		SU_FLAG_STATIC | SU_FLAG_OK, NULL },
-	{ "battery.runtime", 0, 1, APCC_OID_BATT_RUNTIME, "", SU_FLAG_OK, NULL },
-	/* can't find appropriate OID for "battery.voltage". */
-	/*{ "battery.voltage", 0, 1, APCC_OID_BATT_VOLTAGE, "", SU_FLAG_OK, NULL },*/
-	{ "output.voltage", 0, 1, APCC_OID_OUTVOLT, "", SU_FLAG_OK, NULL },
-	{ "ups.id", ST_FLAG_STRING | ST_FLAG_RW, 8, APCC_OID_UPSIDEN, "",
-		SU_FLAG_OK | SU_FLAG_STATIC | SU_TYPE_STRING, NULL },
-	{ "battery.date", ST_FLAG_STRING | ST_FLAG_RW, 8, APCC_OID_MFRDATE, "",
-		SU_FLAG_OK | SU_FLAG_STATIC | SU_TYPE_STRING, NULL },
-	{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_SLFTSTRES, "",
-		SU_FLAG_OK, NULL },
-	{ "input.transfer.low", ST_FLAG_STRING | ST_FLAG_RW, 3, APCC_OID_LOWXFER, "",
-		SU_TYPE_INT | SU_FLAG_OK, NULL },
-	{ "input.transfer.high", ST_FLAG_STRING | ST_FLAG_RW, 3, APCC_OID_HIGHXFER, "",
-		SU_TYPE_INT | SU_FLAG_OK, NULL },
-	{ "output.current", 0, 0, APCC_OID_OUTCURRENT, "", SU_FLAG_OK, NULL },
-	{ "output.voltage.target.battery", ST_FLAG_STRING | ST_FLAG_RW, 3, APCC_OID_REQOUTVOLT, "",
-		SU_TYPE_INT | SU_FLAG_OK, NULL },
-	{ "battery.charge.restart", ST_FLAG_STRING | ST_FLAG_RW, 3, APCC_OID_RETCAPACITY, "",
-		SU_TYPE_INT | SU_FLAG_OK, NULL },
-	{ "input.sensitivity", ST_FLAG_STRING | ST_FLAG_RW, 1, APCC_OID_SENS, "",
-		SU_TYPE_INT | SU_FLAG_OK, NULL },
-	{ "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 3, APCC_OID_GRACEDELAY, "",
-		SU_FLAG_OK, NULL },
-	{ "ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 3, APCC_OID_RETDELAY, "",
-		SU_FLAG_OK, NULL },
-	{ "battery.charge.low", ST_FLAG_STRING | ST_FLAG_RW, 3, APCC_OID_LOBATTIME, "",
-		SU_FLAG_OK, NULL },
+		SU_FLAG_OK | SU_STATUS_RB, apcc_battrepl_info },
+	{ "ups.temperature", 0, 1, ".1.3.6.1.4.1.318.1.1.1.2.2.2.0", "", SU_FLAG_OK, NULL },
+	{ "input.frequency", 0, 1, ".1.3.6.1.4.1.318.1.1.1.3.2.4.0", "", SU_FLAG_OK, NULL },
+	{ "ups.load", 0, 1, ".1.3.6.1.4.1.318.1.1.1.4.2.3.0", "", SU_FLAG_OK, NULL },
+	{ "ups.firmware", ST_FLAG_STRING, 16, ".1.3.6.1.4.1.318.1.1.1.1.2.1.0", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
+	{ "battery.runtime", 0, 1, ".1.3.6.1.4.1.318.1.1.1.2.2.3.0", "", SU_FLAG_OK, NULL },
+	{ "battery.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.2.2.8.0", "", SU_FLAG_OK, NULL },
+	{ "output.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.4.2.1.0", "", SU_FLAG_OK, NULL },
+	{ "ups.id", ST_FLAG_STRING | ST_FLAG_RW, 8, ".1.3.6.1.4.1.318.1.1.1.1.1.2.0", "", SU_FLAG_OK | SU_FLAG_STATIC | SU_TYPE_STRING, NULL },
+	{ "battery.date", ST_FLAG_STRING | ST_FLAG_RW, 8, ".1.3.6.1.4.1.318.1.1.1.2.1.3.0", "", SU_FLAG_OK | SU_FLAG_STATIC | SU_TYPE_STRING, NULL },
+	{ "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE, APCC_OID_TESTDIAGRESULTS, "", SU_FLAG_OK, apcc_testdiag_results },
+	{ "input.transfer.low", ST_FLAG_STRING | ST_FLAG_RW, 3, ".1.3.6.1.4.1.318.1.1.1.5.2.3.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
+	{ "input.transfer.high", ST_FLAG_STRING | ST_FLAG_RW, 3, ".1.3.6.1.4.1.318.1.1.1.5.2.2.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
+	{ "output.phases", ST_FLAG_STRING, 2, ".1.3.6.1.4.1.318.1.1.1.9.3.2.1.2.1", "", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
+	{ "output.frequency", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.2.1.4.1", "", SU_FLAG_OK, NULL },
+	{ "output.current", 0, 1, ".1.3.6.1.4.1.318.1.1.1.4.2.4.0", "", SU_FLAG_OK, NULL },
+	{ "output.L1-L2.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.3.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2-L3.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.3.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3-L1.voltage", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.3.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.current", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.4.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.current", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.4.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.current", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.4.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.current.maximum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.5.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.current.maximum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.5.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.current.maximum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.5.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.current.minimum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.6.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.current.minimum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.6.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.current.minimum", 0, 0.1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.6.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.power", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.7.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.power", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.7.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.power", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.7.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.power.maximum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.8.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.power.maximum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.8.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.power.maximum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.8.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.power.minimum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.9.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.power.minimum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.9.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.power.minimum", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.9.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.power.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.10.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.power.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.10.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.power.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.10.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.power.maximum.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.11.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.power.maximum.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.11.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.power.maximum.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.11.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.L1.power.minimum.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.12.1.1.1", "", SU_FLAG_OK, NULL },
+	{ "output.L2.power.minimum.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.12.1.1.2", "", SU_FLAG_OK, NULL },
+	{ "output.L3.power.minimum.percent", 0, 1, ".1.3.6.1.4.1.318.1.1.1.9.3.3.1.12.1.1.3", "", SU_FLAG_OK, NULL },
+	{ "output.voltage.target.battery", ST_FLAG_STRING | ST_FLAG_RW, 3, ".1.3.6.1.4.1.318.1.1.1.5.2.1.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
+	{ "battery.charge.restart", ST_FLAG_STRING | ST_FLAG_RW, 3, ".1.3.6.1.4.1.318.1.1.1.5.2.6.0", "", SU_TYPE_INT | SU_FLAG_OK, NULL },
+	{ "input.sensitivity", ST_FLAG_STRING | ST_FLAG_RW, 1, APCC_OID_SENSITIVITY, "", SU_TYPE_INT | SU_FLAG_OK, apcc_sensitivity_modes },
+	{ "ups.delay.shutdown", ST_FLAG_STRING | ST_FLAG_RW, 3, ".1.3.6.1.4.1.318.1.1.1.5.2.10.0", "", SU_FLAG_OK, NULL },
+	{ "ups.delay.start", ST_FLAG_STRING | ST_FLAG_RW, 3, ".1.3.6.1.4.1.318.1.1.1.5.2.9.0", "", SU_FLAG_OK, NULL },
+	{ "battery.charge.low", ST_FLAG_STRING | ST_FLAG_RW, 3, ".1.3.6.1.4.1.318.1.1.1.5.2.8.0", "", SU_FLAG_OK, NULL },
 
 	/* Measure-UPS ambient variables */
-	{ "ambient.temperature", 0, 1, APCC_OID_AMBTEMP, "", SU_FLAG_OK, NULL },
-	{ "ambient.humidity", 0, 1, APCC_OID_AMBHUMID, "", SU_FLAG_OK, NULL },
+/* Environmental sensors (AP9612TH and others) */
+	{ "ambient.temperature", 0, 1, ".1.3.6.1.4.1.318.1.1.2.1.1.0", "", SU_FLAG_OK, NULL },
+	{ "ambient.humidity", 0, 1, ".1.3.6.1.4.1.318.1.1.2.1.2.0", "", 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.0"
+#define APCC_OID_IEM_TEMP_UNIT  ".1.3.6.1.4.1.318.1.1.10.2.3.2.1.5.0"
+#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.0"
 	{ "ambient.temperature", 0, 1, APCC_OID_IEM_TEMP, "", SU_FLAG_OK, NULL },
 	{ "ambient.humidity", 0, 1, APCC_OID_IEM_HUMID, "", SU_FLAG_OK, NULL },
 
 	/* instant commands. */
-	{ "load.off", 0, APCC_OFF_DO, APCC_OID_OFF, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "load.on", 0, APCC_ON_DO, APCC_OID_ON, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "shutdown.stayoff", 0, APCC_OFF_GRACEFUL, APCC_OID_OFF, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "load.off", 0, 2, ".1.3.6.1.4.1.318.1.1.1.6.2.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "load.on", 0, 2, ".1.3.6.1.4.1.318.1.1.1.6.2.6.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "shutdown.stayoff", 0, 3, ".1.3.6.1.4.1.318.1.1.1.6.2.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
 
 /*	{ CMD_SDRET, 0, APCC_REBOOT_GRACEFUL, APCC_OID_REBOOT, "", SU_TYPE_CMD | SU_FLAG_OK, NULL }, */
 	
-	{ "shutdown.return", 0, APCC_CONSERVE_DO, APCC_OID_CONSERVE, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "test.failure.start", 0, APCC_SIMPWF_DO, APCC_OID_SIMPWF, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "test.panel.start", 0, APCC_FPTEST_DO, APCC_OID_FPTEST, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "bypass.start", 0, APCC_BYPASS_ON, APCC_OID_BYPASS, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "test.battery.start", 0, APCC_SELFTEST_DO, APCC_OID_SELFTEST, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "calibrate.stop", 0, APCC_CAL_CANCEL, APCC_OID_CAL, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
-	{ "calibrate.start", 0, APCC_CAL_DO, APCC_OID_CAL, "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "shutdown.return", 0, 2, ".1.3.6.1.4.1.318.1.1.1.6.1.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "test.failure.start", 0, 2, ".1.3.6.1.4.1.318.1.1.1.6.2.4.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "test.panel.start", 0, 2, ".1.3.6.1.4.1.318.1.1.1.6.2.5.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "bypass.start", 0, 2, ".1.3.6.1.4.1.318.1.1.1.6.2.7.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "bypass.stop", 0, 3, ".1.3.6.1.4.1.318.1.1.1.6.2.7.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "test.battery.start", 0, 2, ".1.3.6.1.4.1.318.1.1.1.7.2.2.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "calibrate.start", 0, 2, ".1.3.6.1.4.1.318.1.1.1.7.2.5.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "calibrate.stop", 0, 3, ".1.3.6.1.4.1.318.1.1.1.7.2.5.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
+	{ "reset.input.minmax", 0, 2, ".1.3.6.1.4.1.318.1.1.1.9.1.1.0", "", SU_TYPE_CMD | SU_FLAG_OK, NULL },
 
 	/* end of structure. */
 	{ NULL, 0, 0, NULL, NULL, 0, NULL }
 };
+
+/*
+vim:ts=4:sw=4:et:
+*/
Index: drivers/ietfmib.h
===================================================================
RCS file: /cvsroot/nut/nut/drivers/ietfmib.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ietfmib.h
--- drivers/ietfmib.h	27 Jan 2005 14:33:21 -0000	1.1.1.1
+++ drivers/ietfmib.h	24 Jan 2006 13:04:24 -0000
@@ -26,20 +26,20 @@
 
 /* SNMP OIDs set */
 #define IETF_OID_UPS_MIB			".1.3.6.1.2.1.33"
-#define IETF_OID_MFR_NAME			".1.3.6.1.2.1.33.1.1.1"
-#define IETF_OID_MODEL_NAME			".1.3.6.1.2.1.33.1.1.2"
-#define IETF_OID_FIRMREV			".1.3.6.1.2.1.33.1.1.4"
-#define IETF_OID_BATT_STATUS		".1.3.6.1.2.1.33.1.2.1"     /* INFO_STATUS (2) */
-#define IETF_OID_BATT_RUNTIME		".1.3.6.1.2.1.33.1.2.3"
-#define IETF_OID_BATT_RUNTIME_LOW	".1.3.6.1.2.1.33.1.9.7"
-#define IETF_OID_BATT_CHARGE		".1.3.6.1.2.1.33.1.2.4"
-#define IETF_OID_BATT_VOLTAGE		".1.3.6.1.2.1.33.1.2.5"
-#define IETF_OID_IN_FREQ			".1.3.6.1.2.1.33.1.3.3.1.2"
-#define IETF_OID_IN_VOLTAGE			".1.3.6.1.2.1.33.1.3.3.1.3"
-#define IETF_OID_POWER_STATUS		".1.3.6.1.2.1.33.1.4.1"     /* INFO_STATUS (1) */
-#define IETF_OID_OUT_VOLTAGE		".1.3.6.1.2.1.33.1.9.3"     /* INFO_UTILITY ? */
-#define IETF_OID_UTIL_VOLTAGE		".1.3.6.1.2.1.33.1.4.4.1.2" /* INFO_UTILITY ? */
-#define IETF_OID_LOAD_LEVEL			".1.3.6.1.2.1.33.1.4.4.1.5" /* INFO_LOADPCT */
+#define IETF_OID_MFR_NAME			".1.3.6.1.2.1.33.1.1.1.0"
+#define IETF_OID_MODEL_NAME			".1.3.6.1.2.1.33.1.1.2.0"
+#define IETF_OID_FIRMREV			".1.3.6.1.2.1.33.1.1.4.0"
+#define IETF_OID_BATT_STATUS		".1.3.6.1.2.1.33.1.2.1.0"     /* INFO_STATUS (2) */
+#define IETF_OID_BATT_RUNTIME		".1.3.6.1.2.1.33.1.2.3.0"
+#define IETF_OID_BATT_RUNTIME_LOW	".1.3.6.1.2.1.33.1.9.7.0"
+#define IETF_OID_BATT_CHARGE		".1.3.6.1.2.1.33.1.2.4.0"
+#define IETF_OID_BATT_VOLTAGE		".1.3.6.1.2.1.33.1.2.5.0"
+#define IETF_OID_IN_FREQ			".1.3.6.1.2.1.33.1.3.3.1.2.0"
+#define IETF_OID_IN_VOLTAGE			".1.3.6.1.2.1.33.1.3.3.1.3.0"
+#define IETF_OID_POWER_STATUS		".1.3.6.1.2.1.33.1.4.1.0"     /* INFO_STATUS (1) */
+#define IETF_OID_OUT_VOLTAGE		".1.3.6.1.2.1.33.1.9.3.0"     /* INFO_UTILITY ? */
+#define IETF_OID_UTIL_VOLTAGE		".1.3.6.1.2.1.33.1.4.4.1.2.0" /* INFO_UTILITY ? */
+#define IETF_OID_LOAD_LEVEL			".1.3.6.1.2.1.33.1.4.4.1.5.0" /* INFO_LOADPCT */
 #define IETF_OID_OUTPUT_TAB			".1.3.6.1.2.1.33.1.4.4"
 
 /* Defines for IETF_OID_POWER_STATUS (1) */
Index: drivers/mgemib.h
===================================================================
RCS file: /cvsroot/nut/nut/drivers/mgemib.h,v
retrieving revision 1.1.1.1.10.1
diff -u -r1.1.1.1.10.1 mgemib.h
--- drivers/mgemib.h	28 Jun 2005 15:04:38 -0000	1.1.1.1.10.1
+++ drivers/mgemib.h	24 Jan 2006 13:04:24 -0000
@@ -27,56 +27,56 @@
 
 /* SNMP OIDs set */
 #define MGE_OID_UPS_MIB			".1.3.6.1.4.1.705"
-#define MGE_OID_MODEL_NAME		".1.3.6.1.4.1.705.1.1.1"
-#define MGE_OID_SERIAL			".1.3.6.1.4.1.705.1.1.7"
-#define MGE_OID_LOBATTPCT		".1.3.6.1.4.1.705.1.4.8"
-#define MGE_OID_BATT_RUNTIME 	".1.3.6.1.4.1.705.1.5.1"
-#define MGE_OID_BATT_CHARGE		".1.3.6.1.4.1.705.1.5.2"
-#define MGE_OID_BATTVOLT		".1.3.6.1.4.1.705.1.5.5"
-#define MGE_OID_LOWBATT_STATUS	".1.3.6.1.4.1.705.1.5.14"
+#define MGE_OID_MODEL_NAME		".1.3.6.1.4.1.705.1.1.1.0"
+#define MGE_OID_SERIAL			".1.3.6.1.4.1.705.1.1.7.0"
+#define MGE_OID_LOBATTPCT		".1.3.6.1.4.1.705.1.4.8.0"
+#define MGE_OID_BATT_RUNTIME 	".1.3.6.1.4.1.705.1.5.1.0"
+#define MGE_OID_BATT_CHARGE		".1.3.6.1.4.1.705.1.5.2.0"
+#define MGE_OID_BATTVOLT		".1.3.6.1.4.1.705.1.5.5.0"
+#define MGE_OID_LOWBATT_STATUS	".1.3.6.1.4.1.705.1.5.14.0"
 info_lkp_t mge_lowbatt_info[] = {
 	{ 1, "LB" },
 	{ 2, "" },
 	{ 0, "NULL" }
 };
-#define MGE_OID_INVOLT			".1.3.6.1.4.1.705.1.6.2.1.2"
-#define MGE_OID_INFREQ			".1.3.6.1.4.1.705.1.6.2.1.3"
-#define MGE_OID_INVOLTMIN		".1.3.6.1.4.1.705.1.6.2.1.4"
-#define MGE_OID_INVOLTMAX		".1.3.6.1.4.1.705.1.6.2.1.5"
-#define MGE_OID_OUTVOLT			".1.3.6.1.4.1.705.1.7.2.1.2"
-#define MGE_OID_OUTFREQ			".1.3.6.1.4.1.705.1.7.2.1.3"
-#define MGE_OID_LOADPCT			".1.3.6.1.4.1.705.1.7.2.1.4"
-#define MGE_OID_ONBATT_STATUS	".1.3.6.1.4.1.705.1.7.3"
+#define MGE_OID_INVOLT			".1.3.6.1.4.1.705.1.6.2.1.2.0"
+#define MGE_OID_INFREQ			".1.3.6.1.4.1.705.1.6.2.1.3.0"
+#define MGE_OID_INVOLTMIN		".1.3.6.1.4.1.705.1.6.2.1.4.0"
+#define MGE_OID_INVOLTMAX		".1.3.6.1.4.1.705.1.6.2.1.5.0"
+#define MGE_OID_OUTVOLT			".1.3.6.1.4.1.705.1.7.2.1.2.0"
+#define MGE_OID_OUTFREQ			".1.3.6.1.4.1.705.1.7.2.1.3.0"
+#define MGE_OID_LOADPCT			".1.3.6.1.4.1.705.1.7.2.1.4.0"
+#define MGE_OID_ONBATT_STATUS	".1.3.6.1.4.1.705.1.7.3.0"
 info_lkp_t mge_onbatt_info[] = {
 	{ 1, "OB" },
 	{ 2, "OL" },
 	{ 0, "NULL" }
 };
 
-#define MGE_OID_BYPASS_STATUS	".1.3.6.1.4.1.705.1.7.4"
+#define MGE_OID_BYPASS_STATUS	".1.3.6.1.4.1.705.1.7.4.0"
 info_lkp_t mge_bypass_info[] = {
 	{ 1, "BYPASS" },
 	{ 2, "" },
 	{ 0, "NULL" }
 };
 
-#define MGE_OID_BOOST_STATUS	".1.3.6.1.4.1.705.1.7.8"
+#define MGE_OID_BOOST_STATUS	".1.3.6.1.4.1.705.1.7.8.0"
 info_lkp_t mge_boost_info[] = {
 	{ 1, "BOOST" },
 	{ 2, "" },
 	{ 0, "NULL" }
 };
 
-#define MGE_OID_OVERBATT_STATUS	".1.3.6.1.4.1.705.1.7.10"
+#define MGE_OID_OVERBATT_STATUS	".1.3.6.1.4.1.705.1.7.10.0"
 info_lkp_t mge_overbatt_info[] = {
 	{ 1, "OVER" },
 	{ 2, "" },
 	{ 0, "NULL" }
 };
 
-#define MGE_OID_FIRMREV			".1.3.6.1.4.1.705.1.12.12"
+#define MGE_OID_FIRMREV			".1.3.6.1.4.1.705.1.12.12.0"
 
-#define MGE_OID_BATT_TEST		".1.3.6.1.4.1.705.1.10.4"
+#define MGE_OID_BATT_TEST		".1.3.6.1.4.1.705.1.10.4.0"
 
 #define MGE_NOTHING_VALUE		1
 #define MGE_START_VALUE			2
Index: drivers/netvisionmib.h
===================================================================
RCS file: /cvsroot/nut/nut/drivers/Attic/netvisionmib.h,v
retrieving revision 1.1.4.1
diff -u -r1.1.4.1 netvisionmib.h
--- drivers/netvisionmib.h	4 May 2005 09:36:37 -0000	1.1.4.1
+++ drivers/netvisionmib.h	24 Jan 2006 13:04:24 -0000
@@ -25,13 +25,13 @@
 
 /* SNMP OIDs set */
 #define NETVISION_OID_UPS_MIB			".1.3.6.1.4.1.4555.1.1.1.1"
-#define NETVISION_OID_UPSIDENTMODEL		".1.3.6.1.4.1.4555.1.1.1.1.1.1"
-#define NETVISION_OID_UPSIDENTFWVERSION		".1.3.6.1.4.1.4555.1.1.1.1.1.2"
-#define NETVISION_OID_UPSIDENTAGENTSWVERSION	".1.3.6.1.4.1.4555.1.1.1.1.1.3"
-#define NETVISION_OID_UPSIDENTUPSSERIALNUMBER	".1.3.6.1.4.1.4555.1.1.1.1.1.4"
+#define NETVISION_OID_UPSIDENTMODEL		".1.3.6.1.4.1.4555.1.1.1.1.1.1.0"
+#define NETVISION_OID_UPSIDENTFWVERSION		".1.3.6.1.4.1.4555.1.1.1.1.1.2.0"
+#define NETVISION_OID_UPSIDENTAGENTSWVERSION	".1.3.6.1.4.1.4555.1.1.1.1.1.3.0"
+#define NETVISION_OID_UPSIDENTUPSSERIALNUMBER	".1.3.6.1.4.1.4555.1.1.1.1.1.4.0"
 
 /* UPS Battery */
-#define NETVISION_OID_BATTERYSTATUS		".1.3.6.1.4.1.4555.1.1.1.1.2.1"
+#define NETVISION_OID_BATTERYSTATUS		".1.3.6.1.4.1.4555.1.1.1.1.2.1.0"
 info_lkp_t netvision_batt_info[] = {
 	{ 2, "OL" }, /* battery normal */
 	{ 3, "LB" }, /* battery low */
@@ -40,10 +40,10 @@
 	{ 6, "RB" }  /* battery failure */
 };
 
-#define NETVISION_OID_SECONDSONBATTERY		".1.3.6.1.4.1.4555.1.1.1.1.2.2"
-#define NETVISION_OID_BATT_RUNTIME_REMAINING	".1.3.6.1.4.1.4555.1.1.1.1.2.3"
-#define NETVISION_OID_BATT_CHARGE		".1.3.6.1.4.1.4555.1.1.1.1.2.4"
-#define NETVISION_OID_BATT_VOLTS		".1.3.6.1.4.1.4555.1.1.1.1.2.5"
+#define NETVISION_OID_SECONDSONBATTERY		".1.3.6.1.4.1.4555.1.1.1.1.2.2.0"
+#define NETVISION_OID_BATT_RUNTIME_REMAINING	".1.3.6.1.4.1.4555.1.1.1.1.2.3.0"
+#define NETVISION_OID_BATT_CHARGE		".1.3.6.1.4.1.4555.1.1.1.1.2.4.0"
+#define NETVISION_OID_BATT_VOLTS		".1.3.6.1.4.1.4555.1.1.1.1.2.5.0"
 
 #define NETVISION_OID_INPUT_NUM_LINES		".1.3.6.1.4.1.4555.1.1.1.1.3.1.0" /* 1phase or 3phase UPS input */
 #define NETVISION_OID_OUTPUT_NUM_LINES		".1.3.6.1.4.1.4555.1.1.1.1.4.3.0" /* 1phase or 3phase UPS output */
@@ -53,10 +53,10 @@
 	in case of one-phase output, only _P1 should be used
 */
 
-#define NETVISION_OID_OUT_VOLTAGE_P1	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.2"
-#define NETVISION_OID_OUT_CURRENT_P1	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3"
-#define NETVISION_OID_OUT_LOAD_PCT_P1	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.4"
-#define NETVISION_OID_IN_VOLTAGE_P1	".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.5"
+#define NETVISION_OID_OUT_VOLTAGE_P1	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.2.1"
+#define NETVISION_OID_OUT_CURRENT_P1	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3.1"
+#define NETVISION_OID_OUT_LOAD_PCT_P1	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.4.1"
+#define NETVISION_OID_IN_VOLTAGE_P1	".1.3.6.1.4.1.4555.1.1.1.1.3.3.1.5.1"
 
 #define NETVISION_OID_OUT_VOLTAGE_P2	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.2.2"
 #define NETVISION_OID_OUT_CURRENT_P2	".1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3.2"
Index: drivers/pwmib.h
===================================================================
RCS file: /cvsroot/nut/nut/drivers/Attic/pwmib.h,v
retrieving revision 1.1.4.1
diff -u -r1.1.4.1 pwmib.h
--- drivers/pwmib.h	4 May 2005 09:36:37 -0000	1.1.4.1
+++ drivers/pwmib.h	24 Jan 2006 13:04:24 -0000
@@ -23,26 +23,26 @@
 
 #define PW_MIB_VERSION                   "0.1"
 
-#define PW_OID_MANUFACTURER              ".1.3.6.1.2.1.33.1.1.1"
-#define PW_OID_MODEL                     ".1.3.6.1.2.1.33.1.1.2"
-#define PW_OID_SOFTWARE_VERSION          ".1.3.6.1.2.1.33.1.1.3"
-#define PW_OID_AGENT_SOFTWARE_VERSION    ".1.3.6.1.2.1.33.1.1.4"
-
-#define PW_OID_BATTERY_STATUS            ".1.3.6.1.4.1.534.1.2.5" /* Xups.mib */
-#define PW_OID_BATTERY_MINUTES_REMAINING ".1.3.6.1.2.1.33.1.2.3"
-#define PW_OID_BATTERY_CHARGE_REMAINING  ".1.3.6.1.2.1.33.1.2.4"
-#define PW_OID_BATTERY_VOLTAGE           ".1.3.6.1.2.1.33.1.2.5"
-
-#define PW_OID_IN_FREQUENCY              ".1.3.6.1.2.1.33.1.3.3.1.2"
-#define PW_OID_IN_VOLTAGE                ".1.3.6.1.2.1.33.1.3.3.1.3"
-
-#define PW_OID_OUT_FREQUENCY             ".1.3.6.1.2.1.33.1.4.2"
-#define PW_OID_OUT_VOLTAGE               ".1.3.6.1.2.1.33.1.4.4.1.2"
-#define PW_OID_OUT_CURRENT               ".1.3.6.1.2.1.33.1.4.4.1.3"
-#define PW_OID_OUT_POWER                 ".1.3.6.1.2.1.33.1.4.4.1.4"
-#define PW_OID_OUT_PERCENTLOAD           ".1.3.6.1.2.1.33.1.4.4.1.5"
+#define PW_OID_MANUFACTURER              ".1.3.6.1.2.1.33.1.1.1.0"
+#define PW_OID_MODEL                     ".1.3.6.1.2.1.33.1.1.2.0"
+#define PW_OID_SOFTWARE_VERSION          ".1.3.6.1.2.1.33.1.1.3.0"
+#define PW_OID_AGENT_SOFTWARE_VERSION    ".1.3.6.1.2.1.33.1.1.4.0"
+
+#define PW_OID_BATTERY_STATUS            ".1.3.6.1.4.1.534.1.2.5.0" /* Xups.mib */
+#define PW_OID_BATTERY_MINUTES_REMAINING ".1.3.6.1.2.1.33.1.2.3.0"
+#define PW_OID_BATTERY_CHARGE_REMAINING  ".1.3.6.1.2.1.33.1.2.4.0"
+#define PW_OID_BATTERY_VOLTAGE           ".1.3.6.1.2.1.33.1.2.5.0"
+
+#define PW_OID_IN_FREQUENCY              ".1.3.6.1.2.1.33.1.3.3.1.2.0"
+#define PW_OID_IN_VOLTAGE                ".1.3.6.1.2.1.33.1.3.3.1.3.0"
+
+#define PW_OID_OUT_FREQUENCY             ".1.3.6.1.2.1.33.1.4.2.0"
+#define PW_OID_OUT_VOLTAGE               ".1.3.6.1.2.1.33.1.4.4.1.2.0"
+#define PW_OID_OUT_CURRENT               ".1.3.6.1.2.1.33.1.4.4.1.3.0"
+#define PW_OID_OUT_POWER                 ".1.3.6.1.2.1.33.1.4.4.1.4.0"
+#define PW_OID_OUT_PERCENTLOAD           ".1.3.6.1.2.1.33.1.4.4.1.5.0"
 
-#define PW_OID_AMBIENT_TEMP              ".1.3.6.1.4.1.534.1.6.1" /* Xups.mib */
+#define PW_OID_AMBIENT_TEMP              ".1.3.6.1.4.1.534.1.6.1.0" /* Xups.mib */
 
 
 /* Defines for PW_OID_BATTERY_STATUS */
Index: drivers/snmp-ups.c
===================================================================
RCS file: /cvsroot/nut/nut/drivers/snmp-ups.c,v
retrieving revision 1.1.1.1.8.1
diff -u -r1.1.1.1.8.1 snmp-ups.c
--- drivers/snmp-ups.c	4 May 2005 09:36:37 -0000	1.1.1.1.8.1
+++ drivers/snmp-ups.c	24 Jan 2006 13:04:24 -0000
@@ -152,7 +152,7 @@
 	
   	/* Get UPS Model node to see if there's a MIB */
 	su_info_p = su_find_info("ups.model");
-	status = nut_snmp_get_str(su_info_p->OID, model, sizeof(model));
+	status = nut_snmp_get_str(su_info_p->OID, model, sizeof(model), NULL);
 
 	if (status == TRUE)
 		upslogx(0, "detected %s on host %s", model, device_path);
@@ -205,60 +205,6 @@
 	SOCK_CLEANUP;
 }
 
-static int oid_compare(const char *oid_req_in, long *oid_ans, size_t oid_len)
-{
-	unsigned int	ctr;
-	long	val;
-	char	*tmp, *ptr, *oid_req;
-
-	/* sanity check */
-	if (oid_req_in[0] != '.')
-		return 0;	/* failed: invalid input */
-
-	/* keep a local copy */
-	oid_req = xstrdup(oid_req_in);
-
-	ctr = 0;
-	tmp = &oid_req[1];
-	ptr = strchr(tmp, '.');
-
-	while (ptr) {
-		*ptr++ = '\0';
-
-		val = strtol(tmp, (char **) NULL, 10);
-
-		if (val != oid_ans[ctr]) {
-			free(oid_req);
-			return 0;	/* failed: mismatched octet */
-		}
-
-		tmp = ptr;
-		ptr = strchr(tmp, '.');
-
-		ctr++;
-
-		if (ctr > (oid_len - 1)) {
-			free(oid_req);
-			return 0;	/* failed: answer is too short */
-		}
-	}
-
-	/* check the final octet */
-	val = strtol(tmp, (char **) NULL, 10);
-
-	/* done with this now */
-	free(oid_req);
-
-	if (val != oid_ans[ctr])
-		return 0;	/* failed: mismatch on the last octet */
-
-	/* answer OID must be req OID plus one more element (the index) */
-	if (oid_len > (ctr + 2)) 
-		return 0;	/* failed: ans is too long */
-
-	return 1;	/* success */
-}
-
 struct snmp_pdu *nut_snmp_get(const char *OID)
 {
 	int status;
@@ -274,7 +220,7 @@
 		return NULL;
 	}
 
-	pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
+	pdu = snmp_pdu_create(SNMP_MSG_GET);
 	
 	if (pdu == NULL)
 		fatalx("Not enough memory");
@@ -286,12 +232,6 @@
 	if (!response)
 		return NULL;
 
-	/* getnext can take us too far, so make sure we got what we want */
-	if (!oid_compare(OID, response->variables->name, 
-		response->variables->name_length)) {
-		return NULL;
-	}
-	
 	if (!((status == STAT_SUCCESS) && (response->errstat == SNMP_ERR_NOERROR)))
 	{
 		numerr++;
@@ -315,7 +255,7 @@
 	return response;
 }
 
-bool nut_snmp_get_str(const char *OID, char *buf, size_t buf_len)
+bool nut_snmp_get_str(const char *OID, char *buf, size_t buf_len, info_lkp_t *oid2info)
 {
 	size_t len = 0;
 	struct snmp_pdu *pdu;
@@ -337,7 +277,19 @@
 		break;
 	case ASN_INTEGER:
 	case ASN_GAUGE:
-		len = snprintf(buf, buf_len, "%ld", *pdu->variables->val.integer);
+		if(oid2info) {
+			const char *str;
+			if((str=su_find_infoval(oid2info, *pdu->variables->val.integer))) {
+				strncpy(buf, str, buf_len-1);
+			}
+			else {
+				strncpy(buf, "UNKNOWN", buf_len-1);
+			}
+			buf[buf_len-1]='\0';
+		}
+		else {
+			len = snprintf(buf, buf_len, "%ld", *pdu->variables->val.integer);
+		}
 		break;
 	case ASN_TIMETICKS:
 		/* convert timeticks to seconds */
@@ -404,19 +356,13 @@
 	struct snmp_pdu *pdu, *response = NULL;
 	oid name[MAX_OID_LEN];
 	size_t name_len = MAX_OID_LEN;
-	char *setOID = (char *) xmalloc (strlen(OID) + 3);
 	
-	/* append ".0" suffix to reach the right OID */
-	sprintf(setOID, "%s.0", OID);
-	
-	if (!read_objid(setOID, name, &name_len)) {
+	if (!read_objid(OID, name, &name_len)) {
 		upslogx(LOG_ERR, "[%s] nut_snmp_set: %s: %s",
-			upsname, setOID, snmp_api_errstring(snmp_errno));
-		free(setOID);
+			upsname, OID, snmp_api_errstring(snmp_errno));
 		return FALSE;
 	}
 
-	/* TODO: confirm we're setting the right OID ! */
 	pdu = snmp_pdu_create(SNMP_MSG_SET);
 	if (pdu == NULL)
 		fatalx("Not enough memory");
@@ -425,7 +371,6 @@
 		upslogx(LOG_ERR, "[%s] nut_snmp_set: %s: %s",
 			upsname, OID, snmp_api_errstring(snmp_errno));
 		
-		free(setOID);
 		return FALSE;
 	}
 
@@ -438,7 +383,6 @@
 			"nut_snmp_set: can't set %s", OID);
 
 	snmp_free_pdu(response);
-	free(setOID);
 	return ret;
 }
 
@@ -618,7 +562,7 @@
 			return info_lkp->oid_value;
 		}
 	}
-	upsdebugx(1, "su_find_infoval: no matching INFO_* value for this OID value (%s)", value);
+	upsdebugx(1, "su_find_valinfo: no matching INFO_* value for this OID value (%s)", value);
 	return -1;
 }
 
@@ -720,7 +664,7 @@
 	bool status;
 	long value;
 
-	upsdebugx(2, "su_ups_get: %s", su_info_p->OID);
+	upsdebugx(2, "su_ups_get: %s %s", su_info_p->info_type, su_info_p->OID);
 	
 	if (!strcasecmp(su_info_p->info_type, "ups.status")) {
 
@@ -736,8 +680,14 @@
 
 	/* another special case */
 	if (!strcasecmp(su_info_p->info_type, "ambient.temperature")) {
+		float temp=0;
+
 		status = nut_snmp_get_int(su_info_p->OID, &value);
 
+		if(status != TRUE) {
+			return status;
+		}
+
 		/* only do this if using the IEM sensor */
 		if (!strcmp(su_info_p->OID, APCC_OID_IEM_TEMP)) {
 			int	su;
@@ -746,14 +696,18 @@
 			su = nut_snmp_get_int(APCC_OID_IEM_TEMP_UNIT, &units);
 
 			/* no response, or units == F */
-			if ((su == FALSE) || (units == TEMP_UNIT_FAHRENHEIT))
-				value = (value - 32) / 1.8;
+			if ((su == FALSE) || (units == APCC_IEM_FAHRENHEIT))
+				temp = (value - 32) / 1.8;
+		}
+		else {
+			temp=value;
 		}
 
-		if (status == TRUE)
-			dstate_setinfo("ambient.temperature", "%ld", value);
+		sprintf(buf, "%05.1f", temp);
+		su_setinfo(su_info_p->info_type, buf,
+			su_info_p->info_flags, su_info_p->info_len);
 
-		return status;
+		return TRUE;
 	}			
 
 	if (su_info_p->info_flags == 0) {
@@ -762,7 +716,7 @@
 			sprintf(buf, "%05.1f", value * su_info_p->info_len);
 		}
 	} else {
-		status = nut_snmp_get_str(su_info_p->OID, buf, sizeof(buf));
+		status = nut_snmp_get_str(su_info_p->OID, buf, sizeof(buf), su_info_p->oid2info);
 	}
 		
 	if (status == TRUE) {
Index: drivers/snmp-ups.h
===================================================================
RCS file: /cvsroot/nut/nut/drivers/snmp-ups.h,v
retrieving revision 1.1.1.1.8.1
diff -u -r1.1.1.1.8.1 snmp-ups.h
--- drivers/snmp-ups.h	4 May 2005 09:36:37 -0000	1.1.1.1.8.1
+++ drivers/snmp-ups.h	24 Jan 2006 13:04:24 -0000
@@ -153,7 +153,7 @@
 void nut_snmp_init(const char *type, const char *host, const char *community);
 void nut_snmp_cleanup(void);
 struct snmp_pdu *nut_snmp_get(const char *OID);
-bool nut_snmp_get_str(const char *OID, char *buf, size_t buf_len);
+bool nut_snmp_get_str(const char *OID, char *buf, size_t buf_len, info_lkp_t *oid2info);
 bool nut_snmp_get_int(const char *OID, long *pval);
 bool nut_snmp_set(const char *OID, char type, const char *value);
 bool nut_snmp_set_str(const char *OID, const char *value);


More information about the Nut-upsdev mailing list