[Nut-upsdev] [Nut-upsuser] Powerware 9155 with SNMP card

Arjen de Korte nut+devel at de-korte.org
Wed Aug 15 11:17:10 UTC 2007


> over the last few days I spent a little time on playing with pwmib.h and
> surroundings. Here is how far I got up to now... maybe someone has a
> similar setup and is willing to test things...

I don't, but I'm willing to take a look at the changes you made. :-)

> First things are in snmp-ups.c:
>
> --- nut-2.2.0.org/drivers/snmp-ups.c    2007-05-26 16:24:26.000000000
> +0200
> +++ nut-2.2.0/drivers/snmp-ups.c        2007-08-15 11:03:57.031031000
> +0200
> @@ -75,10 +75,11 @@
>         dstate_setinfo("driver.version.internal", version);
>
>         /* add instant commands to the info database. */
> -       for (su_info_p = &snmp_info[0]; su_info_p->info_type != NULL ;
> su_info_p++)
> +       for (su_info_p = &snmp_info[0]; su_info_p->info_type != NULL ;
> su_info_p++) {
>                 su_info_p->flags |= SU_FLAG_OK;
>                 if (SU_TYPE(su_info_p) == SU_TYPE_CMD)
>                         dstate_addcmd(su_info_p->info_type);
> +       }
>
>         /* setup handlers for instcmd and setvar functions */
>         upsh.setvar = su_setvar;
> @@ -316,6 +317,7 @@
>                 buf[len] = '\0';
>                 break;
>         case ASN_INTEGER:
> +       case ASN_COUNTER:
>         case ASN_GAUGE:
>                 if(oid2info) {
>                         const char *str;
> @@ -367,6 +369,7 @@
>                 free(buf);
>                 break;
>         case ASN_INTEGER:
> +       case ASN_COUNTER:
>         case ASN_GAUGE:
>                 value = *pdu->variables->val.integer;
>                 break;
>
> The first part now really add instant commands... The second part add
> ASN_COUNTER as type for data we might get from the ups (needed for the
> number of nie failures one can retrieve from the ups).

No problem here, looks fine to me.

> ietfmib.h got the following changes:
>
> --- nut-2.2.0.org/drivers/ietfmib.h     2007-01-19 07:45:46.000000000
> +0100
> +++ nut-2.2.0/drivers/ietfmib.h 2007-08-15 11:03:55.241993000 +0200
> @@ -55,7 +55,13 @@
> #define IETF_OID_OUT_POWER        "1.3.6.1.2.1.33.1.4.4.1.4"   /*
> UPS-MIB::upsOutputPower */
> #define IETF_OID_LOAD_LEVEL       "1.3.6.1.2.1.33.1.4.4.1.5"   /*
> UPS-MIB::upsOutputPercentLoad */
>
> +#define IETF_OID_UPS_TEST_ID     "1.3.6.1.2.1.33.1.7.1.0"      /*
> UPS-MIB::upsTestID.0 */
> +#define IETF_OID_UPS_TEST_RES    "1.3.6.1.2.1.33.1.7.3.0"      /*
> UPS-MIB::upsTestResultsSummary.0 */
> +#define IETF_OID_UPS_TEST_RESDET  "1.3.6.1.2.1.33.1.7.4.0"      /*
> UPS-MIB::upsTestResultsDetail.0 */
> +#define IETF_OID_UPS_TEST_QBATT   "1.3.6.1.2.1.33.1.7.7.4"      /*
> UPS-MIB::upsTestQuickBatteryTest.0 */
> +
> #define IETF_OID_CONF_VOLTAGE     "1.3.6.1.2.1.33.1.9.3.0"     /*
> UPS-MIB::upsConfigOutputVoltage.0 */
> +#define IETF_OID_CONF_OUT_VA      "1.3.6.1.2.1.33.1.9.5.0"     /*
> UPS-MIB::upsConfigOutputVA.0 */
> #define IETF_OID_CONF_RUNTIME_LOW "1.3.6.1.2.1.33.1.9.7.0"     /*
> UPS-MIB::upsConfigLowBattTime.0 */
>
> /* Defines for IETF_OID_POWER_STATUS (1) */
> @@ -126,6 +132,8 @@
>                 SU_STATUS_PWR, &ietf_pwr_info[0] },
>         { "ups.status", ST_FLAG_STRING, SU_INFOSIZE, IETF_OID_BATT_STATUS,
> "",
>                 SU_STATUS_BATT, &ietf_batt_info[0] },
> +       { "ups.test.result", ST_FLAG_STRING, SU_INFOSIZE,
> IETF_OID_UPS_TEST_RESDET, "",
> +               0, NULL },
>
>         /* Battery page */
>         { "battery.charge", 0, 1.0, IETF_OID_BATT_CHARGE, "",
>
> added a few OIDs for the battery test and report last test result. I'll
> add the instant command to run a battery test soonish.

I assume you checked these with RFC 1628, which is good.

> pwmib.h got quite some work so it's attached rather than diff'ed. Lots
> of added OIDs (now sorted for readability).
> http://149.203.91.65/cgi-bin/nut/upsstats.cgi?host=ups2@149.203.91.145&treemode
> gives the status page one of the upses with all added info. Also it's
> now possible to run a battery test.

Looks good, although I doubt that the battery.runtime is correct. Please
note that the NUT unit for this is seconds, not minutes (see
docs/new-names.txt for a full listing). Also have a look at
docs/new-drivers.txt for a look at the way how to list battery status.

You may wish to apply the following change to snmp-ups.c too:

void upsdrv_updateinfo(void)
{
	upsdebugx(1,"SNMP UPS driver : entering upsdrv_updateinfo()");

	/* only update every pollfreq */
	if (time(NULL) > (lastpoll + pollfreq)) {

+		status_init();

		/* update all dynamic info fields */
		if (snmp_ups_walk(SU_WALKMODE_UPDATE))
			dstate_dataok();
		else
			dstate_datastale();

		/* store timestamp */
		lastpoll = time(NULL);

+		status_commit();
	}
}

And remove the calls to status_init() and status_commit() from the
su_status_set() function. By doing so, the driver should be able to parse
all "ups.status" OID's. Side effect will be that there may be some
duplicate flags, but that should not pose a problem to clients, this is
just cosmetic.

The above is a huge hack though, the real solution would be to integrate
the SNMP, HID and SHUT drivers and the way how the latter two use the
status flags (which is far more flexible than the above kludge).

Best regards, Arjen
-- 
Eindhoven - The Netherlands
Key fingerprint - 66 4E 03 2C 9D B5 CB 9B  7A FE 7E C1 EE 88 BC 57




More information about the Nut-upsdev mailing list