feat(inputs.openstack): Gather cinder services (#13443)
This commit is contained in:
parent
62dc1684f0
commit
33be0dc081
|
|
@ -83,8 +83,9 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
password = "password"
|
password = "password"
|
||||||
|
|
||||||
## Available services are:
|
## Available services are:
|
||||||
## "agents", "aggregates", "flavors", "hypervisors", "networks", "nova_services",
|
## "agents", "aggregates", "cinder_services", "flavors", "hypervisors", "networks",
|
||||||
## "ports", "projects", "servers", "services", "stacks", "storage_pools", "subnets", "volumes"
|
## "nova_services", "ports", "projects", "servers", "services", "stacks", "storage_pools",
|
||||||
|
## "subnets", "volumes"
|
||||||
# enabled_services = ["services", "projects", "hypervisors", "flavors", "networks", "volumes"]
|
# enabled_services = ["services", "projects", "hypervisors", "flavors", "networks", "volumes"]
|
||||||
|
|
||||||
## Collect Server Diagnostics
|
## Collect Server Diagnostics
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"github.com/gophercloud/gophercloud"
|
"github.com/gophercloud/gophercloud"
|
||||||
"github.com/gophercloud/gophercloud/openstack"
|
"github.com/gophercloud/gophercloud/openstack"
|
||||||
"github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/schedulerstats"
|
"github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/schedulerstats"
|
||||||
|
cinder_services "github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/services"
|
||||||
"github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumetenants"
|
"github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumetenants"
|
||||||
"github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes"
|
"github.com/gophercloud/gophercloud/openstack/blockstorage/v3/volumes"
|
||||||
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/aggregates"
|
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/aggregates"
|
||||||
|
|
@ -201,19 +202,20 @@ func (o *OpenStack) Gather(acc telegraf.Accumulator) error {
|
||||||
// Gather resources. Note service harvesting must come first as the other
|
// Gather resources. Note service harvesting must come first as the other
|
||||||
// gatherers are dependant on this information.
|
// gatherers are dependant on this information.
|
||||||
gatherers := map[string]func(telegraf.Accumulator) error{
|
gatherers := map[string]func(telegraf.Accumulator) error{
|
||||||
"projects": o.gatherProjects,
|
"projects": o.gatherProjects,
|
||||||
"hypervisors": o.gatherHypervisors,
|
"hypervisors": o.gatherHypervisors,
|
||||||
"flavors": o.gatherFlavors,
|
"flavors": o.gatherFlavors,
|
||||||
"servers": o.gatherServers,
|
"servers": o.gatherServers,
|
||||||
"volumes": o.gatherVolumes,
|
"volumes": o.gatherVolumes,
|
||||||
"storage_pools": o.gatherStoragePools,
|
"storage_pools": o.gatherStoragePools,
|
||||||
"subnets": o.gatherSubnets,
|
"subnets": o.gatherSubnets,
|
||||||
"ports": o.gatherPorts,
|
"ports": o.gatherPorts,
|
||||||
"networks": o.gatherNetworks,
|
"networks": o.gatherNetworks,
|
||||||
"aggregates": o.gatherAggregates,
|
"aggregates": o.gatherAggregates,
|
||||||
"nova_services": o.gatherNovaServices,
|
"nova_services": o.gatherNovaServices,
|
||||||
"agents": o.gatherAgents,
|
"cinder_services": o.gatherCinderServices,
|
||||||
"stacks": o.gatherStacks,
|
"agents": o.gatherAgents,
|
||||||
|
"stacks": o.gatherStacks,
|
||||||
}
|
}
|
||||||
|
|
||||||
callDuration := map[string]interface{}{}
|
callDuration := map[string]interface{}{}
|
||||||
|
|
@ -328,6 +330,38 @@ func (o *OpenStack) gatherNovaServices(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gatherCinderServices collects and accumulates cinder_services data from the OpenStack API.
|
||||||
|
func (o *OpenStack) gatherCinderServices(acc telegraf.Accumulator) error {
|
||||||
|
page, err := cinder_services.List(o.volume, &cinder_services.ListOpts{}).AllPages()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to list cinder_services: %w", err)
|
||||||
|
}
|
||||||
|
cinderServices, err := cinder_services.ExtractServices(page)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to extract cinder_services: %w", err)
|
||||||
|
}
|
||||||
|
for _, cinderService := range cinderServices {
|
||||||
|
tags := map[string]string{
|
||||||
|
"name": cinderService.Binary,
|
||||||
|
"cluster": cinderService.Cluster,
|
||||||
|
"host_machine": cinderService.Host,
|
||||||
|
"state": cinderService.State,
|
||||||
|
"status": strings.ToLower(cinderService.Status),
|
||||||
|
"zone": cinderService.Zone,
|
||||||
|
}
|
||||||
|
fields := map[string]interface{}{
|
||||||
|
"id": cinderService.ActiveBackendID,
|
||||||
|
"disabled_reason": cinderService.DisabledReason,
|
||||||
|
"frozen": cinderService.Frozen,
|
||||||
|
"replication_status": cinderService.ReplicationStatus,
|
||||||
|
"updated_at": o.convertTimeFormat(cinderService.UpdatedAt),
|
||||||
|
}
|
||||||
|
acc.AddFields("openstack_cinder_service", fields, tags)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// gatherSubnets collects and accumulates subnets data from the OpenStack API.
|
// gatherSubnets collects and accumulates subnets data from the OpenStack API.
|
||||||
func (o *OpenStack) gatherSubnets(acc telegraf.Accumulator) error {
|
func (o *OpenStack) gatherSubnets(acc telegraf.Accumulator) error {
|
||||||
page, err := subnets.List(o.network, &subnets.ListOpts{}).AllPages()
|
page, err := subnets.List(o.network, &subnets.ListOpts{}).AllPages()
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@
|
||||||
password = "password"
|
password = "password"
|
||||||
|
|
||||||
## Available services are:
|
## Available services are:
|
||||||
## "agents", "aggregates", "flavors", "hypervisors", "networks", "nova_services",
|
## "agents", "aggregates", "cinder_services", "flavors", "hypervisors", "networks",
|
||||||
## "ports", "projects", "servers", "services", "stacks", "storage_pools", "subnets", "volumes"
|
## "nova_services", "ports", "projects", "servers", "services", "stacks", "storage_pools",
|
||||||
|
## "subnets", "volumes"
|
||||||
# enabled_services = ["services", "projects", "hypervisors", "flavors", "networks", "volumes"]
|
# enabled_services = ["services", "projects", "hypervisors", "flavors", "networks", "volumes"]
|
||||||
|
|
||||||
## Collect Server Diagnostics
|
## Collect Server Diagnostics
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue