From e812584f27f0fd3aababb1f6d747308a0ca552d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 24 Nov 2024 13:18:14 +0100 Subject: [PATCH] smb: extend smb share metrics (#1765) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- internal/collector/ad/ad.go | 2 +- internal/collector/adcs/adcs.go | 2 +- internal/collector/cache/cache.go | 4 +- internal/collector/cpu/cpu.go | 2 +- internal/collector/dfsr/dfsr.go | 6 +- internal/collector/dhcp/dhcp.go | 2 +- internal/collector/dns/dns.go | 4 +- .../exchange/exchange_active_sync.go | 2 +- .../exchange/exchange_ad_access_processes.go | 2 +- .../exchange/exchange_autodiscover.go | 2 +- .../exchange/exchange_availability_service.go | 2 +- .../collector/exchange/exchange_http_proxy.go | 2 +- .../exchange/exchange_mapi_http_emsmdb.go | 2 +- .../exchange/exchange_outlook_web_access.go | 2 +- .../exchange/exchange_rpc_client_access.go | 2 +- .../exchange/exchange_transport_queues.go | 2 +- .../exchange/exchange_workload_management.go | 2 +- internal/collector/hyperv/hyperv_datastore.go | 2 +- .../hyperv/hyperv_dynamic_memory_balancer.go | 2 +- .../hyperv/hyperv_dynamic_memory_vm.go | 2 +- .../hyperv_hypervisor_logical_processor.go | 2 +- ...yperv_hypervisor_root_virtual_processor.go | 2 +- .../hyperv_hypervisor_virtual_processor.go | 2 +- .../hyperv/hyperv_legacy_network_adapter.go | 2 +- .../hyperv_virtual_machine_health_summary.go | 2 +- .../hyperv_virtual_machine_vid_partition.go | 2 +- .../hyperv/hyperv_virtual_network_adapter.go | 2 +- ...rv_virtual_network_adapter_drop_reasons.go | 2 +- .../collector/hyperv/hyperv_virtual_smb.go | 2 +- .../hyperv/hyperv_virtual_storage_device.go | 2 +- .../collector/hyperv/hyperv_virtual_switch.go | 2 +- internal/collector/iis/iis_app_pool_was.go | 2 +- internal/collector/iis/iis_w3svc_w3wp.go | 5 +- internal/collector/iis/iis_web_service.go | 2 +- .../collector/iis/iis_web_service_cache.go | 2 +- .../collector/logical_disk/logical_disk.go | 2 +- internal/collector/memory/memory.go | 4 +- .../collector/mssql/mssql_access_methods.go | 2 +- .../mssql/mssql_availability_replica.go | 2 +- internal/collector/mssql/mssql_database.go | 2 +- .../collector/mssql/mssql_database_replica.go | 2 +- .../mssql/mssql_general_statistics.go | 2 +- internal/collector/mssql/mssql_locks.go | 2 +- .../collector/mssql/mssql_memory_manager.go | 4 +- internal/collector/mssql/mssql_sql_errors.go | 2 +- internal/collector/mssql/mssql_sql_stats.go | 2 +- .../collector/mssql/mssql_transactions.go | 2 +- internal/collector/mssql/mssql_wait_stats.go | 2 +- internal/collector/net/net.go | 2 +- internal/collector/nps/nps.go | 4 +- internal/collector/pagefile/pagefile.go | 2 +- internal/collector/perfdata/perfdata.go | 2 +- .../collector/physical_disk/physical_disk.go | 2 +- internal/collector/process/process.go | 8 +- internal/collector/remote_fx/remote_fx.go | 4 +- internal/collector/smb/const.go | 6 + internal/collector/smb/smb.go | 128 +++++++++++++++--- internal/collector/smbclient/smbclient.go | 2 +- internal/collector/smtp/smtp.go | 2 +- internal/collector/system/system.go | 2 +- internal/collector/tcp/tcp.go | 8 +- .../terminal_services/terminal_services.go | 6 +- internal/collector/time/time.go | 2 +- internal/collector/udp/udp.go | 8 +- internal/collector/vmware/vmware.go | 6 +- internal/perfdata/collector.go | 14 +- internal/perfdata/types.go | 5 +- 67 files changed, 209 insertions(+), 115 deletions(-) diff --git a/internal/collector/ad/ad.go b/internal/collector/ad/ad.go index f568c2d82..4e7e94ad2 100644 --- a/internal/collector/ad/ad.go +++ b/internal/collector/ad/ad.go @@ -265,7 +265,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("DirectoryServices", perfdata.InstanceAll, counters) + c.perfDataCollector, err = perfdata.NewCollector("DirectoryServices", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create DirectoryServices collector: %w", err) } diff --git a/internal/collector/adcs/adcs.go b/internal/collector/adcs/adcs.go index a434e30d1..e53595c0e 100644 --- a/internal/collector/adcs/adcs.go +++ b/internal/collector/adcs/adcs.go @@ -70,7 +70,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("Certification Authority", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("Certification Authority", perfdata.InstancesAll, []string{ requestsPerSecond, requestProcessingTime, retrievalsPerSecond, diff --git a/internal/collector/cache/cache.go b/internal/collector/cache/cache.go index 2f5a46996..a9b9aa83a 100644 --- a/internal/collector/cache/cache.go +++ b/internal/collector/cache/cache.go @@ -86,7 +86,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("Cache", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("Cache", perfdata.InstancesAll, []string{ asyncCopyReadsTotal, asyncDataMapsTotal, asyncFastReadsTotal, @@ -306,7 +306,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect Cache metrics: %w", err) } - cacheData, ok := data[perfdata.EmptyInstance] + cacheData, ok := data[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for Cache returned empty result set") diff --git a/internal/collector/cpu/cpu.go b/internal/collector/cpu/cpu.go index 30e43bee8..5e98a4b8e 100644 --- a/internal/collector/cpu/cpu.go +++ b/internal/collector/cpu/cpu.go @@ -78,7 +78,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { c.mu = sync.Mutex{} - c.perfDataCollector, err = perfdata.NewCollector("Processor Information", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("Processor Information", perfdata.InstancesAll, []string{ c1TimeSeconds, c2TimeSeconds, c3TimeSeconds, diff --git a/internal/collector/dfsr/dfsr.go b/internal/collector/dfsr/dfsr.go index 538bd8484..05cc52a34 100644 --- a/internal/collector/dfsr/dfsr.go +++ b/internal/collector/dfsr/dfsr.go @@ -146,7 +146,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { var err error if slices.Contains(c.config.CollectorsEnabled, "connection") { - c.perfDataCollectorConnection, err = perfdata.NewCollector("DFS Replication Connections", perfdata.InstanceAll, []string{ + c.perfDataCollectorConnection, err = perfdata.NewCollector("DFS Replication Connections", perfdata.InstancesAll, []string{ bandwidthSavingsUsingDFSReplicationTotal, bytesReceivedTotal, compressedSizeOfFilesReceivedTotal, @@ -163,7 +163,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { } if slices.Contains(c.config.CollectorsEnabled, "folder") { - c.perfDataCollectorFolder, err = perfdata.NewCollector("DFS Replicated Folders", perfdata.InstanceAll, []string{ + c.perfDataCollectorFolder, err = perfdata.NewCollector("DFS Replicated Folders", perfdata.InstancesAll, []string{ bandwidthSavingsUsingDFSReplicationTotal, compressedSizeOfFilesReceivedTotal, conflictBytesCleanedUpTotal, @@ -198,7 +198,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { } if slices.Contains(c.config.CollectorsEnabled, "volume") { - c.perfDataCollectorVolume, err = perfdata.NewCollector("DFS Replication Service Volumes", perfdata.InstanceAll, []string{ + c.perfDataCollectorVolume, err = perfdata.NewCollector("DFS Replication Service Volumes", perfdata.InstancesAll, []string{ databaseCommitsTotal, databaseLookupsTotal, usnJournalRecordsReadTotal, diff --git a/internal/collector/dhcp/dhcp.go b/internal/collector/dhcp/dhcp.go index de4b16111..4039d14f7 100644 --- a/internal/collector/dhcp/dhcp.go +++ b/internal/collector/dhcp/dhcp.go @@ -273,7 +273,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect DHCP Server metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for DHCP Server returned empty result set") } diff --git a/internal/collector/dns/dns.go b/internal/collector/dns/dns.go index b0238c9b9..ceed9d0b7 100644 --- a/internal/collector/dns/dns.go +++ b/internal/collector/dns/dns.go @@ -79,7 +79,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("DNS", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("DNS", perfdata.InstancesAll, []string{ axfrRequestReceived, axfrRequestSent, axfrResponseReceived, @@ -269,7 +269,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect DNS metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for DNS returned empty result set") } diff --git a/internal/collector/exchange/exchange_active_sync.go b/internal/collector/exchange/exchange_active_sync.go index 5bca8b947..f95431abf 100644 --- a/internal/collector/exchange/exchange_active_sync.go +++ b/internal/collector/exchange/exchange_active_sync.go @@ -26,7 +26,7 @@ func (c *Collector) buildActiveSync() error { var err error - c.perfDataCollectorActiveSync, err = perfdata.NewCollector("MSExchange ActiveSync", perfdata.InstanceAll, counters) + c.perfDataCollectorActiveSync, err = perfdata.NewCollector("MSExchange ActiveSync", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange ActiveSync collector: %w", err) } diff --git a/internal/collector/exchange/exchange_ad_access_processes.go b/internal/collector/exchange/exchange_ad_access_processes.go index b1ad3ada1..499ab9a2e 100644 --- a/internal/collector/exchange/exchange_ad_access_processes.go +++ b/internal/collector/exchange/exchange_ad_access_processes.go @@ -30,7 +30,7 @@ func (c *Collector) buildADAccessProcesses() error { var err error - c.perfDataCollectorADAccessProcesses, err = perfdata.NewCollector("MSExchange ADAccess Processes", perfdata.InstanceAll, counters) + c.perfDataCollectorADAccessProcesses, err = perfdata.NewCollector("MSExchange ADAccess Processes", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange ADAccess Processes collector: %w", err) } diff --git a/internal/collector/exchange/exchange_autodiscover.go b/internal/collector/exchange/exchange_autodiscover.go index 9dad12ea3..8206dd4b6 100644 --- a/internal/collector/exchange/exchange_autodiscover.go +++ b/internal/collector/exchange/exchange_autodiscover.go @@ -18,7 +18,7 @@ func (c *Collector) buildAutoDiscover() error { var err error - c.perfDataCollectorAutoDiscover, err = perfdata.NewCollector("MSExchange Autodiscover", perfdata.InstanceAll, counters) + c.perfDataCollectorAutoDiscover, err = perfdata.NewCollector("MSExchange Autodiscover", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange Autodiscover collector: %w", err) } diff --git a/internal/collector/exchange/exchange_availability_service.go b/internal/collector/exchange/exchange_availability_service.go index abfcdf869..800da8a22 100644 --- a/internal/collector/exchange/exchange_availability_service.go +++ b/internal/collector/exchange/exchange_availability_service.go @@ -18,7 +18,7 @@ func (c *Collector) buildAvailabilityService() error { var err error - c.perfDataCollectorAvailabilityService, err = perfdata.NewCollector("MSExchange Availability Service", perfdata.InstanceAll, counters) + c.perfDataCollectorAvailabilityService, err = perfdata.NewCollector("MSExchange Availability Service", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange Availability Service collector: %w", err) } diff --git a/internal/collector/exchange/exchange_http_proxy.go b/internal/collector/exchange/exchange_http_proxy.go index d4be48301..d28446476 100644 --- a/internal/collector/exchange/exchange_http_proxy.go +++ b/internal/collector/exchange/exchange_http_proxy.go @@ -32,7 +32,7 @@ func (c *Collector) buildHTTPProxy() error { var err error - c.perfDataCollectorHttpProxy, err = perfdata.NewCollector("MSExchange HttpProxy", perfdata.InstanceAll, counters) + c.perfDataCollectorHttpProxy, err = perfdata.NewCollector("MSExchange HttpProxy", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange HttpProxy collector: %w", err) } diff --git a/internal/collector/exchange/exchange_mapi_http_emsmdb.go b/internal/collector/exchange/exchange_mapi_http_emsmdb.go index 1c1e68d40..58561b709 100644 --- a/internal/collector/exchange/exchange_mapi_http_emsmdb.go +++ b/internal/collector/exchange/exchange_mapi_http_emsmdb.go @@ -22,7 +22,7 @@ func (c *Collector) buildMapiHttpEmsmdb() error { var err error - c.perfDataCollectorMapiHttpEmsmdb, err = perfdata.NewCollector("MSExchange MapiHttp Emsmdb", perfdata.InstanceAll, counters) + c.perfDataCollectorMapiHttpEmsmdb, err = perfdata.NewCollector("MSExchange MapiHttp Emsmdb", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange MapiHttp Emsmdb: %w", err) } diff --git a/internal/collector/exchange/exchange_outlook_web_access.go b/internal/collector/exchange/exchange_outlook_web_access.go index 2391897ff..7e5137ff8 100644 --- a/internal/collector/exchange/exchange_outlook_web_access.go +++ b/internal/collector/exchange/exchange_outlook_web_access.go @@ -24,7 +24,7 @@ func (c *Collector) buildOWA() error { var err error - c.perfDataCollectorOWA, err = perfdata.NewCollector("MSExchange OWA", perfdata.InstanceAll, counters) + c.perfDataCollectorOWA, err = perfdata.NewCollector("MSExchange OWA", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange OWA collector: %w", err) } diff --git a/internal/collector/exchange/exchange_rpc_client_access.go b/internal/collector/exchange/exchange_rpc_client_access.go index 76d3d0c7b..aaa967975 100644 --- a/internal/collector/exchange/exchange_rpc_client_access.go +++ b/internal/collector/exchange/exchange_rpc_client_access.go @@ -32,7 +32,7 @@ func (c *Collector) buildRPC() error { var err error - c.perfDataCollectorRpcClientAccess, err = perfdata.NewCollector("MSExchange RpcClientAccess", perfdata.InstanceAll, counters) + c.perfDataCollectorRpcClientAccess, err = perfdata.NewCollector("MSExchange RpcClientAccess", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange RpcClientAccess collector: %w", err) } diff --git a/internal/collector/exchange/exchange_transport_queues.go b/internal/collector/exchange/exchange_transport_queues.go index a42caf1f1..cc1f68112 100644 --- a/internal/collector/exchange/exchange_transport_queues.go +++ b/internal/collector/exchange/exchange_transport_queues.go @@ -58,7 +58,7 @@ func (c *Collector) buildTransportQueues() error { var err error - c.perfDataCollectorTransportQueues, err = perfdata.NewCollector("MSExchangeTransport Queues", perfdata.InstanceAll, counters) + c.perfDataCollectorTransportQueues, err = perfdata.NewCollector("MSExchangeTransport Queues", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchangeTransport Queues collector: %w", err) } diff --git a/internal/collector/exchange/exchange_workload_management.go b/internal/collector/exchange/exchange_workload_management.go index d9f377e52..24fd47c07 100644 --- a/internal/collector/exchange/exchange_workload_management.go +++ b/internal/collector/exchange/exchange_workload_management.go @@ -30,7 +30,7 @@ func (c *Collector) buildWorkloadManagementWorkloads() error { var err error - c.perfDataCollectorWorkloadManagementWorkloads, err = perfdata.NewCollector("MSExchange WorkloadManagement Workloads", perfdata.InstanceAll, counters) + c.perfDataCollectorWorkloadManagementWorkloads, err = perfdata.NewCollector("MSExchange WorkloadManagement Workloads", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create MSExchange WorkloadManagement Workloads collector: %w", err) } diff --git a/internal/collector/hyperv/hyperv_datastore.go b/internal/collector/hyperv/hyperv_datastore.go index 4349e6d3a..9693a3ad3 100644 --- a/internal/collector/hyperv/hyperv_datastore.go +++ b/internal/collector/hyperv/hyperv_datastore.go @@ -114,7 +114,7 @@ const ( func (c *Collector) buildDataStore() error { var err error - c.perfDataCollectorDataStore, err = perfdata.NewCollector("Hyper-V DataStore", perfdata.InstanceAll, []string{ + c.perfDataCollectorDataStore, err = perfdata.NewCollector("Hyper-V DataStore", perfdata.InstancesAll, []string{ dataStoreFragmentationRatio, dataStoreSectorSize, dataStoreDataAlignment, diff --git a/internal/collector/hyperv/hyperv_dynamic_memory_balancer.go b/internal/collector/hyperv/hyperv_dynamic_memory_balancer.go index cfa6e4eec..0bd1988e1 100644 --- a/internal/collector/hyperv/hyperv_dynamic_memory_balancer.go +++ b/internal/collector/hyperv/hyperv_dynamic_memory_balancer.go @@ -30,7 +30,7 @@ func (c *Collector) buildDynamicMemoryBalancer() error { var err error // https://learn.microsoft.com/en-us/archive/blogs/chrisavis/monitoring-dynamic-memory-in-windows-server-hyper-v-2012 - c.perfDataCollectorDynamicMemoryBalancer, err = perfdata.NewCollector("Hyper-V Dynamic Memory Balancer", perfdata.InstanceAll, []string{ + c.perfDataCollectorDynamicMemoryBalancer, err = perfdata.NewCollector("Hyper-V Dynamic Memory Balancer", perfdata.InstancesAll, []string{ vmDynamicMemoryBalancerAvailableMemory, vmDynamicMemoryBalancerAvailableMemoryForBalancing, vmDynamicMemoryBalancerAveragePressure, diff --git a/internal/collector/hyperv/hyperv_dynamic_memory_vm.go b/internal/collector/hyperv/hyperv_dynamic_memory_vm.go index 639c39278..bab052a84 100644 --- a/internal/collector/hyperv/hyperv_dynamic_memory_vm.go +++ b/internal/collector/hyperv/hyperv_dynamic_memory_vm.go @@ -42,7 +42,7 @@ const ( func (c *Collector) buildDynamicMemoryVM() error { var err error - c.perfDataCollectorDynamicMemoryVM, err = perfdata.NewCollector("Hyper-V Dynamic Memory VM", perfdata.InstanceAll, []string{ + c.perfDataCollectorDynamicMemoryVM, err = perfdata.NewCollector("Hyper-V Dynamic Memory VM", perfdata.InstancesAll, []string{ vmMemoryAddedMemory, vmMemoryCurrentPressure, vmMemoryGuestVisiblePhysicalMemory, diff --git a/internal/collector/hyperv/hyperv_hypervisor_logical_processor.go b/internal/collector/hyperv/hyperv_hypervisor_logical_processor.go index 846ba8af6..e31cb0285 100644 --- a/internal/collector/hyperv/hyperv_hypervisor_logical_processor.go +++ b/internal/collector/hyperv/hyperv_hypervisor_logical_processor.go @@ -32,7 +32,7 @@ const ( func (c *Collector) buildHypervisorLogicalProcessor() error { var err error - c.perfDataCollectorHypervisorLogicalProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Logical Processor", perfdata.InstanceAll, []string{ + c.perfDataCollectorHypervisorLogicalProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Logical Processor", perfdata.InstancesAll, []string{ hypervisorLogicalProcessorGuestRunTimePercent, hypervisorLogicalProcessorHypervisorRunTimePercent, hypervisorLogicalProcessorTotalRunTimePercent, diff --git a/internal/collector/hyperv/hyperv_hypervisor_root_virtual_processor.go b/internal/collector/hyperv/hyperv_hypervisor_root_virtual_processor.go index 9c7e1d73e..1b3371a89 100644 --- a/internal/collector/hyperv/hyperv_hypervisor_root_virtual_processor.go +++ b/internal/collector/hyperv/hyperv_hypervisor_root_virtual_processor.go @@ -35,7 +35,7 @@ const ( func (c *Collector) buildHypervisorRootVirtualProcessor() error { var err error - c.perfDataCollectorHypervisorRootVirtualProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Root Virtual Processor", perfdata.InstanceAll, []string{ + c.perfDataCollectorHypervisorRootVirtualProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Root Virtual Processor", perfdata.InstancesAll, []string{ hypervisorRootVirtualProcessorGuestIdleTimePercent, hypervisorRootVirtualProcessorGuestRunTimePercent, hypervisorRootVirtualProcessorHypervisorRunTimePercent, diff --git a/internal/collector/hyperv/hyperv_hypervisor_virtual_processor.go b/internal/collector/hyperv/hyperv_hypervisor_virtual_processor.go index acf5d077e..77bf00814 100644 --- a/internal/collector/hyperv/hyperv_hypervisor_virtual_processor.go +++ b/internal/collector/hyperv/hyperv_hypervisor_virtual_processor.go @@ -35,7 +35,7 @@ const ( func (c *Collector) buildHypervisorVirtualProcessor() error { var err error - c.perfDataCollectorHypervisorVirtualProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Virtual Processor", perfdata.InstanceAll, []string{ + c.perfDataCollectorHypervisorVirtualProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Virtual Processor", perfdata.InstancesAll, []string{ hypervisorVirtualProcessorGuestRunTimePercent, hypervisorVirtualProcessorGuestIdleTimePercent, hypervisorVirtualProcessorHypervisorRunTimePercent, diff --git a/internal/collector/hyperv/hyperv_legacy_network_adapter.go b/internal/collector/hyperv/hyperv_legacy_network_adapter.go index b0ccbccc7..39172001e 100644 --- a/internal/collector/hyperv/hyperv_legacy_network_adapter.go +++ b/internal/collector/hyperv/hyperv_legacy_network_adapter.go @@ -33,7 +33,7 @@ const ( func (c *Collector) buildLegacyNetworkAdapter() error { var err error - c.perfDataCollectorLegacyNetworkAdapter, err = perfdata.NewCollector("Hyper-V Legacy Network Adapter", perfdata.InstanceAll, []string{ + c.perfDataCollectorLegacyNetworkAdapter, err = perfdata.NewCollector("Hyper-V Legacy Network Adapter", perfdata.InstancesAll, []string{ legacyNetworkAdapterBytesDropped, legacyNetworkAdapterBytesReceived, legacyNetworkAdapterBytesSent, diff --git a/internal/collector/hyperv/hyperv_virtual_machine_health_summary.go b/internal/collector/hyperv/hyperv_virtual_machine_health_summary.go index 2e71681ff..4c003c946 100644 --- a/internal/collector/hyperv/hyperv_virtual_machine_health_summary.go +++ b/internal/collector/hyperv/hyperv_virtual_machine_health_summary.go @@ -51,7 +51,7 @@ func (c *Collector) collectVirtualMachineHealthSummary(ch chan<- prometheus.Metr return fmt.Errorf("failed to collect Hyper-V Virtual Machine Health Summary metrics: %w", err) } - healthData, ok := data[perfdata.EmptyInstance] + healthData, ok := data[perfdata.InstanceEmpty] if !ok { return errors.New("no data returned for Hyper-V Virtual Machine Health Summary") } diff --git a/internal/collector/hyperv/hyperv_virtual_machine_vid_partition.go b/internal/collector/hyperv/hyperv_virtual_machine_vid_partition.go index 740d4233a..7808f54ff 100644 --- a/internal/collector/hyperv/hyperv_virtual_machine_vid_partition.go +++ b/internal/collector/hyperv/hyperv_virtual_machine_vid_partition.go @@ -26,7 +26,7 @@ const ( func (c *Collector) buildVirtualMachineVidPartition() error { var err error - c.perfDataCollectorVirtualMachineVidPartition, err = perfdata.NewCollector("Hyper-V VM Vid Partition", perfdata.InstanceAll, []string{ + c.perfDataCollectorVirtualMachineVidPartition, err = perfdata.NewCollector("Hyper-V VM Vid Partition", perfdata.InstancesAll, []string{ physicalPagesAllocated, preferredNUMANodeIndex, remotePhysicalPages, diff --git a/internal/collector/hyperv/hyperv_virtual_network_adapter.go b/internal/collector/hyperv/hyperv_virtual_network_adapter.go index 6ac083e07..35a9c0dc2 100644 --- a/internal/collector/hyperv/hyperv_virtual_network_adapter.go +++ b/internal/collector/hyperv/hyperv_virtual_network_adapter.go @@ -33,7 +33,7 @@ const ( func (c *Collector) buildVirtualNetworkAdapter() error { var err error - c.perfDataCollectorVirtualNetworkAdapter, err = perfdata.NewCollector("Hyper-V Virtual Network Adapter", perfdata.InstanceAll, []string{ + c.perfDataCollectorVirtualNetworkAdapter, err = perfdata.NewCollector("Hyper-V Virtual Network Adapter", perfdata.InstancesAll, []string{ virtualNetworkAdapterBytesReceived, virtualNetworkAdapterBytesSent, virtualNetworkAdapterDroppedPacketsIncoming, diff --git a/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go b/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go index b0dae6573..0a415cc83 100644 --- a/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go +++ b/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go @@ -148,7 +148,7 @@ const ( func (c *Collector) buildVirtualNetworkAdapterDropReasons() error { var err error - c.perfDataCollectorVirtualNetworkAdapterDropReasons, err = perfdata.NewCollector("Hyper-V Virtual Network Adapter Drop Reasons", perfdata.InstanceAll, []string{ + c.perfDataCollectorVirtualNetworkAdapterDropReasons, err = perfdata.NewCollector("Hyper-V Virtual Network Adapter Drop Reasons", perfdata.InstancesAll, []string{ virtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq, virtualNetworkAdapterDropReasonsIncomingNativeFwdingReq, virtualNetworkAdapterDropReasonsOutgoingMTUMismatch, diff --git a/internal/collector/hyperv/hyperv_virtual_smb.go b/internal/collector/hyperv/hyperv_virtual_smb.go index d1a0146cf..90e3f9443 100644 --- a/internal/collector/hyperv/hyperv_virtual_smb.go +++ b/internal/collector/hyperv/hyperv_virtual_smb.go @@ -55,7 +55,7 @@ const ( func (c *Collector) buildVirtualSMB() error { var err error - c.perfDataCollectorVirtualSMB, err = perfdata.NewCollector("Hyper-V Virtual SMB", perfdata.InstanceAll, []string{ + c.perfDataCollectorVirtualSMB, err = perfdata.NewCollector("Hyper-V Virtual SMB", perfdata.InstancesAll, []string{ virtualSMBDirectMappedSections, virtualSMBDirectMappedPages, virtualSMBWriteBytesRDMA, diff --git a/internal/collector/hyperv/hyperv_virtual_storage_device.go b/internal/collector/hyperv/hyperv_virtual_storage_device.go index ce9451a48..36ff55110 100644 --- a/internal/collector/hyperv/hyperv_virtual_storage_device.go +++ b/internal/collector/hyperv/hyperv_virtual_storage_device.go @@ -45,7 +45,7 @@ const ( func (c *Collector) buildVirtualStorageDevice() error { var err error - c.perfDataCollectorVirtualStorageDevice, err = perfdata.NewCollector("Hyper-V Virtual Storage Device", perfdata.InstanceAll, []string{ + c.perfDataCollectorVirtualStorageDevice, err = perfdata.NewCollector("Hyper-V Virtual Storage Device", perfdata.InstancesAll, []string{ virtualStorageDeviceErrorCount, virtualStorageDeviceQueueLength, virtualStorageDeviceReadBytes, diff --git a/internal/collector/hyperv/hyperv_virtual_switch.go b/internal/collector/hyperv/hyperv_virtual_switch.go index 353ee5988..c11680ad8 100644 --- a/internal/collector/hyperv/hyperv_virtual_switch.go +++ b/internal/collector/hyperv/hyperv_virtual_switch.go @@ -62,7 +62,7 @@ const ( func (c *Collector) buildVirtualSwitch() error { var err error - c.perfDataCollectorVirtualSwitch, err = perfdata.NewCollector("Hyper-V Virtual Switch", perfdata.InstanceAll, []string{ + c.perfDataCollectorVirtualSwitch, err = perfdata.NewCollector("Hyper-V Virtual Switch", perfdata.InstancesAll, []string{ virtualSwitchBroadcastPacketsReceived, virtualSwitchBroadcastPacketsSent, virtualSwitchBytes, diff --git a/internal/collector/iis/iis_app_pool_was.go b/internal/collector/iis/iis_app_pool_was.go index e81cb2605..fdf8642be 100644 --- a/internal/collector/iis/iis_app_pool_was.go +++ b/internal/collector/iis/iis_app_pool_was.go @@ -57,7 +57,7 @@ var applicationStates = map[uint32]string{ func (c *Collector) buildAppPoolWAS() error { var err error - c.perfDataCollectorAppPoolWAS, err = perfdata.NewCollector("APP_POOL_WAS", perfdata.InstanceAll, []string{ + c.perfDataCollectorAppPoolWAS, err = perfdata.NewCollector("APP_POOL_WAS", perfdata.InstancesAll, []string{ CurrentApplicationPoolState, CurrentApplicationPoolUptime, CurrentWorkerProcesses, diff --git a/internal/collector/iis/iis_w3svc_w3wp.go b/internal/collector/iis/iis_w3svc_w3wp.go index b3ee59df5..3fdfd04ef 100644 --- a/internal/collector/iis/iis_w3svc_w3wp.go +++ b/internal/collector/iis/iis_w3svc_w3wp.go @@ -182,7 +182,7 @@ func (c *Collector) buildW3SVCW3WP() error { var err error - c.perfDataCollectorW3SVCW3WP, err = perfdata.NewCollector("W3SVC_W3WP", perfdata.InstanceAll, counters) + c.perfDataCollectorW3SVCW3WP, err = perfdata.NewCollector("W3SVC_W3WP", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create W3SVC_W3WP collector: %w", err) } @@ -432,8 +432,7 @@ func (c *Collector) collectW3SVCW3WP(ch chan<- prometheus.Metric) error { pid := workerProcessNameExtractor.ReplaceAllString(name, "$1") name := workerProcessNameExtractor.ReplaceAllString(name, "$2") - if name == "" || name == "_Total" || - c.config.AppExclude.MatchString(name) || + if name == "" || c.config.AppExclude.MatchString(name) || !c.config.AppInclude.MatchString(name) { continue } diff --git a/internal/collector/iis/iis_web_service.go b/internal/collector/iis/iis_web_service.go index 637cdb34a..2087856b3 100644 --- a/internal/collector/iis/iis_web_service.go +++ b/internal/collector/iis/iis_web_service.go @@ -80,7 +80,7 @@ const ( func (c *Collector) buildWebService() error { var err error - c.perfDataCollectorWebService, err = perfdata.NewCollector("Web Service", perfdata.InstanceAll, []string{ + c.perfDataCollectorWebService, err = perfdata.NewCollector("Web Service", perfdata.InstancesAll, []string{ CurrentAnonymousUsers, CurrentBlockedAsyncIORequests, CurrentCGIRequests, diff --git a/internal/collector/iis/iis_web_service_cache.go b/internal/collector/iis/iis_web_service_cache.go index d1d83c950..0086f56c1 100644 --- a/internal/collector/iis/iis_web_service_cache.go +++ b/internal/collector/iis/iis_web_service_cache.go @@ -87,7 +87,7 @@ const ( func (c *Collector) buildWebServiceCache() error { var err error - c.perfDataCollectorWebService, err = perfdata.NewCollector("Web Service Cache", perfdata.InstanceAll, []string{ + c.perfDataCollectorWebService, err = perfdata.NewCollector("Web Service Cache", perfdata.InstancesAll, []string{ ServiceCacheActiveFlushedEntries, ServiceCacheCurrentFileCacheMemoryUsage, ServiceCacheMaximumFileCacheMemoryUsage, diff --git a/internal/collector/logical_disk/logical_disk.go b/internal/collector/logical_disk/logical_disk.go index 466809b22..f3c5b04a0 100644 --- a/internal/collector/logical_disk/logical_disk.go +++ b/internal/collector/logical_disk/logical_disk.go @@ -136,7 +136,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("LogicalDisk", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("LogicalDisk", perfdata.InstancesAll, []string{ currentDiskQueueLength, avgDiskReadQueueLength, avgDiskWriteQueueLength, diff --git a/internal/collector/memory/memory.go b/internal/collector/memory/memory.go index 12bb2cac7..b31c759ce 100644 --- a/internal/collector/memory/memory.go +++ b/internal/collector/memory/memory.go @@ -134,7 +134,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("Memory", perfdata.InstanceAll, counters) + c.perfDataCollector, err = perfdata.NewCollector("Memory", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Memory collector: %w", err) } @@ -414,7 +414,7 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect Memory metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for Memory returned empty result set") diff --git a/internal/collector/mssql/mssql_access_methods.go b/internal/collector/mssql/mssql_access_methods.go index 761379c11..2c6951e6e 100644 --- a/internal/collector/mssql/mssql_access_methods.go +++ b/internal/collector/mssql/mssql_access_methods.go @@ -443,7 +443,7 @@ func (c *Collector) collectAccessMethodsInstance(ch chan<- prometheus.Metric, sq return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "AccessMethods"), err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "AccessMethods")) } diff --git a/internal/collector/mssql/mssql_availability_replica.go b/internal/collector/mssql/mssql_availability_replica.go index 62b0865a4..9ed32e601 100644 --- a/internal/collector/mssql/mssql_availability_replica.go +++ b/internal/collector/mssql/mssql_availability_replica.go @@ -54,7 +54,7 @@ func (c *Collector) buildAvailabilityReplica() error { } for sqlInstance := range c.mssqlInstances { - c.availabilityReplicaPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Availability Replica"), perfdata.InstanceAll, counters) + c.availabilityReplicaPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Availability Replica"), perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Availability Replica collector for instance %s: %w", sqlInstance, err) } diff --git a/internal/collector/mssql/mssql_database.go b/internal/collector/mssql/mssql_database.go index dcdcb7972..bae8b65c2 100644 --- a/internal/collector/mssql/mssql_database.go +++ b/internal/collector/mssql/mssql_database.go @@ -170,7 +170,7 @@ func (c *Collector) buildDatabases() error { } for sqlInstance := range c.mssqlInstances { - c.databasesPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Databases"), perfdata.InstanceAll, counters) + c.databasesPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Databases"), perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Databases collector for instance %s: %w", sqlInstance, err) } diff --git a/internal/collector/mssql/mssql_database_replica.go b/internal/collector/mssql/mssql_database_replica.go index d47ec519e..6b3300d4d 100644 --- a/internal/collector/mssql/mssql_database_replica.go +++ b/internal/collector/mssql/mssql_database_replica.go @@ -98,7 +98,7 @@ func (c *Collector) buildDatabaseReplica() error { } for sqlInstance := range c.mssqlInstances { - c.dbReplicaPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Database Replica"), perfdata.InstanceAll, counters) + c.dbReplicaPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Database Replica"), perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Database Replica collector for instance %s: %w", sqlInstance, err) } diff --git a/internal/collector/mssql/mssql_general_statistics.go b/internal/collector/mssql/mssql_general_statistics.go index 5ffb90154..bb9a77000 100644 --- a/internal/collector/mssql/mssql_general_statistics.go +++ b/internal/collector/mssql/mssql_general_statistics.go @@ -263,7 +263,7 @@ func (c *Collector) collectGeneralStatisticsInstance(ch chan<- prometheus.Metric return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "General Statistics"), err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "General Statistics")) } diff --git a/internal/collector/mssql/mssql_locks.go b/internal/collector/mssql/mssql_locks.go index 768922b69..d24430c7d 100644 --- a/internal/collector/mssql/mssql_locks.go +++ b/internal/collector/mssql/mssql_locks.go @@ -51,7 +51,7 @@ func (c *Collector) buildLocks() error { } for sqlInstance := range c.mssqlInstances { - c.locksPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Locks"), perfdata.InstanceAll, counters) + c.locksPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Locks"), perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Locks collector for instance %s: %w", sqlInstance, err) } diff --git a/internal/collector/mssql/mssql_memory_manager.go b/internal/collector/mssql/mssql_memory_manager.go index c38b910a7..f917e151a 100644 --- a/internal/collector/mssql/mssql_memory_manager.go +++ b/internal/collector/mssql/mssql_memory_manager.go @@ -86,7 +86,7 @@ func (c *Collector) buildMemoryManager() error { } for sqlInstance := range c.mssqlInstances { - c.memMgrPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager"), perfdata.InstanceAll, counters) + c.memMgrPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager"), perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Locks collector for instance %s: %w", sqlInstance, err) } @@ -226,7 +226,7 @@ func (c *Collector) collectMemoryManagerInstance(ch chan<- prometheus.Metric, sq return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager"), err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager")) } diff --git a/internal/collector/mssql/mssql_sql_errors.go b/internal/collector/mssql/mssql_sql_errors.go index f9b7d7f7f..84610cdd7 100644 --- a/internal/collector/mssql/mssql_sql_errors.go +++ b/internal/collector/mssql/mssql_sql_errors.go @@ -30,7 +30,7 @@ func (c *Collector) buildSQLErrors() error { } for sqlInstance := range c.mssqlInstances { - c.genStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Errors"), perfdata.InstanceAll, counters) + c.genStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Errors"), perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create SQL Errors collector for instance %s: %w", sqlInstance, err) } diff --git a/internal/collector/mssql/mssql_sql_stats.go b/internal/collector/mssql/mssql_sql_stats.go index a02939461..93a57ca86 100644 --- a/internal/collector/mssql/mssql_sql_stats.go +++ b/internal/collector/mssql/mssql_sql_stats.go @@ -145,7 +145,7 @@ func (c *Collector) collectSQLStatsInstance(ch chan<- prometheus.Metric, sqlInst return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics"), err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics")) } diff --git a/internal/collector/mssql/mssql_transactions.go b/internal/collector/mssql/mssql_transactions.go index 9c2a300e6..a5f211385 100644 --- a/internal/collector/mssql/mssql_transactions.go +++ b/internal/collector/mssql/mssql_transactions.go @@ -165,7 +165,7 @@ func (c *Collector) collectTransactionsInstance(ch chan<- prometheus.Metric, sql return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Transactions"), err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "Transactions")) } diff --git a/internal/collector/mssql/mssql_wait_stats.go b/internal/collector/mssql/mssql_wait_stats.go index ab6ef9b93..b304a03f5 100644 --- a/internal/collector/mssql/mssql_wait_stats.go +++ b/internal/collector/mssql/mssql_wait_stats.go @@ -62,7 +62,7 @@ func (c *Collector) buildWaitStats() error { } for sqlInstance := range c.mssqlInstances { - c.waitStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Wait Statistics"), perfdata.InstanceAll, counters) + c.waitStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Wait Statistics"), perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Wait Statistics collector for instance %s: %w", sqlInstance, err) } diff --git a/internal/collector/net/net.go b/internal/collector/net/net.go index c4940f217..327a71a88 100644 --- a/internal/collector/net/net.go +++ b/internal/collector/net/net.go @@ -144,7 +144,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("Network Interface", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("Network Interface", perfdata.InstancesAll, []string{ bytesReceivedPerSec, bytesSentPerSec, bytesTotalPerSec, diff --git a/internal/collector/nps/nps.go b/internal/collector/nps/nps.go index 6b19e26c4..a7379dc1e 100644 --- a/internal/collector/nps/nps.go +++ b/internal/collector/nps/nps.go @@ -298,7 +298,7 @@ func (c *Collector) collectAccept(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect NPS Authentication Server metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for NPS Authentication Server returned empty result set") } @@ -390,7 +390,7 @@ func (c *Collector) collectAccounting(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect NPS Accounting Server metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("perflib query for NPS Accounting Server returned empty result set") } diff --git a/internal/collector/pagefile/pagefile.go b/internal/collector/pagefile/pagefile.go index 7646f7f5c..30e9666a7 100644 --- a/internal/collector/pagefile/pagefile.go +++ b/internal/collector/pagefile/pagefile.go @@ -61,7 +61,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("Paging File", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("Paging File", perfdata.InstancesAll, []string{ usage, }) if err != nil { diff --git a/internal/collector/perfdata/perfdata.go b/internal/collector/perfdata/perfdata.go index c4d7100d7..8f607d130 100644 --- a/internal/collector/perfdata/perfdata.go +++ b/internal/collector/perfdata/perfdata.go @@ -118,7 +118,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { for instance, counters := range data { for counter, value := range counters { var labels prometheus.Labels - if instance != perfdata.EmptyInstance { + if instance != perfdata.InstanceEmpty { labels = prometheus.Labels{object.InstanceLabel: instance} } diff --git a/internal/collector/physical_disk/physical_disk.go b/internal/collector/physical_disk/physical_disk.go index 3f118ffaf..5932014dd 100644 --- a/internal/collector/physical_disk/physical_disk.go +++ b/internal/collector/physical_disk/physical_disk.go @@ -129,7 +129,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("PhysicalDisk", perfdata.InstanceAll, counters) + c.perfDataCollector, err = perfdata.NewCollector("PhysicalDisk", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create PhysicalDisk collector: %w", err) } diff --git a/internal/collector/process/process.go b/internal/collector/process/process.go index c06f03455..6835c4bf2 100644 --- a/internal/collector/process/process.go +++ b/internal/collector/process/process.go @@ -180,11 +180,11 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error { workingSet, } - c.perfDataCollector, err = perfdata.NewCollector("Process V2", perfdata.InstanceAll, counters) + c.perfDataCollector, err = perfdata.NewCollector("Process V2", perfdata.InstancesAll, counters) if errors.Is(err, perfdata.NewPdhError(perfdata.PdhCstatusNoObject)) { counters[0] = idProcess - c.perfDataCollector, err = perfdata.NewCollector("Process", perfdata.InstanceAll, counters) + c.perfDataCollector, err = perfdata.NewCollector("Process", perfdata.InstancesAll, counters) } if err != nil { @@ -324,9 +324,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { // Duplicate processes are suffixed #, and an index number. Remove those. name, _, _ = strings.Cut(name, "#") - if name == "_Total" || - c.config.ProcessExclude.MatchString(name) || - !c.config.ProcessInclude.MatchString(name) { + if c.config.ProcessExclude.MatchString(name) || !c.config.ProcessInclude.MatchString(name) { continue } diff --git a/internal/collector/remote_fx/remote_fx.go b/internal/collector/remote_fx/remote_fx.go index 05716d522..525a6b4f3 100644 --- a/internal/collector/remote_fx/remote_fx.go +++ b/internal/collector/remote_fx/remote_fx.go @@ -88,7 +88,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(*slog.Logger, *mi.Session) error { var err error - c.perfDataCollectorNetwork, err = perfdata.NewCollector("RemoteFX Network", perfdata.InstanceAll, []string{ + c.perfDataCollectorNetwork, err = perfdata.NewCollector("RemoteFX Network", perfdata.InstancesAll, []string{ BaseTCPRTT, BaseUDPRTT, CurrentTCPBandwidth, @@ -107,7 +107,7 @@ func (c *Collector) Build(*slog.Logger, *mi.Session) error { return fmt.Errorf("failed to create RemoteFX Network collector: %w", err) } - c.perfDataCollectorGraphics, err = perfdata.NewCollector("RemoteFX Graphics", perfdata.InstanceAll, []string{ + c.perfDataCollectorGraphics, err = perfdata.NewCollector("RemoteFX Graphics", perfdata.InstancesAll, []string{ AverageEncodingTime, FrameQuality, FramesSkippedPerSecondInsufficientClientResources, diff --git a/internal/collector/smb/const.go b/internal/collector/smb/const.go index b8adc8025..bd8ee20f9 100644 --- a/internal/collector/smb/const.go +++ b/internal/collector/smb/const.go @@ -5,4 +5,10 @@ package smb const ( currentOpenFileCount = "Current Open File Count" treeConnectCount = "Tree Connect Count" + receivedBytes = "Received Bytes/sec" + writeRequests = "Write Requests/sec" + readRequests = "Read Requests/sec" + metadataRequests = "Metadata Requests/sec" + sentBytes = "Sent Bytes/sec" + filesOpened = "Files Opened/sec" ) diff --git a/internal/collector/smb/smb.go b/internal/collector/smb/smb.go index 3cb085781..e4f247cc4 100644 --- a/internal/collector/smb/smb.go +++ b/internal/collector/smb/smb.go @@ -3,7 +3,6 @@ package smb import ( - "errors" "fmt" "log/slog" @@ -27,6 +26,12 @@ type Collector struct { treeConnectCount *prometheus.Desc currentOpenFileCount *prometheus.Desc + receivedBytes *prometheus.Desc + writeRequests *prometheus.Desc + readRequests *prometheus.Desc + metadataRequests *prometheus.Desc + sentBytes *prometheus.Desc + filesOpened *prometheus.Desc } func New(config *Config) *Collector { @@ -58,9 +63,15 @@ func (c *Collector) Close() error { func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("SMB Server Shares", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("SMB Server Shares", perfdata.InstancesAll, []string{ currentOpenFileCount, treeConnectCount, + receivedBytes, + writeRequests, + readRequests, + metadataRequests, + sentBytes, + filesOpened, }) if err != nil { return fmt.Errorf("failed to create SMB Server Shares collector: %w", err) @@ -68,14 +79,50 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { c.currentOpenFileCount = prometheus.NewDesc( prometheus.BuildFQName(types.Namespace, Name, "server_shares_current_open_file_count"), - "Current total count open files on the SMB Server", - nil, + "Current total count open files on the SMB Server Share", + []string{"share"}, nil, ) c.treeConnectCount = prometheus.NewDesc( prometheus.BuildFQName(types.Namespace, Name, "server_shares_tree_connect_count"), - "Count of user connections to the SMB Server", + "Count of user connections to the SMB Server Share", + []string{"share"}, + nil, + ) + c.receivedBytes = prometheus.NewDesc( + prometheus.BuildFQName(types.Namespace, Name, "server_shares_received_bytes_total"), + "Received bytes on the SMB Server Share", + []string{"share"}, + nil, + ) + c.writeRequests = prometheus.NewDesc( + prometheus.BuildFQName(types.Namespace, Name, "server_shares_write_requests_count"), + "Writes requests on the SMB Server Share", + []string{"share"}, + nil, + ) + c.readRequests = prometheus.NewDesc( + prometheus.BuildFQName(types.Namespace, Name, "server_shares_read_requests_count"), + "Read requests on the SMB Server Share", + []string{"share"}, + nil, + ) + c.metadataRequests = prometheus.NewDesc( + prometheus.BuildFQName(types.Namespace, Name, "server_shares_metadata_requests_count"), + "Metadata requests on the SMB Server Share", + []string{"share"}, + nil, + ) + c.sentBytes = prometheus.NewDesc( + prometheus.BuildFQName(types.Namespace, Name, "server_shares_sent_bytes_total"), + "Sent bytes on the SMB Server Share", + []string{"share"}, nil, + ) + c.filesOpened = prometheus.NewDesc( + prometheus.BuildFQName(types.Namespace, Name, "server_shares_filed_opened_count"), + "Files opened on the SMB Server Share", + []string{"share"}, nil, ) @@ -89,22 +136,63 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect SMB Server Shares metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] - if !ok { - return errors.New("query for SMB Server Shares returned empty result set") + for share, data := range perfData { + ch <- prometheus.MustNewConstMetric( + c.currentOpenFileCount, + prometheus.CounterValue, + data[currentOpenFileCount].FirstValue, + share, + ) + + ch <- prometheus.MustNewConstMetric( + c.treeConnectCount, + prometheus.CounterValue, + data[treeConnectCount].FirstValue, + share, + ) + + ch <- prometheus.MustNewConstMetric( + c.receivedBytes, + prometheus.CounterValue, + data[receivedBytes].FirstValue, + share, + ) + + ch <- prometheus.MustNewConstMetric( + c.writeRequests, + prometheus.GaugeValue, + data[writeRequests].FirstValue, + share, + ) + + ch <- prometheus.MustNewConstMetric( + c.readRequests, + prometheus.GaugeValue, + data[readRequests].FirstValue, + share, + ) + + ch <- prometheus.MustNewConstMetric( + c.metadataRequests, + prometheus.GaugeValue, + data[metadataRequests].FirstValue, + share, + ) + + ch <- prometheus.MustNewConstMetric( + c.sentBytes, + prometheus.CounterValue, + data[sentBytes].FirstValue, + share, + ) + + ch <- prometheus.MustNewConstMetric( + c.filesOpened, + prometheus.GaugeValue, + data[filesOpened].FirstValue, + share, + ) } - ch <- prometheus.MustNewConstMetric( - c.currentOpenFileCount, - prometheus.CounterValue, - data[currentOpenFileCount].FirstValue, - ) - - ch <- prometheus.MustNewConstMetric( - c.treeConnectCount, - prometheus.CounterValue, - data[treeConnectCount].FirstValue, - ) - return nil } diff --git a/internal/collector/smbclient/smbclient.go b/internal/collector/smbclient/smbclient.go index cb69c52ac..3638a69d9 100644 --- a/internal/collector/smbclient/smbclient.go +++ b/internal/collector/smbclient/smbclient.go @@ -78,7 +78,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("SMB Client Shares", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("SMB Client Shares", perfdata.InstancesAll, []string{ AvgDataQueueLength, AvgReadQueueLength, AvgSecPerRead, diff --git a/internal/collector/smtp/smtp.go b/internal/collector/smtp/smtp.go index 5ac132e8f..066b4edd6 100644 --- a/internal/collector/smtp/smtp.go +++ b/internal/collector/smtp/smtp.go @@ -144,7 +144,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollector, err = perfdata.NewCollector("SMTP Server", perfdata.InstanceAll, []string{ + c.perfDataCollector, err = perfdata.NewCollector("SMTP Server", perfdata.InstancesAll, []string{ badmailedMessagesBadPickupFileTotal, badmailedMessagesGeneralFailureTotal, badmailedMessagesHopCountExceededTotal, diff --git a/internal/collector/system/system.go b/internal/collector/system/system.go index 00047e1a5..93772e35d 100644 --- a/internal/collector/system/system.go +++ b/internal/collector/system/system.go @@ -139,7 +139,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect System metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("query for System returned empty result set") } diff --git a/internal/collector/tcp/tcp.go b/internal/collector/tcp/tcp.go index a79655741..df46969ae 100644 --- a/internal/collector/tcp/tcp.go +++ b/internal/collector/tcp/tcp.go @@ -215,22 +215,22 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect TCPv4 metrics: %w", err) } - if _, ok := data[perfdata.EmptyInstance]; !ok { + if _, ok := data[perfdata.InstanceEmpty]; !ok { return errors.New("no data for TCPv4") } - c.writeTCPCounters(ch, data[perfdata.EmptyInstance], []string{"ipv4"}) + c.writeTCPCounters(ch, data[perfdata.InstanceEmpty], []string{"ipv4"}) data, err = c.perfDataCollector6.Collect() if err != nil { return fmt.Errorf("failed to collect TCPv6 metrics: %w", err) } - if _, ok := data[perfdata.EmptyInstance]; !ok { + if _, ok := data[perfdata.InstanceEmpty]; !ok { return errors.New("no data for TCPv6") } - c.writeTCPCounters(ch, data[perfdata.EmptyInstance], []string{"ipv6"}) + c.writeTCPCounters(ch, data[perfdata.InstanceEmpty], []string{"ipv6"}) return nil } diff --git a/internal/collector/terminal_services/terminal_services.go b/internal/collector/terminal_services/terminal_services.go index e33e65b6f..373f1c50e 100644 --- a/internal/collector/terminal_services/terminal_services.go +++ b/internal/collector/terminal_services/terminal_services.go @@ -142,7 +142,7 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error { var err error - c.perfDataCollectorTerminalServicesSession, err = perfdata.NewCollector("Terminal Services Session", perfdata.InstanceAll, counters) + c.perfDataCollectorTerminalServicesSession, err = perfdata.NewCollector("Terminal Services Session", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Terminal Services Session collector: %w", err) } @@ -158,7 +158,7 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error { var err error - c.perfDataCollectorBroker, err = perfdata.NewCollector("Remote Desktop Connection Broker Counterset", perfdata.InstanceAll, counters) + c.perfDataCollectorBroker, err = perfdata.NewCollector("Remote Desktop Connection Broker Counterset", perfdata.InstancesAll, counters) if err != nil { return fmt.Errorf("failed to create Remote Desktop Connection Broker Counterset collector: %w", err) } @@ -413,7 +413,7 @@ func (c *Collector) collectCollectionBrokerPerformanceCounter(ch chan<- promethe return fmt.Errorf("failed to collect Remote Desktop Connection Broker Counterset metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("query for Remote Desktop Connection Broker Counterset returned empty result set") } diff --git a/internal/collector/time/time.go b/internal/collector/time/time.go index cc9338f5a..d655fbb93 100644 --- a/internal/collector/time/time.go +++ b/internal/collector/time/time.go @@ -227,7 +227,7 @@ func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect VM Memory metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("query for Windows Time Service returned empty result set") } diff --git a/internal/collector/udp/udp.go b/internal/collector/udp/udp.go index 27648c43f..caa3d625c 100644 --- a/internal/collector/udp/udp.go +++ b/internal/collector/udp/udp.go @@ -124,22 +124,22 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect UDPv4 metrics: %w", err) } - if _, ok := data[perfdata.EmptyInstance]; !ok { + if _, ok := data[perfdata.InstanceEmpty]; !ok { return errors.New("no data for UDPv4") } - c.writeUDPCounters(ch, data[perfdata.EmptyInstance], []string{"ipv4"}) + c.writeUDPCounters(ch, data[perfdata.InstanceEmpty], []string{"ipv4"}) data, err = c.perfDataCollector6.Collect() if err != nil { return fmt.Errorf("failed to collect UDPv6 metrics: %w", err) } - if _, ok := data[perfdata.EmptyInstance]; !ok { + if _, ok := data[perfdata.InstanceEmpty]; !ok { return errors.New("no data for UDPv6") } - c.writeUDPCounters(ch, data[perfdata.EmptyInstance], []string{"ipv6"}) + c.writeUDPCounters(ch, data[perfdata.InstanceEmpty], []string{"ipv6"}) return nil } diff --git a/internal/collector/vmware/vmware.go b/internal/collector/vmware/vmware.go index dd8e4f6e3..31d4274d5 100644 --- a/internal/collector/vmware/vmware.go +++ b/internal/collector/vmware/vmware.go @@ -79,7 +79,7 @@ func (c *Collector) Close() error { func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error { var err error - c.perfDataCollectorCPU, err = perfdata.NewCollector("VM Processor", perfdata.InstanceTotal, []string{ + c.perfDataCollectorCPU, err = perfdata.NewCollector("VM Processor", perfdata.InstancesTotal, []string{ cpuLimitMHz, cpuReservationMHz, cpuShares, @@ -251,7 +251,7 @@ func (c *Collector) collectMem(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect VM Memory metrics: %w", err) } - data, ok := perfData[perfdata.EmptyInstance] + data, ok := perfData[perfdata.InstanceEmpty] if !ok { return errors.New("query for VM Memory returned empty result set") } @@ -337,7 +337,7 @@ func (c *Collector) collectCpu(ch chan<- prometheus.Metric) error { return fmt.Errorf("failed to collect VM Memory metrics: %w", err) } - data, ok := perfData["_Total"] + data, ok := perfData[perfdata.InstanceTotal] if !ok { return errors.New("query for VM CPU returned empty result set") } diff --git a/internal/perfdata/collector.go b/internal/perfdata/collector.go index 5f5d69b64..f71028bb4 100644 --- a/internal/perfdata/collector.go +++ b/internal/perfdata/collector.go @@ -15,8 +15,8 @@ import ( ) var ( - InstanceAll = []string{"*"} - InstanceTotal = []string{"_Total"} + InstancesAll = []string{"*"} + InstancesTotal = []string{InstanceTotal} ) type Collector struct { @@ -43,14 +43,14 @@ func NewCollector(object string, instances []string, counters []string) (*Collec } if len(instances) == 0 { - instances = []string{EmptyInstance} + instances = []string{InstanceEmpty} } collector := &Collector{ object: object, counters: make(map[string]Counter, len(counters)), handle: handle, - totalCounterRequested: slices.Contains(instances, "_Total"), + totalCounterRequested: slices.Contains(instances, InstanceTotal), mu: sync.RWMutex{}, } @@ -186,12 +186,12 @@ func (c *Collector) Collect() (map[string]map[string]CounterValues, error) { for _, item := range items { if item.RawValue.CStatus == PdhCstatusValidData || item.RawValue.CStatus == PdhCstatusNewData { instanceName := windows.UTF16PtrToString(item.SzName) - if strings.HasSuffix(instanceName, "_Total") && !c.totalCounterRequested { + if strings.HasSuffix(instanceName, InstanceTotal) && !c.totalCounterRequested { continue } if instanceName == "" || instanceName == "*" { - instanceName = EmptyInstance + instanceName = InstanceEmpty } if _, ok := data[instanceName]; !ok { @@ -239,7 +239,7 @@ func (c *Collector) Close() { func formatCounterPath(object, instance, counterName string) string { var counterPath string - if instance == EmptyInstance { + if instance == InstanceEmpty { counterPath = fmt.Sprintf(`\%s\%s`, object, counterName) } else { counterPath = fmt.Sprintf(`\%s(%s)\%s`, object, instance, counterName) diff --git a/internal/perfdata/types.go b/internal/perfdata/types.go index 66706e3bf..3d52f2a50 100644 --- a/internal/perfdata/types.go +++ b/internal/perfdata/types.go @@ -4,7 +4,10 @@ package perfdata import "github.com/prometheus/client_golang/prometheus" -const EmptyInstance = "------" +const ( + InstanceEmpty = "------" + InstanceTotal = "_Total" +) type CounterValues struct { Type prometheus.ValueType