[Nut-upsdev] [Nut-upsuser] Powerware 9155 with SNMP card
Arjen de Korte
nut+devel at de-korte.org
Tue Aug 14 13:31:38 UTC 2007
> I'm trying to add an instant command to pwmib:
>
> #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_QBATT "1.3.6.1.2.1.33.1.7.7.4" /*
> UPS-MIB::upsTestQuickBatteryTest.0 */
>
> { "test.battery.start", ST_FLAG_STRING, SU_INFOSIZE,
> IETF_OID_UPS_TEST_ID, IETF_OID_UPS_TEST_QBATT, SU_TYPE_CMD | SU_FLAG_OK,
> NULL },
>
> what I hope it to do is write IETF_OID_UPS_TEST_QBATT into
> IETF_OID_UPS_TEST_ID to trigger the test. I hope my understanding of the
> code is right that in this way the string in snmp_info_t->dfl get
> written to OID IETF_OID_UPS_TEST_ID?
>
> though for whatever reason upscmd -l ups doesnt list any instant
> commands... is there anything else to be done to register an instant
> command? apccmib.h and mgemib.h both seem to do nothing else?
The problem is in the upsdrv_initinfo() function in 'snmp-ups.c':
/* add instant commands to the info database. */
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);
It looks like we're missing some curly brackets here. Unlike what the
indentation suggests, the dstate_addcmd() will not be called in the for()
loop, but only when it has finished. At that time, su_info_p->info_type is
NULL, so regardless of what SU_TYPE(su_info_p) evaluates to, this never
adds something useful.
I guess you're the first to notice this, congratulations. Can we persuade
to join the development team? :-)
Best regards, Arjen
More information about the Nut-upsdev
mailing list