diff --git a/.run/all.run.xml b/.run/all.run.xml index 3bc35cc0..15a33922 100644 --- a/.run/all.run.xml +++ b/.run/all.run.xml @@ -19,7 +19,7 @@ - + diff --git a/README.md b/README.md index 01cd1f52..4963430f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ A Prometheus exporter for Windows machines. | [cache](docs/collector.cache.md) | Cache metrics | | | [cpu](docs/collector.cpu.md) | CPU usage | ✓ | | [cpu_info](docs/collector.cpu_info.md) | CPU Information | | -| [cs](docs/collector.cs.md) | "Computer System" metrics (system properties, num cpus/total memory) | | | [container](docs/collector.container.md) | Container metrics | | | [diskdrive](docs/collector.diskdrive.md) | Diskdrive metrics | | | [dfsr](docs/collector.dfsr.md) | DFSR metrics | | diff --git a/docs/README.md b/docs/README.md index d66c4229..2d152186 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,7 +9,6 @@ This directory contains documentation of the collectors in the windows_exporter, - [`container`](collector.container.md) - [`cpu`](collector.cpu.md) - [`cpu_info`](collector.cpu_info.md) -- [`cs`](collector.cs.md) - [`dfsr`](collector.dfsr.md) - [`dhcp`](collector.dhcp.md) - [`diskdrive`](collector.diskdrive.md) diff --git a/docs/collector.cs.md b/docs/collector.cs.md deleted file mode 100644 index 33465407..00000000 --- a/docs/collector.cs.md +++ /dev/null @@ -1,34 +0,0 @@ -# cs collector - -> [!CAUTION] -> This collector is deprecated and will be removed in a future release. -> See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information. - -The cs collector exposes metrics detailing the hardware of the computer system - -||| --|- -Metric name prefix | `cs` -Classes | [`Win32_ComputerSystem`](https://msdn.microsoft.com/en-us/library/aa394102) -Enabled by default? | Yes - -## Flags - -None - -## Metrics - -Name | Description | Type | Labels ------|-------------|------|------- -`windows_cs_logical_processors` | Number of installed logical processors | gauge | None -`windows_cs_physical_memory_bytes` | Total installed physical memory | gauge | None -`windows_cs_hostname` | Labelled system hostname information | gauge | `hostname`, `domain`, `fqdn` - -### Example metric -_This collector does not yet have explained examples, we would appreciate your help adding them!_ - -## Useful queries -_This collector does not yet have any useful queries added, we would appreciate your help adding them!_ - -## Alerting examples -_This collector does not yet have alerting examples, we would appreciate your help adding them!_ diff --git a/docs/example_config.yml b/docs/example_config.yml index 4879f463..f5483952 100644 --- a/docs/example_config.yml +++ b/docs/example_config.yml @@ -1,7 +1,7 @@ --- # Note this is not an exhaustive list of all configuration values collectors: - enabled: cpu,cs,logical_disk,net,os,service,system + enabled: cpu,logical_disk,net,os,service,system collector: service: include: "windows_exporter" diff --git a/installer/main.wxs b/installer/main.wxs index 285f8440..d5f63465 100644 --- a/installer/main.wxs +++ b/installer/main.wxs @@ -178,7 +178,7 @@ - + diff --git a/internal/collector/cs/cs.go b/internal/collector/cs/cs.go deleted file mode 100644 index 82c93817..00000000 --- a/internal/collector/cs/cs.go +++ /dev/null @@ -1,157 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// -// Copyright The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build windows - -package cs - -import ( - "log/slog" - - "github.com/alecthomas/kingpin/v2" - "github.com/prometheus-community/windows_exporter/internal/headers/sysinfoapi" - "github.com/prometheus-community/windows_exporter/internal/mi" - "github.com/prometheus-community/windows_exporter/internal/types" - "github.com/prometheus/client_golang/prometheus" -) - -const Name = "cs" - -type Config struct{} - -//nolint:gochecknoglobals -var ConfigDefaults = Config{} - -// A Collector is a Prometheus Collector for WMI metrics. -type Collector struct { - config Config - - // physicalMemoryBytes - // Deprecated: Use windows_memory_physical_total_bytes instead - physicalMemoryBytes *prometheus.Desc - // logicalProcessors - // Deprecated: Use windows_cpu_logical_processor instead - logicalProcessors *prometheus.Desc - // hostname - // Deprecated: Use windows_os_hostname instead - hostname *prometheus.Desc -} - -func New(config *Config) *Collector { - if config == nil { - config = &ConfigDefaults - } - - c := &Collector{ - config: *config, - } - - return c -} - -func NewWithFlags(_ *kingpin.Application) *Collector { - return &Collector{} -} - -func (c *Collector) GetName() string { - return Name -} - -func (c *Collector) Close() error { - return nil -} - -func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error { - logger.Warn("The cs collector is deprecated and will be removed in a future release. " + - "Logical processors has been moved to cpu_info collector. " + - "Physical memory has been moved to memory collector. " + - "Hostname has been moved to os collector.") - - c.logicalProcessors = prometheus.NewDesc( - prometheus.BuildFQName(types.Namespace, Name, "logical_processors"), - "Deprecated: Use windows_cpu_logical_processor instead", - nil, - nil, - ) - c.physicalMemoryBytes = prometheus.NewDesc( - prometheus.BuildFQName(types.Namespace, Name, "physical_memory_bytes"), - "Deprecated: Use windows_memory_physical_total_bytes instead", - nil, - nil, - ) - c.hostname = prometheus.NewDesc( - prometheus.BuildFQName(types.Namespace, Name, "hostname"), - "Deprecated: Use windows_os_hostname instead", - []string{ - "hostname", - "domain", - "fqdn", - }, - nil, - ) - - return nil -} - -// Collect sends the metric values for each metric -// to the provided prometheus Metric channel. -func (c *Collector) Collect(ch chan<- prometheus.Metric) error { - // Get systeminfo for number of processors - systemInfo := sysinfoapi.GetSystemInfo() - - // Get memory status for physical memory - mem, err := sysinfoapi.GlobalMemoryStatusEx() - if err != nil { - return err - } - - ch <- prometheus.MustNewConstMetric( - c.logicalProcessors, - prometheus.GaugeValue, - float64(systemInfo.NumberOfProcessors), - ) - - ch <- prometheus.MustNewConstMetric( - c.physicalMemoryBytes, - prometheus.GaugeValue, - float64(mem.TotalPhys), - ) - - hostname, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSHostname) - if err != nil { - return err - } - - domain, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSDomain) - if err != nil { - return err - } - - fqdn, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSFullyQualified) - if err != nil { - return err - } - - ch <- prometheus.MustNewConstMetric( - c.hostname, - prometheus.GaugeValue, - 1.0, - hostname, - domain, - fqdn, - ) - - return nil -} diff --git a/internal/collector/cs/cs_test.go b/internal/collector/cs/cs_test.go deleted file mode 100644 index a91229a3..00000000 --- a/internal/collector/cs/cs_test.go +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// -// Copyright The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build windows - -package cs_test - -import ( - "testing" - - "github.com/prometheus-community/windows_exporter/internal/collector/cs" - "github.com/prometheus-community/windows_exporter/internal/utils/testutils" -) - -func BenchmarkCollector(b *testing.B) { - testutils.FuncBenchmarkCollector(b, cs.Name, cs.NewWithFlags) -} - -func TestCollector(t *testing.T) { - testutils.TestCollector(t, cs.New, nil) -} diff --git a/pkg/collector/collection.go b/pkg/collector/collection.go index 1a6442b5..29df38b0 100644 --- a/pkg/collector/collection.go +++ b/pkg/collector/collection.go @@ -35,7 +35,6 @@ import ( "github.com/prometheus-community/windows_exporter/internal/collector/container" "github.com/prometheus-community/windows_exporter/internal/collector/cpu" "github.com/prometheus-community/windows_exporter/internal/collector/cpu_info" - "github.com/prometheus-community/windows_exporter/internal/collector/cs" "github.com/prometheus-community/windows_exporter/internal/collector/dfsr" "github.com/prometheus-community/windows_exporter/internal/collector/dhcp" "github.com/prometheus-community/windows_exporter/internal/collector/diskdrive" @@ -106,7 +105,6 @@ func NewWithConfig(config Config) *Collection { collectors[container.Name] = container.New(&config.Container) collectors[cpu.Name] = cpu.New(&config.CPU) collectors[cpu_info.Name] = cpu_info.New(&config.CPUInfo) - collectors[cs.Name] = cs.New(&config.Cs) collectors[dfsr.Name] = dfsr.New(&config.DFSR) collectors[dhcp.Name] = dhcp.New(&config.Dhcp) collectors[diskdrive.Name] = diskdrive.New(&config.DiskDrive) diff --git a/pkg/collector/config.go b/pkg/collector/config.go index 00d7644f..b8419fde 100644 --- a/pkg/collector/config.go +++ b/pkg/collector/config.go @@ -25,7 +25,6 @@ import ( "github.com/prometheus-community/windows_exporter/internal/collector/container" "github.com/prometheus-community/windows_exporter/internal/collector/cpu" "github.com/prometheus-community/windows_exporter/internal/collector/cpu_info" - "github.com/prometheus-community/windows_exporter/internal/collector/cs" "github.com/prometheus-community/windows_exporter/internal/collector/dfsr" "github.com/prometheus-community/windows_exporter/internal/collector/dhcp" "github.com/prometheus-community/windows_exporter/internal/collector/diskdrive" @@ -76,7 +75,6 @@ type Config struct { Container container.Config `yaml:"container"` CPU cpu.Config `yaml:"cpu"` CPUInfo cpu_info.Config `yaml:"cpu_info"` - Cs cs.Config `yaml:"cs"` DFSR dfsr.Config `yaml:"dfsr"` Dhcp dhcp.Config `yaml:"dhcp"` DiskDrive diskdrive.Config `yaml:"diskdrive"` @@ -131,7 +129,6 @@ var ConfigDefaults = Config{ Container: container.ConfigDefaults, CPU: cpu.ConfigDefaults, CPUInfo: cpu_info.ConfigDefaults, - Cs: cs.ConfigDefaults, DFSR: dfsr.ConfigDefaults, Dhcp: dhcp.ConfigDefaults, DiskDrive: diskdrive.ConfigDefaults, diff --git a/pkg/collector/map.go b/pkg/collector/map.go index 776b5e36..70e89440 100644 --- a/pkg/collector/map.go +++ b/pkg/collector/map.go @@ -29,7 +29,6 @@ import ( "github.com/prometheus-community/windows_exporter/internal/collector/container" "github.com/prometheus-community/windows_exporter/internal/collector/cpu" "github.com/prometheus-community/windows_exporter/internal/collector/cpu_info" - "github.com/prometheus-community/windows_exporter/internal/collector/cs" "github.com/prometheus-community/windows_exporter/internal/collector/dfsr" "github.com/prometheus-community/windows_exporter/internal/collector/dhcp" "github.com/prometheus-community/windows_exporter/internal/collector/diskdrive" @@ -87,7 +86,6 @@ var BuildersWithFlags = map[string]BuilderWithFlags[Collector]{ container.Name: NewBuilderWithFlags(container.NewWithFlags), cpu.Name: NewBuilderWithFlags(cpu.NewWithFlags), cpu_info.Name: NewBuilderWithFlags(cpu_info.NewWithFlags), - cs.Name: NewBuilderWithFlags(cs.NewWithFlags), dfsr.Name: NewBuilderWithFlags(dfsr.NewWithFlags), dhcp.Name: NewBuilderWithFlags(dhcp.NewWithFlags), diskdrive.Name: NewBuilderWithFlags(diskdrive.NewWithFlags), diff --git a/pkg/collector/types.go b/pkg/collector/types.go index 71d69ba0..2830139d 100644 --- a/pkg/collector/types.go +++ b/pkg/collector/types.go @@ -26,7 +26,7 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -const DefaultCollectors = "cpu,cs,memory,logical_disk,physical_disk,net,os,service,system" +const DefaultCollectors = "cpu,memory,logical_disk,physical_disk,net,os,service,system" type Collection struct { collectors Map diff --git a/tools/e2e-output.txt b/tools/e2e-output.txt index 5ede8509..33991fca 100644 --- a/tools/e2e-output.txt +++ b/tools/e2e-output.txt @@ -101,12 +101,6 @@ test_alpha_total 42 # TYPE windows_cpu_processor_utility_total counter # HELP windows_cpu_time_total Time that processor spent in different modes (dpc, idle, interrupt, privileged, user) # TYPE windows_cpu_time_total counter -# HELP windows_cs_hostname Deprecated: Use windows_os_hostname instead -# TYPE windows_cs_hostname gauge -# HELP windows_cs_logical_processors Deprecated: Use windows_cpu_logical_processor instead -# TYPE windows_cs_logical_processors gauge -# HELP windows_cs_physical_memory_bytes Deprecated: Use windows_memory_physical_total_bytes instead -# TYPE windows_cs_physical_memory_bytes gauge # HELP windows_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which windows_exporter was built, and the goos and goarch for the build. # TYPE windows_exporter_build_info gauge # HELP windows_exporter_collector_duration_seconds windows_exporter: Duration of a collection. @@ -116,7 +110,6 @@ test_alpha_total 42 windows_exporter_collector_success{collector="cache"} 1 windows_exporter_collector_success{collector="cpu"} 1 windows_exporter_collector_success{collector="cpu_info"} 1 -windows_exporter_collector_success{collector="cs"} 1 windows_exporter_collector_success{collector="logical_disk"} 1 windows_exporter_collector_success{collector="memory"} 1 windows_exporter_collector_success{collector="net"} 1 @@ -137,7 +130,6 @@ windows_exporter_collector_success{collector="udp"} 1 windows_exporter_collector_timeout{collector="cache"} 0 windows_exporter_collector_timeout{collector="cpu"} 0 windows_exporter_collector_timeout{collector="cpu_info"} 0 -windows_exporter_collector_timeout{collector="cs"} 0 windows_exporter_collector_timeout{collector="logical_disk"} 0 windows_exporter_collector_timeout{collector="memory"} 0 windows_exporter_collector_timeout{collector="net"} 0 diff --git a/tools/end-to-end-test.ps1 b/tools/end-to-end-test.ps1 index 5f62ad2d..f70030f7 100644 --- a/tools/end-to-end-test.ps1 +++ b/tools/end-to-end-test.ps1 @@ -18,7 +18,7 @@ mkdir $textfile_dir | Out-Null Copy-Item 'e2e-textfile.prom' -Destination "$($textfile_dir)/e2e-textfile.prom" # Omit dynamic collector information that will change after each run -$skip_re = "^(go_|windows_exporter_build_info|windows_exporter_collector_duration_seconds|windows_exporter_scrape_duration_seconds|process_|windows_textfile_mtime_seconds|windows_cpu|windows_cs|windows_cache|windows_pagefile|windows_logical_disk|windows_physical_disk|windows_memory|windows_net|windows_os|windows_process|windows_service_process|windows_printer|windows_udp|windows_tcp|windows_system|windows_time|windows_session|windows_performancecounter|windows_performancecounter|windows_textfile_mtime_seconds)" +$skip_re = "^(go_|windows_exporter_build_info|windows_exporter_collector_duration_seconds|windows_exporter_scrape_duration_seconds|process_|windows_textfile_mtime_seconds|windows_cpu|windows_cache|windows_pagefile|windows_logical_disk|windows_physical_disk|windows_memory|windows_net|windows_os|windows_process|windows_service_process|windows_printer|windows_udp|windows_tcp|windows_system|windows_time|windows_session|windows_performancecounter|windows_performancecounter|windows_textfile_mtime_seconds)" # Start process in background, awaiting HTTP requests. # Use default collectors, port and address: http://localhost:9182/metrics