mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 07:09:04 +01:00
Use package hostlist to expand a host list
This commit is contained in:
parent
6f1f33f3a5
commit
31a8e63d72
@ -7,23 +7,23 @@
|
|||||||
},
|
},
|
||||||
"redfish_recv": {
|
"redfish_recv": {
|
||||||
"type": "redfish",
|
"type": "redfish",
|
||||||
|
"endpoint": "https://%h-bmc",
|
||||||
"client_config": [
|
"client_config": [
|
||||||
{
|
{
|
||||||
"hostname": "my-host-1",
|
"host_list": "my-host-1-[1-2]",
|
||||||
"username": "username-1",
|
"username": "username-1",
|
||||||
"password": "password-1",
|
"password": "password-1"
|
||||||
"endpoint": "https://my-endpoint-1"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hostname": "my-host-2",
|
"host_list": "my-host-2-[1,2]",
|
||||||
"username": "username-2",
|
"username": "username-2",
|
||||||
"password": "password-2",
|
"password": "password-2"
|
||||||
"endpoint": "https://my-endpoint-2"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ipmi_recv": {
|
"ipmi_recv": {
|
||||||
"type": "ipmi",
|
"type": "ipmi",
|
||||||
|
"endpoint": "ipmi-sensors://%h-ipmi",
|
||||||
"exclude_metrics": [
|
"exclude_metrics": [
|
||||||
"fan_speed",
|
"fan_speed",
|
||||||
"voltage"
|
"voltage"
|
||||||
@ -32,15 +32,13 @@
|
|||||||
{
|
{
|
||||||
"username": "username-1",
|
"username": "username-1",
|
||||||
"password": "password-1",
|
"password": "password-1",
|
||||||
"endpoint": "ipmi-sensors://%h-ipmi",
|
|
||||||
"host_list": "my-host-1-[1-2]"
|
"host_list": "my-host-1-[1-2]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"username": "username-2",
|
"username": "username-2",
|
||||||
"password": "password-2",
|
"password": "password-2",
|
||||||
"endpoint": "ipmi-sensors://%h-ipmi",
|
|
||||||
"host_list": "my-host-2-[1,2]"
|
"host_list": "my-host-2-[1,2]"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ The IPMI Receiver uses `ipmi-sensors` from the [FreeIPMI](https://www.gnu.org/so
|
|||||||
"fanout": 256,
|
"fanout": 256,
|
||||||
"username": "<Username>",
|
"username": "<Username>",
|
||||||
"password": "<Password>",
|
"password": "<Password>",
|
||||||
"endpoint": "ipmi-sensors://%h-p",
|
"endpoint": "ipmi-sensors://%h-bmc",
|
||||||
"exclude_metrics": [ "fan_speed", "voltage" ],
|
"exclude_metrics": [ "fan_speed", "voltage" ],
|
||||||
"client_config": [
|
"client_config": [
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
|
cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
|
||||||
|
"github.com/ClusterCockpit/cc-metric-collector/pkg/hostlist"
|
||||||
|
|
||||||
// See: https://pkg.go.dev/github.com/stmcginnis/gofish
|
// See: https://pkg.go.dev/github.com/stmcginnis/gofish
|
||||||
"github.com/stmcginnis/gofish"
|
"github.com/stmcginnis/gofish"
|
||||||
@ -630,10 +631,10 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) {
|
|||||||
ExcludeMetrics []string `json:"exclude_metrics,omitempty"`
|
ExcludeMetrics []string `json:"exclude_metrics,omitempty"`
|
||||||
|
|
||||||
ClientConfigs []struct {
|
ClientConfigs []struct {
|
||||||
HostList []string `json:"host_list"` // List of hosts with the same client configuration
|
HostList string `json:"host_list"` // List of hosts with the same client configuration
|
||||||
Username *string `json:"username"` // User name to authenticate with
|
Username *string `json:"username"` // User name to authenticate with
|
||||||
Password *string `json:"password"` // Password to use for authentication
|
Password *string `json:"password"` // Password to use for authentication
|
||||||
Endpoint *string `json:"endpoint"` // URL of the redfish service
|
Endpoint *string `json:"endpoint"` // URL of the redfish service
|
||||||
|
|
||||||
// Per client disable collection of power,processor or thermal metrics
|
// Per client disable collection of power,processor or thermal metrics
|
||||||
DisablePowerMetrics bool `json:"disable_power_metrics"`
|
DisablePowerMetrics bool `json:"disable_power_metrics"`
|
||||||
@ -763,7 +764,14 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) {
|
|||||||
isExcluded[key] = true
|
isExcluded[key] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
// Endpoint of the redfish service
|
// Endpoint of the redfish service
|
||||||
endpoint := strings.Replace(endpoint_pattern, "%h", host, -1)
|
endpoint := strings.Replace(endpoint_pattern, "%h", host, -1)
|
||||||
|
@ -8,22 +8,22 @@ The Redfish receiver uses the [Redfish (specification)](https://www.dmtf.org/sta
|
|||||||
{
|
{
|
||||||
"<redfish receiver name>": {
|
"<redfish receiver name>": {
|
||||||
"type": "redfish",
|
"type": "redfish",
|
||||||
"username": "<user A>",
|
"username": "<Username>",
|
||||||
"password": "<password A>",
|
"password": "<Password>",
|
||||||
"endpoint": "https://%h-bmc",
|
"endpoint": "https://%h-bmc",
|
||||||
"exclude_metrics": [ "min_consumed_watts" ],
|
"exclude_metrics": [ "min_consumed_watts" ],
|
||||||
"client_config": [
|
"client_config": [
|
||||||
{
|
{
|
||||||
"host_list": [ "<host 1>", "<host 2>" ]
|
"host_list": "n[1,2-4]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"host_list": [ "<host 3>", "<host 4>" ]
|
"host_list": "n5"
|
||||||
"disable_power_metrics": true
|
"disable_power_metrics": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"host_list": [ "<host 5>" ],
|
"host_list": "n6" ],
|
||||||
"username": "<user B>",
|
"username": "<Username 2>",
|
||||||
"password": "<password B>",
|
"password": "<Password 2>",
|
||||||
"endpoint": "https://%h-BMC",
|
"endpoint": "https://%h-BMC",
|
||||||
"disable_thermal_metrics": true
|
"disable_thermal_metrics": true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user