Skip to content

Commit

Permalink
Merge pull request #2285 from jimklimov/issue-2275-snmp-mib2nut-wrappers
Browse files Browse the repository at this point in the history
snmp mib2nut wrapper macros
  • Loading branch information
jimklimov authored Feb 11, 2024
2 parents 00c6d24 + 5621018 commit d950fa7
Show file tree
Hide file tree
Showing 32 changed files with 7,435 additions and 7,338 deletions.
387 changes: 193 additions & 194 deletions drivers/apc-ats-mib.c

Large diffs are not rendered by default.

184 changes: 92 additions & 92 deletions drivers/apc-epdu-mib.c

Large diffs are not rendered by default.

405 changes: 204 additions & 201 deletions drivers/apc-mib.c

Large diffs are not rendered by default.

931 changes: 464 additions & 467 deletions drivers/apc-pdu-mib.c

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions drivers/baytech-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,72 +31,72 @@
#define BAYTECH_OID_MODEL_NAME ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1"

static info_lkp_t baytech_outlet_status_info[] = {
{ -1, "error", NULL, NULL },
{ 0, "off", NULL, NULL },
{ 1, "on", NULL, NULL },
{ 2, "cycling", NULL, NULL }, /* transitional status, "reboot" in MIB comments */
{ 3, "lockon", NULL, NULL },
{ 4, "lockoff", NULL, NULL },
{ 5, "unlock", NULL, NULL },
{ 6, "unknown", NULL, NULL },
{ 0, NULL, NULL, NULL }
info_lkp_default(-1, "error"),
info_lkp_default(0, "off"),
info_lkp_default(1, "on"),
info_lkp_default(2, "cycling"), /* transitional status, "reboot" in MIB comments */
info_lkp_default(3, "lockon"),
info_lkp_default(4, "lockoff"),
info_lkp_default(5, "unlock"),
info_lkp_default(6, "unknown"),
info_lkp_sentinel
};

