From 66564c2324abc58b24327b763e1113ff781156a2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 21 Feb 2019 20:34:01 +0100 Subject: Adding upstream version 1.12.1. Signed-off-by: Daniel Baumann --- collectors/freeipmi.plugin/freeipmi_plugin.c | 74 ++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'collectors/freeipmi.plugin/freeipmi_plugin.c') diff --git a/collectors/freeipmi.plugin/freeipmi_plugin.c b/collectors/freeipmi.plugin/freeipmi_plugin.c index 35b9a0032..d42ada1b4 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); -- cgit v1.2.3