diff --git a/receivers.json b/receivers.json index 14176b4..ae07225 100644 --- a/receivers.json +++ b/receivers.json @@ -32,19 +32,15 @@ { "username": "username-1", "password": "password-1", - "endpoint": "ipmi-sensors://my-endpoint-1", - "host_list": [ - "my-host-1" - ] + "endpoint": "ipmi-sensors://%h-ipmi", + "host_list": "my-host-1-[1-2]" }, { "username": "username-2", "password": "password-2", - "endpoint": "ipmi-sensors://my-endpoint-2", - "host_list": [ - "my-host-2" - ] + "endpoint": "ipmi-sensors://%h-ipmi", + "host_list": "my-host-2-[1,2]" } ] } -} \ No newline at end of file +} diff --git a/receivers/ipmiReceiver.go b/receivers/ipmiReceiver.go index b00df96..7eecba1 100644 --- a/receivers/ipmiReceiver.go +++ b/receivers/ipmiReceiver.go @@ -15,6 +15,7 @@ import ( cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger" lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric" + "github.com/ClusterCockpit/cc-metric-collector/pkg/hostlist" ) type IPMIReceiverClientConfig struct { @@ -319,12 +320,12 @@ func NewIPMIReceiver(name string, config json.RawMessage) (Receiver, error) { ExcludeMetrics []string `json:"exclude_metrics,omitempty"` ClientConfigs []struct { - Fanout int `json:"fanout,omitempty"` // Maximum number of simultaneous IPMI connections (default: 64) - DriverType string `json:"driver_type,omitempty"` // Out of band IPMI driver (default: LAN_2_0) - HostList []string `json:"host_list"` // List of hosts with the same client configuration - Username *string `json:"username"` // User name to authenticate with - Password *string `json:"password"` // Password to use for authentication - Endpoint *string `json:"endpoint"` // URL of the IPMI service + Fanout int `json:"fanout,omitempty"` // Maximum number of simultaneous IPMI connections (default: 64) + DriverType string `json:"driver_type,omitempty"` // Out of band IPMI driver (default: LAN_2_0) + HostList string `json:"host_list"` // List of hosts with the same client configuration + Username *string `json:"username"` // User name to authenticate with + Password *string `json:"password"` // Password to use for authentication + Endpoint *string `json:"endpoint"` // URL of the IPMI service // Per client excluded metrics ExcludeMetrics []string `json:"exclude_metrics,omitempty"` @@ -435,10 +436,17 @@ func NewIPMIReceiver(name string, config json.RawMessage) (Receiver, error) { return nil, err } - // Create mapping between ipmi hostname and node hostname - // This also guaranties that all ipmi hostnames are uniqu + // Create mapping between IPMI host name and node host name + // This also guaranties that all IPMI host names are unique ipmi2HostMapping := make(map[string]string) - for _, host := range clientConfigJSON.HostList { + hostList, err := hostlist.Expand(clientConfigJSON.HostList) + if err != nil { + err := fmt.Errorf("client config number %d failed to parse host list %s: %v", + i, clientConfigJSON.HostList, err) + cclog.ComponentError(r.name, err) + return nil, err + } + for _, host := range hostList { ipmiHost := strings.Replace(host_pattern, "%h", host, -1) ipmi2HostMapping[ipmiHost] = host } diff --git a/receivers/ipmiReceiver.md b/receivers/ipmiReceiver.md index a82211e..cdf8e72 100644 --- a/receivers/ipmiReceiver.md +++ b/receivers/ipmiReceiver.md @@ -16,10 +16,10 @@ The IPMI Receiver uses `ipmi-sensors` from the [FreeIPMI](https://www.gnu.org/so "exclude_metrics": [ "fan_speed", "voltage" ], "client_config": [ { - "host_list": ["n1", "n2", "n3", "n4" ] + "host_list": "n[1,2-4]" }, { - "host_list": [ "n5", "n6" ], + "host_list": "n[5-6]", "driver_type": "LAN", "cli_options": [ "--workaround-flags=..." ], "password": ""