diff options
author | Chris Akritidis <43294513+cakrit@users.noreply.github.com> | 2019-02-19 13:56:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-19 13:56:42 +0100 |
commit | fae8fb2c159142e173e634f2d3726b0bb8356dad (patch) | |
tree | 5068bf487bb8ec275497abb4c78944a234c2a93b | |
parent | 797c9a9efb2a271b6f0d709f8c4b2fc9b5c93835 (diff) |
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.
-rw-r--r-- | collectors/freeipmi.plugin/README.md | 6 | ||||
-rw-r--r-- | collectors/freeipmi.plugin/freeipmi_plugin.c | 74 |
2 files changed, 80 insertions, 0 deletions
diff --git a/collectors/freeipmi.plugin/README.md b/collectors/freeipmi.plugin/README.md index a2beddb5d3..246955f958 100644 --- a/collectors/freeipmi.plugin/README.md +++ b/collectors/freeipmi.plugin/README.md @@ -68,6 +68,12 @@ The plugin supports a few options. To see them, run: password PASS connect to remote IPMI host default: local IPMI processor + driver-type IPMIDRIVER + Specify the driver type to use instead of doing an auto selection. + The currently available outofband drivers are LAN and LAN_2_0, + which perform IPMI 1.5 and IPMI 2.0 respectively. + The currently available inband drivers are KCS, SSIF, OPENIPMI and SUNBMC. + sdr-cache-dir PATH directory for SDR cache files default: /tmp diff --git a/collectors/freeipmi.plugin/freeipmi_plugin.c b/collectors/freeipmi.plugin/freeipmi_plugin.c index 35b9a0032a..d42ada1b4b 100644 --- a/collectors/freeipmi.plugin/freeipmi_plugin.c +++ b/collectors/freeipmi.plugin/freeipmi_plugin.c @@ -28,6 +28,20 @@ #ifdef HAVE_FREEIPMI +#define IPMI_PARSE_DEVICE_LAN_STR "lan" +#define IPMI_PARSE_DEVICE_LAN_2_0_STR "lan_2_0" +#define IPMI_PARSE_DEVICE_LAN_2_0_STR2 "lan20" +#define IPMI_PARSE_DEVICE_LAN_2_0_STR3 "lan_20" +#define IPMI_PARSE_DEVICE_LAN_2_0_STR4 "lan2_0" +#define IPMI_PARSE_DEVICE_LAN_2_0_STR5 "lanplus" +#define IPMI_PARSE_DEVICE_KCS_STR "kcs" +#define IPMI_PARSE_DEVICE_SSIF_STR "ssif" +#define IPMI_PARSE_DEVICE_OPENIPMI_STR "openipmi" +#define IPMI_PARSE_DEVICE_OPENIPMI_STR2 "open" +#define IPMI_PARSE_DEVICE_SUNBMC_STR "sunbmc" +#define IPMI_PARSE_DEVICE_SUNBMC_STR2 "bmc" +#define IPMI_PARSE_DEVICE_INTELDCMI_STR "inteldcmi" + // ---------------------------------------------------------------------------- // callback required by fatal() @@ -1548,6 +1562,49 @@ int ipmi_detect_speed_secs(struct ipmi_monitoring_ipmi_config *ipmi_config) { return (int)(( total * 2 / checks / 1000000 ) + 1); } +int parse_inband_driver_type (const char *str) +{ + assert (str); + + if (strcasecmp (str, IPMI_PARSE_DEVICE_KCS_STR) == 0) + return (IPMI_MONITORING_DRIVER_TYPE_KCS); + else if (strcasecmp (str, IPMI_PARSE_DEVICE_SSIF_STR) == 0) + return (IPMI_MONITORING_DRIVER_TYPE_SSIF); + /* support "open" for those that might be used to + * ipmitool. + */ + else if (strcasecmp (str, IPMI_PARSE_DEVICE_OPENIPMI_STR) == 0 + || strcasecmp (str, IPMI_PARSE_DEVICE_OPENIPMI_STR2) == 0) + return (IPMI_MONITORING_DRIVER_TYPE_OPENIPMI); + /* support "bmc" for those that might be used to + * ipmitool. + */ + else if (strcasecmp (str, IPMI_PARSE_DEVICE_SUNBMC_STR) == 0 + || strcasecmp (str, IPMI_PARSE_DEVICE_SUNBMC_STR2) == 0) + return (IPMI_MONITORING_DRIVER_TYPE_SUNBMC); + + return (-1); +} + +int parse_outofband_driver_type (const char *str) +{ + assert (str); + + if (strcasecmp (str, IPMI_PARSE_DEVICE_LAN_STR) == 0) + return (IPMI_MONITORING_PROTOCOL_VERSION_1_5); + /* support "lanplus" for those that might be used to ipmitool. + * support typo variants to ease. + */ + else if (strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR) == 0 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR2) == 0 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR3) == 0 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR4) == 0 + || strcasecmp (str, IPMI_PARSE_DEVICE_LAN_2_0_STR5) == 0) + return (IPMI_MONITORING_PROTOCOL_VERSION_2_0); + + return (-1); +} + int main (int argc, char **argv) { // ------------------------------------------------------------------------ @@ -1618,6 +1675,12 @@ int main (int argc, char **argv) { " password PASS connect to remote IPMI host\n" " default: local IPMI processor\n" "\n" + " driver-type IPMIDRIVER\n" + " Specify the driver type to use instead of doing an auto selection. \n" + " The currently available outofband drivers are LAN and LAN_2_0,\n" + " which perform IPMI 1.5 and IPMI 2.0 respectively. \n" + " The currently available inband drivers are KCS, SSIF, OPENIPMI and SUNBMC.\n" + "\n" " sdr-cache-dir PATH directory for SDR cache files\n" " default: %s\n" "\n" @@ -1676,6 +1739,17 @@ int main (int argc, char **argv) { if(debug) fprintf(stderr, "freeipmi.plugin: password set to '%s'\n", password); continue; } + else if(strcmp("driver-type", argv[i]) == 0) { + if (hostname) { + protocol_version=parse_outofband_driver_type(argv[++i]); + if(debug) fprintf(stderr, "freeipmi.plugin: outband protocol version set to '%d'\n", protocol_version); + } + else { + driver_type=parse_inband_driver_type(argv[++i]); + if(debug) fprintf(stderr, "freeipmi.plugin: inband driver type set to '%d'\n", driver_type); + } + continue; + } else if(i < argc && strcmp("sdr-cache-dir", argv[i]) == 0) { sdr_cache_directory = argv[++i]; if(debug) fprintf(stderr, "freeipmi.plugin: SDR cache directory set to '%s'\n", sdr_cache_directory); |