/* Snmp2NUT lookup table for BayTech MIBs */
static snmp_info_t baytech_mib[] = {

/* standard MIB items */
{ "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL },
{ "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL },
{ "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL },
snmp_info_default("device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL),
snmp_info_default("device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL),
snmp_info_default("device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL),

/* Device page */
{ "device.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "BayTech",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "device.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1",
"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "device.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.2.0", "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.2.2.1.6.2",
"", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
snmp_info_default("device.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "BayTech",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),
snmp_info_default("device.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1",
"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL),
snmp_info_default("device.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.2.0", "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL),
snmp_info_default("device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),
snmp_info_default("device.macaddr", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.2.1.2.2.1.6.2",
"", SU_FLAG_STATIC | SU_FLAG_OK, NULL),

/* UPS page */
{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Baytech",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1",
"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.id", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.3.0",
"unknown", SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.2.0", "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.1.0", "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL },
{ "ups.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
{ "ups.temperature", 0, 0.1, ".1.3.6.1.4.1.4779.1.3.5.5.1.10.2.1", NULL, 0, NULL },
snmp_info_default("ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "Baytech",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),
snmp_info_default("ups.model", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.2.1.24.1",
"Generic SNMP PDU", SU_FLAG_STATIC | SU_FLAG_OK, NULL),
snmp_info_default("ups.id", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.3.0",
"unknown", SU_FLAG_STATIC | SU_FLAG_OK, NULL),
snmp_info_default("ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.2.0", "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL),
snmp_info_default("ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.1.1.0", "",
SU_FLAG_STATIC | SU_FLAG_OK, NULL),
snmp_info_default("ups.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "pdu",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),
snmp_info_default("ups.temperature", 0, 0.1, ".1.3.6.1.4.1.4779.1.3.5.5.1.10.2.1", NULL, 0, NULL),

/* 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.4779.1.3.5.2.1.15.1", "0", 0, NULL },
{ "outlet.current", 0, 0.1, ".1.3.6.1.4.1.4779.1.3.5.5.1.6.2.1", NULL, 0, NULL },
{ "outlet.voltage", 0, 0.1, ".1.3.6.1.4.1.4779.1.3.5.5.1.8.2.1", NULL, 0, NULL },
snmp_info_default("outlet.id", 0, 1, NULL, "0", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),
snmp_info_default("outlet.desc", ST_FLAG_RW | ST_FLAG_STRING, 20, NULL, "All outlets",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),
snmp_info_default("outlet.count", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.2.1.15.1", "0", 0, NULL),
snmp_info_default("outlet.current", 0, 0.1, ".1.3.6.1.4.1.4779.1.3.5.5.1.6.2.1", NULL, 0, NULL),
snmp_info_default("outlet.voltage", 0, 0.1, ".1.3.6.1.4.1.4779.1.3.5.5.1.8.2.1", NULL, 0, NULL),

/* outlet template definition */
{ "outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.3.1.3.1.%i", NULL, SU_OUTLET, &baytech_outlet_status_info[0] },
{ "outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.3.1.4.1.%i", NULL, SU_OUTLET, NULL },
{ "outlet.%i.id", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.6.1.3.2.1.%i", "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_OUTLET | SU_FLAG_OK, NULL },
{ "outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.3.1.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, NULL },
snmp_info_default("outlet.%i.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.3.1.3.1.%i", NULL, SU_OUTLET, &baytech_outlet_status_info[0]),
snmp_info_default("outlet.%i.desc", ST_FLAG_RW | ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.4779.1.3.5.3.1.4.1.%i", NULL, SU_OUTLET, NULL),
snmp_info_default("outlet.%i.id", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.6.1.3.2.1.%i", "%i", SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_OUTLET | SU_FLAG_OK, NULL),
snmp_info_default("outlet.%i.switchable", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.3.1.1.1.%i", "yes", SU_FLAG_STATIC | SU_OUTLET, NULL),

/* instant commands. */
{ "outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.3.1.3.1.%i", "0", SU_TYPE_CMD | SU_OUTLET, NULL },
{ "outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.3.1.3.1.%i", "1", SU_TYPE_CMD | SU_OUTLET, NULL },
snmp_info_default("outlet.%i.load.off", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.3.1.3.1.%i", "0", SU_TYPE_CMD | SU_OUTLET, NULL),
snmp_info_default("outlet.%i.load.on", 0, 1, ".1.3.6.1.4.1.4779.1.3.5.3.1.3.1.%i", "1", SU_TYPE_CMD | SU_OUTLET, NULL),

/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL }
snmp_info_sentinel
};

mib2nut_info_t baytech = { "baytech", BAYTECH_MIB_VERSION, NULL, BAYTECH_OID_MODEL_NAME, baytech_mib, BAYTECH_OID_MIB, NULL };
64 changes: 32 additions & 32 deletions drivers/bestpower-mib.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,56 +35,56 @@
#define BESTPOWER_SYSOID BESTPOWER_OID_MODEL_NAME

static info_lkp_t bestpower_power_status[] = {
{ 1, "OL", NULL, NULL },
{ 2, "OB", NULL, NULL },
{ 0, NULL, NULL, NULL }
} ;
info_lkp_default(1, "OL"),
info_lkp_default(2, "OB"),
info_lkp_sentinel
};

/* Snmp2NUT lookup table for Best Power MIB */
static snmp_info_t bestpower_mib[] = {

/* standard MIB items */
{ "device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL },
{ "device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL },
{ "device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL },
snmp_info_default("device.description", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.1.0", NULL, SU_FLAG_OK, NULL),
snmp_info_default("device.contact", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.4.0", NULL, SU_FLAG_OK, NULL),
snmp_info_default("device.location", ST_FLAG_STRING | ST_FLAG_RW, SU_INFOSIZE, ".1.3.6.1.2.1.1.6.0", NULL, SU_FLAG_OK, NULL),

/* Device page */
{ "device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "ups",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
snmp_info_default("device.type", ST_FLAG_STRING, SU_INFOSIZE, NULL, "ups",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),

{ "ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL },
snmp_info_default("ups.mfr", ST_FLAG_STRING, SU_INFOSIZE, NULL, "EATON",
SU_FLAG_STATIC | SU_FLAG_ABSENT | SU_FLAG_OK, NULL),
/*.1.3.6.1.4.1.2947.1.1.1.0 = STRING: "Ferrups"
.1.3.6.1.4.1.2947.1.1.2.0 = STRING: "FE850VA"*/
{ "ups.model", ST_FLAG_STRING, SU_INFOSIZE, BESTPOWER_OID_MODEL_NAME,
"Best Ferrups", SU_FLAG_STATIC, NULL },
snmp_info_default("ups.model", ST_FLAG_STRING, SU_INFOSIZE, BESTPOWER_OID_MODEL_NAME,
"Best Ferrups", SU_FLAG_STATIC, NULL),

{ "ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.5.0",
"", SU_FLAG_STATIC, NULL },
{ "ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.7.0",
"", SU_FLAG_STATIC, NULL },
{ "ups.power", 0, 1, ".1.3.6.1.4.1.2947.1.1.3.0", "",
0, NULL },
{ "ups.mfr.date", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.8.0", "",
0, NULL },
snmp_info_default("ups.serial", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.5.0",
"", SU_FLAG_STATIC, NULL),
snmp_info_default("ups.firmware", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.7.0",
"", SU_FLAG_STATIC, NULL),
snmp_info_default("ups.power", 0, 1, ".1.3.6.1.4.1.2947.1.1.3.0", "",
0, NULL),
snmp_info_default("ups.mfr.date", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.1.8.0", "",
0, NULL),

{ "ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.2.1.0", "",
0 /*SU_STATUS_PWR*/, &bestpower_power_status[0] },
snmp_info_default("ups.status", ST_FLAG_STRING, SU_INFOSIZE, ".1.3.6.1.4.1.2947.1.2.1.0", "",
0 /*SU_STATUS_PWR*/, &bestpower_power_status[0]),

/* Battery runtime is expressed in minutes */
{ "battery.runtime", 0, 60.0, ".1.3.6.1.4.1.2947.1.2.3.0", "",
0, NULL },
snmp_info_default("battery.runtime", 0, 60.0, ".1.3.6.1.4.1.2947.1.2.3.0", "",
0, NULL),
/* The elapsed time in seconds since the
* UPS has switched to battery power */
{ "battery.runtime.elapsed", 0, 1.0, ".1.3.6.1.4.1.2947.1.2.2.0", "",
0, NULL },
{ "battery.voltage", 0, 0.1, ".1.3.6.1.4.1.2947.1.2.4.0", "",
0, NULL },
{ "battery.current", 0, 0.1, ".1.3.6.1.4.1.2947.1.2.5.0", "",
0, NULL },
snmp_info_default("battery.runtime.elapsed", 0, 1.0, ".1.3.6.1.4.1.2947.1.2.2.0", "",
0, NULL),
snmp_info_default("battery.voltage", 0, 0.1, ".1.3.6.1.4.1.2947.1.2.4.0", "",
0, NULL),
snmp_info_default("battery.current", 0, 0.1, ".1.3.6.1.4.1.2947.1.2.5.0", "",
0, NULL),

/* end of structure. */
{ NULL, 0, 0, NULL, NULL, 0, NULL }
snmp_info_sentinel
} ;

mib2nut_info_t bestpower = { "bestpower", BESTPOWER_MIB_VERSION, NULL,
Expand Down
Loading

0 comments on commit d950fa7

Please sign in to comment.