@cryptotaxi247 / netdata-1 / commits / fae8fb2c1

Add driver-type option to the freeipmi plugin (#5384)

Permit processing of a `driver-type` directive, that `ipmimonitoring` uses to set the protocol version for outband (different host) or driver type for inband (same host) communications.

Chris Akritidis committed Feb 19, 2019 at 13:56 UTC fae8fb2c159142e173e634f2d3726b0bb8356dad
2 files changed +80
collectors/freeipmi.plugin/README.md
+6
@@ -68,6 +68,12 @@ The plugin supports a few options. To see them, run:
68 password PASS connect to remote IPMI host
69 default: local IPMI processor
70
71 + driver-type IPMIDRIVER
72 + Specify the driver type to use instead of doing an auto selection.
73 + The currently available outofband drivers are LAN and LAN_2_0,
74 + which perform IPMI 1.5 and IPMI 2.0 respectively.
75 + The currently available inband drivers are KCS, SSIF, OPENIPMI and SUNBMC.
76 +
77 sdr-cache-dir PATH directory for SDR cache files
78 default: /tmp
79
collectors/freeipmi.plugin/freeipmi_plugin.c
+74
@@ -28,6 +28,20 @@
28
29 #ifdef HAVE_FREEIPMI
30
31 +#define IPMI_PARSE_DEVICE_LAN_STR "lan"
32 +#define IPMI_PARSE_DEVICE_LAN_2_0_STR "lan_2_0"
33 +#define IPMI_PARSE_DEVICE_LAN_2_0_STR2 "lan20"
34 +#define IPMI_PARSE_DEVICE_LAN_2_0_STR3 "lan_20"
35 +#define IPMI_PARSE_DEVICE_LAN_2_0_STR4 "lan2_0"
36 +#define IPMI_PARSE_DEVICE_LAN_2_0_STR5 "lanplus"
37 +#define IPMI_PARSE_DEVICE_KCS_STR "kcs"
38 +#define IPMI_PARSE_DEVICE_SSIF_STR "ssif"
39 +#define IPMI_PARSE_DEVICE_OPENIPMI_STR "openipmi"
40 +#define IPMI_PARSE_DEVICE_OPENIPMI_STR2 "open"
41 +#define IPMI_PARSE_DEVICE_SUNBMC_STR "sunbmc"
42 +#define IPMI_PARSE_DEVICE_SUNBMC_STR2 "bmc"
43 +#define IPMI_PARSE_DEVICE_INTELDCMI_STR "inteldcmi"
44 +
45 // ----------------------------------------------------------------------------
46
47 // callback required by fatal()
@@ -1548,6 +1562,49 @@ int ipmi_detect_speed_secs(struct ipmi_monitoring_ipmi_config *ipmi_config) {
1562 return (int)(( total * 2 / checks / 1000000 ) + 1);
1563 }
1564
1565 +int parse_inband_driver_type (const char *str)
1566 +{
1567 + assert (str);
1568 +
1569 + if (strcasecmp (str, IPMI_PARSE_DEVICE_KCS_STR) == 0)
1570 + return (IPMI_MONITORING_DRIVER_TYPE_KCS);
1571 + else if (strcasecmp (str, IPMI_PARSE_DEVICE_SSIF_STR) == 0)
1572 + return (IPMI_MONITORING_DRIVER_TYPE_SSIF);
1573 + /* support "open" for those that might be used to
1574 + * ipmitool.
1575 + */
1576 + else if (strcasecmp (str, IPMI_PARSE_DEVICE_OPENIPMI_STR) == 0
1577 + || strcasecmp (str, IPMI_PARSE_DEVICE_OPENIPMI_STR2) == 0)
1578 + return (IPMI_MONITORING_DRIVER_TYPE_OPENIPMI);
1579 + /* support "bmc" for those that might be used to
1580 + * ipmitool.
1581 + */
1582 + else if (strcasecmp (str, IPMI_PARSE_DEVICE_SUNBMC_STR) == 0
1583 + || strcasecmp (str, IPMI_PARSE_DEVICE_SUNBMC_STR2) == 0)
1584 + return (IPMI_MONITORING_DRIVER_TYPE_SUNBMC);
1585 +
1586 + return (-1);
1587 +}
1588 +
1589 +int parse_outofband_driver_type (const char *str)
1590 +{
1591 + assert (str);
1592 +
1593 + if (strcasecmp (str, IPMI_PARSE_DEVICE_LAN_STR) == 0)
1594 + return (IPMI_MONITORING_PROTOCOL_VERSION_1_5);
1595 + /* support "lanplus" for those that might be used to ipmitool.
1596 + * support typo variants to ease.
1597 + */
1598 + else if (strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR) == 0
1599 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR2) == 0
1600 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR3) == 0
1601 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR4) == 0
1602 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR5) == 0)
1603 + return (IPMI_MONITORING_PROTOCOL_VERSION_2_0);
1604 +
1605 + return (-1);
1606 +}
1607 +
1608 int main (int argc, char **argv) {
1609
1610 // ------------------------------------------------------------------------
@@ -1618,6 +1675,12 @@ int main (int argc, char **argv) {
1675 " password PASS connect to remote IPMI host\n"
1676 " default: local IPMI processor\n"
1677 "\n"
1678 + " driver-type IPMIDRIVER\n"
1679 + " Specify the driver type to use instead of doing an auto selection. \n"
1680 + " The currently available outofband drivers are LAN and LAN_2_0,\n"
1681 + " which perform IPMI 1.5 and IPMI 2.0 respectively. \n"
1682 + " The currently available inband drivers are KCS, SSIF, OPENIPMI and SUNBMC.\n"
1683 + "\n"
1684 " sdr-cache-dir PATH directory for SDR cache files\n"
1685 " default: %s\n"
1686 "\n"
@@ -1676,6 +1739,17 @@ int main (int argc, char **argv) {
1739 if(debug) fprintf(stderr, "freeipmi.plugin: password set to '%s'\n", password);
1740 continue;
1741 }
1742 + else if(strcmp("driver-type", argv[i]) == 0) {
1743 + if (hostname) {
1744 + protocol_version=parse_outofband_driver_type(argv[++i]);
1745 + if(debug) fprintf(stderr, "freeipmi.plugin: outband protocol version set to '%d'\n", protocol_version);
1746 + }
1747 + else {
1748 + driver_type=parse_inband_driver_type(argv[++i]);
1749 + if(debug) fprintf(stderr, "freeipmi.plugin: inband driver type set to '%d'\n", driver_type);
1750 + }
1751 + continue;
1752 + }
1753 else if(i < argc && strcmp("sdr-cache-dir", argv[i]) == 0) {
1754 sdr_cache_directory = argv[++i];
1755 if(debug) fprintf(stderr, "freeipmi.plugin: SDR cache directory set to '%s'\n", sdr_cache_directory);