mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-09 22:46:36 +00:00
Compare commits
28 Commits
v0.31.0-be
...
v0.31.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd7070354a | ||
|
|
373d741260 | ||
|
|
ed15b3c671 | ||
|
|
f8805932b2 | ||
|
|
4fd26fa0fa | ||
|
|
bf722630d6 | ||
|
|
9320e992cc | ||
|
|
7a4e92a473 | ||
|
|
02b9ab4058 | ||
|
|
c3043693df | ||
|
|
7377d48f07 | ||
|
|
d64f1316ca | ||
|
|
492f3af317 | ||
|
|
116203fd19 | ||
|
|
66751baef6 | ||
|
|
b02bddd38e | ||
|
|
3dbc19e18b | ||
|
|
be481e8776 | ||
|
|
aea5c5a2fb | ||
|
|
59ac3072b1 | ||
|
|
66cd489c4a | ||
|
|
4891e23d29 | ||
|
|
f285c3d1e2 | ||
|
|
90dac66bf5 | ||
|
|
34cfda306b | ||
|
|
3e8693f1e3 | ||
|
|
036c858355 | ||
|
|
a69720ae1d |
26
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
26
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@@ -4,8 +4,12 @@ labels: [ 🐞 bug ]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: Thanks for taking the time to fill out this bug report!
|
||||
|
||||
value: |-
|
||||
> [!NOTE]
|
||||
> Windows Server 2012 and Windows Server 2012 R2 are no longer supported by the windows_exporter project.
|
||||
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |-
|
||||
@@ -15,18 +19,18 @@ body:
|
||||
```
|
||||
PS C:\WINDOWS\system32> cd c:\windows\system32
|
||||
PS C:\windows\system32> lodctr /R
|
||||
|
||||
|
||||
Error: Unable to rebuild performance counter setting from system backup store, error code is 2
|
||||
PS C:\windows\system32> cd ..
|
||||
PS C:\windows> cd syswow64
|
||||
PS C:\windows\syswow64> lodctr /R
|
||||
|
||||
|
||||
Info: Successfully rebuilt performance counter setting from system backup store
|
||||
PS C:\windows\syswow64> winmgmt.exe /RESYNCPERF
|
||||
```
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Current Behavior
|
||||
@@ -36,7 +40,7 @@ body:
|
||||
```...```
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
@@ -44,7 +48,7 @@ body:
|
||||
placeholder: When I do <X>, <Z> should happen instead.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps To Reproduce
|
||||
@@ -57,7 +61,7 @@ body:
|
||||
render: Markdown
|
||||
validations:
|
||||
required: false
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environment
|
||||
@@ -70,7 +74,7 @@ body:
|
||||
- Windows Server Version:
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: windows_exporter logs
|
||||
@@ -80,7 +84,7 @@ body:
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Anything else?
|
||||
|
||||
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -91,5 +91,5 @@ jobs:
|
||||
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
||||
with:
|
||||
# renovate: github=golangci/golangci-lint
|
||||
version: v2.1.6
|
||||
version: v2.2.1
|
||||
args: "--max-same-issues=0"
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -231,7 +231,7 @@ jobs:
|
||||
org.opencontainers.image.licenses=MIT
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
|
||||
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||
|
||||
@@ -19,11 +19,13 @@ linters:
|
||||
- lll
|
||||
- maintidx
|
||||
- mnd
|
||||
- noinlineerr
|
||||
- paralleltest
|
||||
- tagliatelle
|
||||
- testpackage
|
||||
- varnamelen
|
||||
- wrapcheck
|
||||
- wsl
|
||||
settings:
|
||||
forbidigo:
|
||||
forbid:
|
||||
@@ -62,6 +64,13 @@ linters:
|
||||
disable:
|
||||
- fieldalignment
|
||||
- shadow
|
||||
revive:
|
||||
rules:
|
||||
- name: var-naming
|
||||
arguments:
|
||||
- [ ] # AllowList - do not remove as args for the rule are positional and won't work without lists first
|
||||
- [ ] # DenyList
|
||||
- - skip-package-name-checks: true
|
||||
sloglint:
|
||||
no-mixed-args: true
|
||||
kv-only: false
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<configuration default="false" name="all" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="run">
|
||||
<module name="windows_exporter" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<parameters value="--web.listen-address=127.0.0.1:9182 --log.level=info --collectors.enabled=ad,adcs,adfs,cache,container,cpu,cpu_info,cs,dfsr,dhcp,diskdrive,dns,exchange,filetime,fsrmquota,hyperv,iis,license,logical_disk,logon,memory,mscluster,msmq,mssql,net,netframework,nps,os,pagefile,performancecounter,physical_disk,printer,process,remote_fx,scheduled_task,service,smb,smbclient,smtp,system,tcp,terminal_services,thermalzone,time,udp,update,vmware,performancecounter --debug.enabled --collector.performancecounter.objects='[{ "name": "memory", "type": "formatted", "object": "Memory", "counters": [{ "name":"Cache Faults/sec", "type":"counter" }]}]'" />
|
||||
<parameters value="--web.listen-address=127.0.0.1:9182 --log.level=info --collectors.enabled=ad,adcs,adfs,cache,container,cpu,cpu_info,dfsr,dhcp,diskdrive,dns,exchange,filetime,fsrmquota,hyperv,iis,license,logical_disk,memory,mscluster,msmq,mssql,net,netframework,nps,os,pagefile,performancecounter,physical_disk,printer,process,remote_fx,scheduled_task,service,smb,smbclient,smtp,system,tcp,terminal_services,thermalzone,time,udp,update,vmware,performancecounter --debug.enabled --collector.performancecounter.objects='[{ "name": "memory", "type": "formatted", "object": "Memory", "counters": [{ "name":"Cache Faults/sec", "type":"counter" }]}]'" />
|
||||
<sudo value="true" />
|
||||
<kind value="PACKAGE" />
|
||||
<package value="github.com/prometheus-community/windows_exporter/cmd/windows_exporter" />
|
||||
|
||||
2
Makefile
2
Makefile
@@ -29,7 +29,7 @@ test:
|
||||
go test -v ./...
|
||||
|
||||
bench:
|
||||
go test -v -bench='benchmarkcollector' ./internal/collectors/{cpu,logical_disk,physical_disk,logon,memory,net,printer,process,service,system,tcp,time}
|
||||
go test -v -bench='benchmarkcollector' ./internal/collectors/{cpu,logical_disk,physical_disk,memory,net,printer,process,service,system,tcp,time}
|
||||
|
||||
lint:
|
||||
golangci-lint -c .golangci.yaml run
|
||||
|
||||
105
README.md
105
README.md
@@ -1,4 +1,4 @@
|
||||
config.file# windows_exporter
|
||||
# windows_exporter
|
||||
|
||||
[](https://github.com/prometheus-community/windows_exporter)
|
||||
[](https://github.com/prometheus-community/windows_exporter)
|
||||
@@ -12,55 +12,54 @@ A Prometheus exporter for Windows machines.
|
||||
|
||||
## Collectors
|
||||
|
||||
Name | Description | Enabled by default
|
||||
------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------
|
||||
[ad](docs/collector.ad.md) | Active Directory Domain Services |
|
||||
[adcs](docs/collector.adcs.md) | Active Directory Certificate Services |
|
||||
[adfs](docs/collector.adfs.md) | Active Directory Federation Services |
|
||||
[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 |
|
||||
[dhcp](docs/collector.dhcp.md) | DHCP Server |
|
||||
[dns](docs/collector.dns.md) | DNS Server |
|
||||
[exchange](docs/collector.exchange.md) | Exchange metrics |
|
||||
[filetime](docs/collector.filetime.md) | FileTime metrics |
|
||||
[fsrmquota](docs/collector.fsrmquota.md) | Microsoft File Server Resource Manager (FSRM) Quotas collector |
|
||||
[gpu](docs/collector.gpu.md) | GPU metrics |
|
||||
[hyperv](docs/collector.hyperv.md) | Hyper-V hosts |
|
||||
[iis](docs/collector.iis.md) | IIS sites and applications |
|
||||
[license](docs/collector.license.md) | Windows license status |
|
||||
[logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓
|
||||
[memory](docs/collector.memory.md) | Memory usage metrics | ✓
|
||||
[mscluster](docs/collector.mscluster.md) | MSCluster metrics |
|
||||
[msmq](docs/collector.msmq.md) | MSMQ queues |
|
||||
[mssql](docs/collector.mssql.md) | [SQL Server Performance Objects](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/use-sql-server-objects#SQLServerPOs) metrics |
|
||||
[netframework](docs/collector.netframework.md) | .NET Framework metrics |
|
||||
[net](docs/collector.net.md) | Network interface I/O | ✓
|
||||
[os](docs/collector.os.md) | OS metrics (memory, processes, users) | ✓
|
||||
[pagefile](docs/collector.pagefile.md) | pagefile metrics |
|
||||
[performancecounter](docs/collector.performancecounter.md) | Custom performance counter metrics |
|
||||
[physical_disk](docs/collector.physical_disk.md) | physical disk metrics | ✓
|
||||
[printer](docs/collector.printer.md) | Printer metrics |
|
||||
[process](docs/collector.process.md) | Per-process metrics |
|
||||
[remote_fx](docs/collector.remote_fx.md) | RemoteFX protocol (RDP) metrics |
|
||||
[scheduled_task](docs/collector.scheduled_task.md) | Scheduled Tasks metrics |
|
||||
[service](docs/collector.service.md) | Service state metrics | ✓
|
||||
[smb](docs/collector.smb.md) | SMB Server |
|
||||
[smbclient](docs/collector.smbclient.md) | SMB Client |
|
||||
[smtp](docs/collector.smtp.md) | IIS SMTP Server |
|
||||
[system](docs/collector.system.md) | System calls | ✓
|
||||
[tcp](docs/collector.tcp.md) | TCP connections |
|
||||
[terminal_services](docs/collector.terminal_services.md) | Terminal services (RDS)
|
||||
[textfile](docs/collector.textfile.md) | Read prometheus metrics from a text file |
|
||||
[thermalzone](docs/collector.thermalzone.md) | Thermal information |
|
||||
[time](docs/collector.time.md) | Windows Time Service |
|
||||
[udp](docs/collector.udp.md) | UDP connections |
|
||||
[update](docs/collector.update.md) | Windows Update Service |
|
||||
[vmware](docs/collector.vmware.md) | Performance counters installed by the Vmware Guest agent |
|
||||
| Name | Description | Enabled by default |
|
||||
|------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|
|
||||
| [ad](docs/collector.ad.md) | Active Directory Domain Services | |
|
||||
| [adcs](docs/collector.adcs.md) | Active Directory Certificate Services | |
|
||||
| [adfs](docs/collector.adfs.md) | Active Directory Federation Services | |
|
||||
| [cache](docs/collector.cache.md) | Cache metrics | |
|
||||
| [cpu](docs/collector.cpu.md) | CPU usage | ✓ |
|
||||
| [cpu_info](docs/collector.cpu_info.md) | CPU Information | |
|
||||
| [container](docs/collector.container.md) | Container metrics | |
|
||||
| [diskdrive](docs/collector.diskdrive.md) | Diskdrive metrics | |
|
||||
| [dfsr](docs/collector.dfsr.md) | DFSR metrics | |
|
||||
| [dhcp](docs/collector.dhcp.md) | DHCP Server | |
|
||||
| [dns](docs/collector.dns.md) | DNS Server | |
|
||||
| [exchange](docs/collector.exchange.md) | Exchange metrics | |
|
||||
| [filetime](docs/collector.filetime.md) | FileTime metrics | |
|
||||
| [fsrmquota](docs/collector.fsrmquota.md) | Microsoft File Server Resource Manager (FSRM) Quotas collector | |
|
||||
| [gpu](docs/collector.gpu.md) | GPU metrics | |
|
||||
| [hyperv](docs/collector.hyperv.md) | Hyper-V hosts | |
|
||||
| [iis](docs/collector.iis.md) | IIS sites and applications | |
|
||||
| [license](docs/collector.license.md) | Windows license status | |
|
||||
| [logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓ |
|
||||
| [memory](docs/collector.memory.md) | Memory usage metrics | ✓ |
|
||||
| [mscluster](docs/collector.mscluster.md) | MSCluster metrics | |
|
||||
| [msmq](docs/collector.msmq.md) | MSMQ queues | |
|
||||
| [mssql](docs/collector.mssql.md) | [SQL Server Performance Objects](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/use-sql-server-objects#SQLServerPOs) metrics | |
|
||||
| [netframework](docs/collector.netframework.md) | .NET Framework metrics | |
|
||||
| [net](docs/collector.net.md) | Network interface I/O | ✓ |
|
||||
| [os](docs/collector.os.md) | OS metrics (memory, processes, users) | ✓ |
|
||||
| [pagefile](docs/collector.pagefile.md) | pagefile metrics | |
|
||||
| [performancecounter](docs/collector.performancecounter.md) | Custom performance counter metrics | |
|
||||
| [physical_disk](docs/collector.physical_disk.md) | physical disk metrics | ✓ |
|
||||
| [printer](docs/collector.printer.md) | Printer metrics | |
|
||||
| [process](docs/collector.process.md) | Per-process metrics | |
|
||||
| [remote_fx](docs/collector.remote_fx.md) | RemoteFX protocol (RDP) metrics | |
|
||||
| [scheduled_task](docs/collector.scheduled_task.md) | Scheduled Tasks metrics | |
|
||||
| [service](docs/collector.service.md) | Service state metrics | ✓ |
|
||||
| [smb](docs/collector.smb.md) | SMB Server | |
|
||||
| [smbclient](docs/collector.smbclient.md) | SMB Client | |
|
||||
| [smtp](docs/collector.smtp.md) | IIS SMTP Server | |
|
||||
| [system](docs/collector.system.md) | System calls | ✓ |
|
||||
| [tcp](docs/collector.tcp.md) | TCP connections | |
|
||||
| [terminal_services](docs/collector.terminal_services.md) | Terminal services (RDS) | |
|
||||
| [textfile](docs/collector.textfile.md) | Read prometheus metrics from a text file | |
|
||||
| [thermalzone](docs/collector.thermalzone.md) | Thermal information | |
|
||||
| [time](docs/collector.time.md) | Windows Time Service | |
|
||||
| [udp](docs/collector.udp.md) | UDP connections | |
|
||||
| [update](docs/collector.update.md) | Windows Update Service | |
|
||||
| [vmware](docs/collector.vmware.md) | Performance counters installed by the Vmware Guest agent | |
|
||||
|
||||
See the linked documentation on each collector for more information on reported metrics, configuration settings and usage examples.
|
||||
|
||||
@@ -155,7 +154,7 @@ msiexec /i <path-to-msi-file> --% ADDLOCAL=FirewallException APPLICATIONFOLDER="
|
||||
On some older versions of Windows,
|
||||
you may need to surround parameter values with double quotes to get the installation command parsing properly:
|
||||
```powershell
|
||||
msiexec /i C:\Users\Administrator\Downloads\windows_exporter.msi --% ENABLED_COLLECTORS="ad,iis,logon,memory,process,tcp,textfile,thermalzone" TEXTFILE_DIRS="C:\custom_metrics\"
|
||||
msiexec /i C:\Users\Administrator\Downloads\windows_exporter.msi --% ENABLED_COLLECTORS="ad,iis,memory,process,tcp,textfile,thermalzone" TEXTFILE_DIRS="C:\custom_metrics\"
|
||||
```
|
||||
|
||||
To install the exporter with creating a firewall exception, use the following command:
|
||||
@@ -194,7 +193,7 @@ See detailed steps to install on Windows Kubernetes [here](./kubernetes/kubernet
|
||||
|
||||
`windows_exporter` supports Windows Server versions 2016 and later, and desktop Windows version 10 and 11 (21H2 or later).
|
||||
|
||||
Windows Server 2012 and 2012R2 are supported as best-effort only, but not guaranteed to work.
|
||||
There are known compatibility issues with Windows Server 2012 R2 and earlier versions.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -258,7 +257,7 @@ An example configuration file can be found [here](docs/example_config.yml).
|
||||
|
||||
Configuration file values can be mixed with CLI flags. E.G.
|
||||
|
||||
`.\windows_exporter.exe --collectors.enabled=cpu,logon`
|
||||
`.\windows_exporter.exe --collectors.enabled=cpu`
|
||||
|
||||
```yaml
|
||||
log:
|
||||
|
||||
@@ -102,6 +102,7 @@ type windowsExporterService struct{}
|
||||
// Execute is the entry point for the Windows service manager.
|
||||
func (s *windowsExporterService) Execute(_ []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) {
|
||||
changes <- svc.Status{State: svc.StartPending}
|
||||
// Send a signal to the main function that the service is running.
|
||||
changes <- svc.Status{State: svc.Running, Accepts: svc.AcceptStop | svc.AcceptShutdown}
|
||||
|
||||
for {
|
||||
@@ -179,6 +180,7 @@ func logToFile(msg string) {
|
||||
// https://github.com/DataDog/datadog-agent/blob/46740e82ef40a04c4be545ed8c16a4b0d1f046cf/pkg/util/winutil/servicemain/servicemain.go#L128
|
||||
func isWindowsService() (bool, error) {
|
||||
var currentProcess windows.PROCESS_BASIC_INFORMATION
|
||||
|
||||
infoSize := uint32(unsafe.Sizeof(currentProcess))
|
||||
|
||||
err := windows.NtQueryInformationProcess(windows.CurrentProcess(), windows.ProcessBasicInformation, unsafe.Pointer(¤tProcess), infoSize, &infoSize)
|
||||
|
||||
@@ -189,7 +189,6 @@ func waitUntilListening(tb testing.TB, network, address string) error {
|
||||
}
|
||||
|
||||
var winErr windows.Errno
|
||||
|
||||
if errors.As(err, &winErr) {
|
||||
return fmt.Errorf("listener not listening: %w (#%d)", winErr, uint32(winErr))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# example configuration file for windows_exporter
|
||||
|
||||
collectors:
|
||||
enabled: cpu,cpu_info,exchange,iis,logical_disk,logon,memory,net,os,performancecounter,process,remote_fx,service,system,tcp,time,terminal_services,textfile
|
||||
enabled: cpu,cpu_info,exchange,iis,logical_disk,memory,net,os,performancecounter,process,remote_fx,service,system,tcp,time,terminal_services,textfile
|
||||
collector:
|
||||
service:
|
||||
include: "windows_exporter"
|
||||
|
||||
@@ -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)
|
||||
@@ -20,7 +19,6 @@ This directory contains documentation of the collectors in the windows_exporter,
|
||||
- [`iis`](collector.iis.md)
|
||||
- [`license`](collector.license.md)
|
||||
- [`logical_disk`](collector.logical_disk.md)
|
||||
- [`logon`](collector.logon.md)
|
||||
- [`memory`](collector.memory.md)
|
||||
- [`mscluster`](collector.mscluster.md)
|
||||
- [`msmq`](collector.msmq.md)
|
||||
|
||||
@@ -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!_
|
||||
@@ -15,7 +15,7 @@ Enabled by default (error stats)? | Yes |
|
||||
|
||||
Name | Description
|
||||
-----|------------
|
||||
`collector.dns.enabled` | Comma-separated list of collectors to use. Available collectors: `metrics`, `error_stats`. Defaults to all collectors if not specified.
|
||||
`collector.dns.enabled` | Comma-separated list of collectors to use. Available collectors: `metrics`, `wmi_stats`. Defaults to all collectors if not specified.
|
||||
|
||||
## Metrics
|
||||
|
||||
@@ -95,4 +95,4 @@ windows_dns_wmi_stats_total{collection_name="Error Stats",dns_server="EC2AMAZ-5N
|
||||
_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!_
|
||||
_This collector does not yet have alerting examples, we would appreciate your help adding them!_
|
||||
|
||||
@@ -130,6 +130,10 @@ If given, an application needs to *not* match the exclude regexp in order for th
|
||||
| `windows_iis_server_output_cache_hits_total` | Total number of successful lookups in output cache (since service startup) | counter | None |
|
||||
| `windows_iis_server_output_cache_items_flushed_total` | Total number of items flushed from output cache (since service startup) | counter | None |
|
||||
| `windows_iis_server_output_cache_flushes_total` | Total number of flushes of output cache (since service startup) | counter | None |
|
||||
| `http_requests_current_queue_size` | Http Request Current queue size | counter | None |
|
||||
| `http_request_total_rejected_request` | Http Request total rejected request | counter | None |
|
||||
| `http_requests_max_queue_item_age` | Http Request Max queue Item age | counter | None |
|
||||
| `http_requests_arrival_rate` | Http requests Arrival Rate | counter | None |
|
||||
|
||||
### Example metric
|
||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
The logical_disk collector exposes metrics about logical disks (in contrast to physical disks)
|
||||
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `logical_disk`
|
||||
Data source | Perflib
|
||||
Counters | `LogicalDisk` ([`Win32_PerfRawData_PerfDisk_LogicalDisk`](https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71)))
|
||||
Enabled by default? | Yes
|
||||
| | |
|
||||
|---------------------|------------------|
|
||||
| Metric name prefix | `logical_disk` |
|
||||
| Data source | Performance Data |
|
||||
| Counters | `LogicalDisk` |
|
||||
| Enabled by default? | Yes |
|
||||
|
||||
## Flags
|
||||
|
||||
@@ -19,25 +19,30 @@ If given, a disk needs to match the include regexp in order for the correspondin
|
||||
|
||||
If given, a disk needs to *not* match the exclude regexp in order for the corresponding disk metrics to be reported
|
||||
|
||||
### `--collector.logical_disk.enabled`
|
||||
|
||||
Comma-separated list of collectors to use. Available collectors: metrics, bitlocker_status. Defaults to metrics, if not specified.
|
||||
|
||||
## Metrics
|
||||
|
||||
Name | Description | Type | Labels
|
||||
-----|-------------|------|-------
|
||||
`windows_logical_disk_info` | A metric with a constant '1' value labeled with logical disk information | gauge | `disk`,`filesystem`,`serial_number`,`volume`,`volume_name`,`type`
|
||||
`windows_logical_disk_requests_queued` | Number of requests outstanding on the disk at the time the performance data is collected | gauge | `volume`
|
||||
`windows_logical_disk_avg_read_requests_queued` | Average number of read requests that were queued for the selected disk during the sample interval | gauge | `volume`
|
||||
`windows_logical_disk_avg_write_requests_queued` | Average number of write requests that were queued for the selected disk during the sample interval | gauge | `volume`
|
||||
`windows_logical_disk_read_bytes_total` | Rate at which bytes are transferred from the disk during read operations | counter | `volume`
|
||||
`windows_logical_disk_reads_total` | Rate of read operations on the disk | counter | `volume`
|
||||
`windows_logical_disk_write_bytes_total` | Rate at which bytes are transferred to the disk during write operations | counter | `volume`
|
||||
`windows_logical_disk_writes_total` | Rate of write operations on the disk | counter | `volume`
|
||||
`windows_logical_disk_read_seconds_total` | Seconds the disk was busy servicing read requests | counter | `volume`
|
||||
`windows_logical_disk_write_seconds_total` | Seconds the disk was busy servicing write requests | counter | `volume`
|
||||
`windows_logical_disk_free_bytes` | Unused space of the disk in bytes (not real time, updates every 10-15 min) | gauge | `volume`
|
||||
`windows_logical_disk_size_bytes` | Total size of the disk in bytes (not real time, updates every 10-15 min) | gauge | `volume`
|
||||
`windows_logical_disk_idle_seconds_total` | Seconds the disk was idle (not servicing read/write requests) | counter | `volume`
|
||||
`windows_logical_disk_split_ios_total` | Number of I/Os to the disk split into multiple I/Os | counter | `volume`
|
||||
`windows_logical_disk_readonly` | Whether the logical disk is read-only | gauge | `volume`
|
||||
| Name | Description | Type | Labels |
|
||||
|--------------------------------------------------|----------------------------------------------------------------------------------------------------|---------|-------------------------------------------------------------------|
|
||||
| `windows_logical_disk_info` | A metric with a constant '1' value labeled with logical disk information | gauge | `disk`,`filesystem`,`serial_number`,`volume`,`volume_name`,`type` |
|
||||
| `windows_logical_disk_requests_queued` | Number of requests outstanding on the disk at the time the performance data is collected | gauge | `volume` |
|
||||
| `windows_logical_disk_avg_read_requests_queued` | Average number of read requests that were queued for the selected disk during the sample interval | gauge | `volume` |
|
||||
| `windows_logical_disk_avg_write_requests_queued` | Average number of write requests that were queued for the selected disk during the sample interval | gauge | `volume` |
|
||||
| `windows_logical_disk_read_bytes_total` | Rate at which bytes are transferred from the disk during read operations | counter | `volume` |
|
||||
| `windows_logical_disk_reads_total` | Rate of read operations on the disk | counter | `volume` |
|
||||
| `windows_logical_disk_write_bytes_total` | Rate at which bytes are transferred to the disk during write operations | counter | `volume` |
|
||||
| `windows_logical_disk_writes_total` | Rate of write operations on the disk | counter | `volume` |
|
||||
| `windows_logical_disk_read_seconds_total` | Seconds the disk was busy servicing read requests | counter | `volume` |
|
||||
| `windows_logical_disk_write_seconds_total` | Seconds the disk was busy servicing write requests | counter | `volume` |
|
||||
| `windows_logical_disk_free_bytes` | Unused space of the disk in bytes (not real time, updates every 10-15 min) | gauge | `volume` |
|
||||
| `windows_logical_disk_size_bytes` | Total size of the disk in bytes (not real time, updates every 10-15 min) | gauge | `volume` |
|
||||
| `windows_logical_disk_idle_seconds_total` | Seconds the disk was idle (not servicing read/write requests) | counter | `volume` |
|
||||
| `windows_logical_disk_split_ios_total` | Number of I/Os to the disk split into multiple I/Os | counter | `volume` |
|
||||
| `windows_logical_disk_readonly` | Whether the logical disk is read-only | gauge | `volume` |
|
||||
| `windows_logical_disk_bitlocker_status` | BitLocker status for the logical disk | gauge | `volume`,`status` |
|
||||
|
||||
### Warning about size metrics
|
||||
The `free_bytes` and `size_bytes` metrics are not updated in real time and might have a delay of 10-15min.
|
||||
|
||||
@@ -109,7 +109,7 @@ Matching is case-sensitive.
|
||||
| `mscluster_network_Role` | Provides access to the network's Role property. The Role property describes the role of the network in the cluster. 0: None; 1: Cluster; 2: Client; 3: Both | gauge | `name` |
|
||||
| `mscluster_network_State` | Provides the current state of the network. 1-1: Unknown; 0: Unavailable; 1: Down; 2: Partitioned; 3: Up | gauge | `name` |
|
||||
|
||||
### Network
|
||||
### Node
|
||||
|
||||
| Name | Description | Type | Labels |
|
||||
|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|--------|
|
||||
|
||||
@@ -10,13 +10,8 @@ Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
|
||||
### `--collector.textfile.directory`
|
||||
:warning: DEPRECATED Use `--collector.textfile.directories`
|
||||
|
||||
<br>
|
||||
|
||||
### `--collector.textfile.directories`
|
||||
One or multiple directories containing the files to be ingested.
|
||||
One or multiple directories containing the files to be ingested.
|
||||
|
||||
E.G. `--collector.textfile.directories="C:\MyDir1,C:\MyDir2"`
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ Matching is case-sensitive.
|
||||
| `windows_time_ntp_round_trip_delay_seconds` | Total roundtrip delay experienced by the NTP client in receiving a response from the server for the most recent request, in seconds. This is the time elapsed on the NTP client between transmitting a request to the NTP server and receiving a valid response from the server. | gauge | None |
|
||||
| `windows_time_ntp_server_outgoing_responses_total` | Total number of requests responded to by the NTP server. | counter | None |
|
||||
| `windows_time_ntp_server_incoming_requests_total` | Total number of requests received by the NTP server. | counter | None |
|
||||
| `windows_time_current_timestamp_seconds` | Current time as reported by the operating system, in [Unix time](https://en.wikipedia.org/wiki/Unix_time). See [time.Unix()](https://golang.org/pkg/time/#Unix) for details | gauge | None |
|
||||
| `windows_time_current_timestamp_seconds` | Current time as reported by the operating system, in [Unix time](https://en.wikipedia.org/wiki/Unix_time). See [time.UnixMicro()](https://golang.org/pkg/time/#UnixMicro) for details | gauge | None |
|
||||
| `windows_time_timezone` | Current timezone as reported by the operating system. | gauge | `timezone` |
|
||||
| `windows_time_clock_sync_source` | This value reflects the sync source of the system clock. | gauge | `type` |
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
12
go.mod
12
go.mod
@@ -9,7 +9,7 @@ require (
|
||||
github.com/go-ole/go-ole v1.3.0
|
||||
github.com/prometheus/client_golang v1.22.0
|
||||
github.com/prometheus/client_model v0.6.2
|
||||
github.com/prometheus/common v0.64.0
|
||||
github.com/prometheus/common v0.65.0
|
||||
github.com/prometheus/exporter-toolkit v0.14.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
golang.org/x/sys v0.33.0
|
||||
@@ -28,13 +28,13 @@ require (
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/procfs v0.16.1 // indirect
|
||||
github.com/prometheus/procfs v0.17.0 // indirect
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
|
||||
golang.org/x/crypto v0.38.0 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/crypto v0.39.0 // indirect
|
||||
golang.org/x/net v0.41.0 // indirect
|
||||
golang.org/x/oauth2 v0.30.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
golang.org/x/sync v0.15.0 // indirect
|
||||
golang.org/x/text v0.26.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
||||
24
go.sum
24
go.sum
@@ -45,12 +45,12 @@ github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/
|
||||
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
|
||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
||||
github.com/prometheus/common v0.64.0 h1:pdZeA+g617P7oGv1CzdTzyeShxAGrTBsolKNOLQPGO4=
|
||||
github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
|
||||
github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE=
|
||||
github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
|
||||
github.com/prometheus/exporter-toolkit v0.14.0 h1:NMlswfibpcZZ+H0sZBiTjrA3/aBFHkNZqE+iCj5EmRg=
|
||||
github.com/prometheus/exporter-toolkit v0.14.0/go.mod h1:Gu5LnVvt7Nr/oqTBUC23WILZepW0nffNo10XdhQcwWA=
|
||||
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
|
||||
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
|
||||
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
|
||||
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -65,19 +65,19 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
|
||||
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
|
||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
|
||||
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
|
||||
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
|
||||
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
|
||||
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
|
||||
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
|
||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
|
||||
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
<Control Id="Title" Type="Text" X="15" Y="6" Width="210" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}windows_exporter configuration" />
|
||||
|
||||
<!-- Edit box for property input -->
|
||||
<!-- cpu,cs,logical_disk,physical_disk,net,os,service,system -->
|
||||
<!-- cpu,logical_disk,physical_disk,net,os,service,system -->
|
||||
<Control Id="PropertyEdit_ENABLED_COLLECTORS_Title1" Type="Text" X="25" Y="55" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="Comma-separated list of collectors to use. Use '[\[]defaults[\]]' as a placeholder for all" />
|
||||
<Control Id="PropertyEdit_ENABLED_COLLECTORS_Title2" Type="Text" X="25" Y="65" Width="300" Height="15" Transparent="yes" NoPrefix="yes" Text="the collectors enabled by default. If value is empty, the exporter default will be used." />
|
||||
<Control Id="PropertyEdit_ENABLED_COLLECTORS" Type="Edit" X="24" Y="77" Width="300" Height="18" Property="ENABLED_COLLECTORS" Text="[ENABLED_COLLECTORS]" Indirect="no" />
|
||||
|
||||
@@ -522,6 +522,8 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", err)
|
||||
} else if len(c.perfDataObject) == 0 {
|
||||
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", types.ErrNoDataUnexpected)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -530,30 +532,35 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].AbANRPerSec,
|
||||
"ambiguous_name_resolution",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.addressBookOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].AbBrowsesPerSec,
|
||||
"browse",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.addressBookOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].AbMatchesPerSec,
|
||||
"find",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.addressBookOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].AbPropertyReadsPerSec,
|
||||
"property_read",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.addressBookOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].AbSearchesPerSec,
|
||||
"search",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.addressBookOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -578,22 +585,26 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].AtqEstimatedQueueDelay/1000,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.atqOutstandingRequests,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].AtqOutstandingQueuedRequests,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.atqAverageRequestLatency,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].AtqRequestLatency,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.atqCurrentThreads,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].AtqThreadsLDAP,
|
||||
"ldap",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.atqCurrentThreads,
|
||||
prometheus.GaugeValue,
|
||||
@@ -607,12 +618,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].BaseSearchesPerSec,
|
||||
"base",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.searchesTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SubtreeSearchesPerSec,
|
||||
"subtree",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.searchesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -626,18 +639,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].DatabaseAddsPerSec,
|
||||
"add",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.databaseOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DatabaseDeletesPerSec,
|
||||
"delete",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.databaseOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DatabaseModifiesPerSec,
|
||||
"modify",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.databaseOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -651,48 +667,56 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].DigestBindsPerSec,
|
||||
"digest",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DsClientBindsPerSec,
|
||||
"ds_client",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DsServerBindsPerSec,
|
||||
"ds_server",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].ExternalBindsPerSec,
|
||||
"external",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].FastBindsPerSec,
|
||||
"fast",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].NegotiatedBindsPerSec,
|
||||
"negotiate",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].NTLMBindsPerSec,
|
||||
"ntlm",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SimpleBindsPerSec,
|
||||
"simple",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bindsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -706,6 +730,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
float64(uint64(c.perfDataObject[0].DRAHighestUSNCommittedHighPart)<<32)+c.perfDataObject[0].DRAHighestUSNCommittedLowPart,
|
||||
"committed",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.replicationHighestUsn,
|
||||
prometheus.CounterValue,
|
||||
@@ -744,6 +769,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].DRAInboundBytesNotCompressedWithinSitePerSec,
|
||||
"inbound",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.intraSiteReplicationDataBytesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -768,6 +794,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DRAInboundObjectsAppliedPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.replicationInboundObjectsFilteredTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -779,6 +806,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DRAInboundPropertiesAppliedPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.replicationInboundPropertiesFilteredTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -790,6 +818,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].DRAPendingReplicationOperations,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.replicationPendingSynchronizations,
|
||||
prometheus.GaugeValue,
|
||||
@@ -801,11 +830,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DRASyncRequestsMade,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.replicationSyncRequestsSuccessTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DRASyncRequestsSuccessful,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.replicationSyncRequestsSchemaMismatchFailureTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -818,6 +849,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].DsClientNameTranslationsPerSec,
|
||||
"client",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.nameTranslationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -830,6 +862,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].DsMonitorListSize,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.changeMonitorUpdatesPending,
|
||||
prometheus.GaugeValue,
|
||||
@@ -841,6 +874,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DsNameCacheHitRate,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.nameCacheLookupsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -854,6 +888,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"read",
|
||||
"replication_agent",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -861,6 +896,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"read",
|
||||
"knowledge_consistency_checker",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -868,6 +904,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"read",
|
||||
"local_security_authority",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -875,6 +912,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"read",
|
||||
"name_service_provider_interface",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -882,6 +920,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"read",
|
||||
"directory_service_api",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -889,6 +928,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"read",
|
||||
"security_account_manager",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -896,6 +936,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"read",
|
||||
"other",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -903,6 +944,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"replication_agent",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -910,6 +952,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"knowledge_consistency_checker",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -917,6 +960,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"ldap",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -924,6 +968,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"local_security_authority",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -931,6 +976,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"name_service_provider_interface",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -938,6 +984,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"directory_service_api",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -945,6 +992,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"security_account_manager",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -952,6 +1000,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"search",
|
||||
"other",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -959,6 +1008,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"write",
|
||||
"replication_agent",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -966,6 +1016,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"write",
|
||||
"knowledge_consistency_checker",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -973,6 +1024,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"write",
|
||||
"ldap",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -980,6 +1032,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"write",
|
||||
"local_security_authority",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -987,6 +1040,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"write",
|
||||
"name_service_provider_interface",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -994,6 +1048,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"write",
|
||||
"directory_service_api",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1001,6 +1056,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
"write",
|
||||
"security_account_manager",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.directoryOperationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1020,16 +1076,19 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DsSecurityDescriptorSubOperationsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.securityDescriptorPropagationEventsQueued,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].DsSecurityDescriptorPropagationsEvents,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.securityDescriptorPropagationAccessWaitTotalSeconds,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].DsSecurityDescriptorPropagatorAverageExclusionTime,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.securityDescriptorPropagationItemsQueuedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1047,12 +1106,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].LdapClosedConnectionsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ldapOpenedConnectionsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].LdapNewConnectionsPerSec,
|
||||
"ldap",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ldapOpenedConnectionsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1083,11 +1144,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].LdapUDPOperationsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ldapWritesTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].LdapWritesPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ldapClientSessions,
|
||||
prometheus.GaugeValue,
|
||||
@@ -1105,6 +1168,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].PhantomsCleanedPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.phantomObjectsVisitedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1117,18 +1181,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].SamGlobalGroupMembershipEvaluationsPerSec,
|
||||
"global",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samGroupMembershipEvaluationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SamDomainLocalGroupMembershipEvaluationsPerSec,
|
||||
"domain_local",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samGroupMembershipEvaluationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SamUniversalGroupMembershipEvaluationsPerSec,
|
||||
"universal",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samGroupMembershipGlobalCatalogEvaluationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1140,6 +1207,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SamNonTransitiveMembershipEvaluationsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samGroupMembershipEvaluationsTransitiveTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1152,6 +1220,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].SamAccountGroupEvaluationLatency,
|
||||
"account_group",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samGroupEvaluationLatency,
|
||||
prometheus.GaugeValue,
|
||||
@@ -1164,6 +1233,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SamSuccessfulComputerCreationsPerSecIncludesAllRequests,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samComputerCreationSuccessfulRequestsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1175,6 +1245,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SamUserCreationAttemptsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samUserCreationSuccessfulRequestsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1186,6 +1257,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SamDisplayInformationQueriesPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.samEnumerationsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -1209,6 +1281,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].TombstonesGarbageCollectedPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.tombstonesObjectsVisitedTotal,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -186,72 +186,84 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
data.RequestsPerSecond,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.requestProcessingTime,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.RequestProcessingTime),
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.retrievalsPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.RetrievalsPerSecond,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.retrievalProcessingTime,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.RetrievalProcessingTime),
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.failedRequestsPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.FailedRequestsPerSecond,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.issuedRequestsPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.IssuedRequestsPerSecond,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.pendingRequestsPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.PendingRequestsPerSecond,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.requestCryptographicSigningTime,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.RequestCryptographicSigningTime),
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.requestPolicyModuleProcessingTime,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.RequestPolicyModuleProcessingTime),
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.challengeResponsesPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.ChallengeResponsesPerSecond,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.challengeResponseProcessingTime,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.ChallengeResponseProcessingTime),
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.signedCertificateTimestampListsPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.SignedCertificateTimestampListsPerSecond,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.signedCertificateTimestampListProcessingTime,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -387,6 +387,8 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect ADFS metrics: %w", err)
|
||||
} else if len(c.perfDataObject) == 0 {
|
||||
return fmt.Errorf("failed to collect ADFS metrics: %w", types.ErrNoDataUnexpected)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
||||
2
internal/collector/cache/cache.go
vendored
2
internal/collector/cache/cache.go
vendored
@@ -290,6 +290,8 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect Cache metrics: %w", err)
|
||||
} else if len(c.perfDataObject) == 0 {
|
||||
return fmt.Errorf("failed to collect Cache metrics: %w", types.ErrNoDataUnexpected)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
||||
"github.com/go-ole/go-ole"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/hcn"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/hcs"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/iphlpapi"
|
||||
@@ -437,6 +437,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
1,
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "false",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -444,6 +445,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitPeakBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -451,6 +453,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usagePrivateWorkingSetBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -458,6 +461,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -465,6 +469,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeUser,
|
||||
prometheus.CounterValue,
|
||||
@@ -472,6 +477,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeKernel,
|
||||
prometheus.CounterValue,
|
||||
@@ -479,6 +485,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
@@ -486,6 +493,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
@@ -493,6 +501,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
@@ -500,6 +509,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
@@ -536,7 +546,7 @@ func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error {
|
||||
continue
|
||||
}
|
||||
|
||||
var nicGUID *guid.GUID
|
||||
var nicGUID *ole.GUID
|
||||
|
||||
for _, allocator := range properties.Resources.Allocators {
|
||||
if allocator.AdapterNetCfgInstanceId != nil {
|
||||
@@ -558,6 +568,7 @@ func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error {
|
||||
}
|
||||
|
||||
var endpointStats iphlpapi.MIB_IF_ROW2
|
||||
|
||||
endpointStats.InterfaceLuid = luid
|
||||
|
||||
if err := iphlpapi.GetIfEntry2Ex(&endpointStats); err != nil {
|
||||
@@ -597,24 +608,28 @@ func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error {
|
||||
float64(endpointStats.OutOctets),
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsReceived,
|
||||
prometheus.CounterValue,
|
||||
float64(endpointStats.InUcastPkts+endpointStats.InNUcastPkts),
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsSent,
|
||||
prometheus.CounterValue,
|
||||
float64(endpointStats.OutUcastPkts+endpointStats.OutNUcastPkts),
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.droppedPacketsIncoming,
|
||||
prometheus.CounterValue,
|
||||
float64(endpointStats.InDiscards+endpointStats.InErrors),
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.droppedPacketsOutgoing,
|
||||
prometheus.CounterValue,
|
||||
@@ -768,6 +783,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
1,
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "true",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -775,6 +791,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usageCommitPeakBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -782,6 +799,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usagePrivateWorkingSetBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -789,6 +807,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -796,6 +815,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeUser,
|
||||
prometheus.CounterValue,
|
||||
@@ -803,6 +823,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.runtimeKernel,
|
||||
prometheus.CounterValue,
|
||||
@@ -810,6 +831,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
@@ -817,6 +839,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
@@ -824,6 +847,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeCountNormalized,
|
||||
prometheus.CounterValue,
|
||||
@@ -831,6 +855,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
||||
|
||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeSizeBytes,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -234,12 +234,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
coreData.C1TimeSeconds,
|
||||
core, "c1",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData.C2TimeSeconds,
|
||||
core, "c2",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cStateSecondsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -253,24 +255,28 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
coreData.IdleTimeSeconds,
|
||||
core, "idle",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData.InterruptTimeSeconds,
|
||||
core, "interrupt",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData.DpcTimeSeconds,
|
||||
core, "dpc",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData.PrivilegedTimeSeconds,
|
||||
core, "privileged",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -284,18 +290,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
coreData.InterruptsTotal,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dpcsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData.DpcQueuedPerSecond,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.clockInterruptsTotal,
|
||||
prometheus.CounterValue,
|
||||
coreData.ClockInterruptsTotal,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.idleBreakEventsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -316,30 +325,35 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
coreData.ProcessorFrequencyMHz,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorPerformance,
|
||||
prometheus.CounterValue,
|
||||
coreData.ProcessorPerformance,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorMPerf,
|
||||
prometheus.CounterValue,
|
||||
counterProcessorMPerfValues.Value(),
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorRTC,
|
||||
prometheus.CounterValue,
|
||||
counterProcessorRTCValues.Value(),
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorUtility,
|
||||
prometheus.CounterValue,
|
||||
coreData.ProcessorUtilityRate,
|
||||
core,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorPrivilegedUtility,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -194,36 +194,42 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
strconv.Itoa(int(processor.Family)),
|
||||
strings.TrimRight(processor.Name, " "),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cpuCoreCount,
|
||||
prometheus.GaugeValue,
|
||||
float64(processor.NumberOfCores),
|
||||
strings.TrimRight(processor.DeviceID, " "),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cpuEnabledCoreCount,
|
||||
prometheus.GaugeValue,
|
||||
float64(processor.NumberOfEnabledCore),
|
||||
strings.TrimRight(processor.DeviceID, " "),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cpuLogicalProcessorsCount,
|
||||
prometheus.GaugeValue,
|
||||
float64(processor.NumberOfLogicalProcessors),
|
||||
strings.TrimRight(processor.DeviceID, " "),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cpuThreadCount,
|
||||
prometheus.GaugeValue,
|
||||
float64(processor.ThreadCount),
|
||||
strings.TrimRight(processor.DeviceID, " "),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cpuL2CacheSize,
|
||||
prometheus.GaugeValue,
|
||||
float64(processor.L2CacheSize),
|
||||
strings.TrimRight(processor.DeviceID, " "),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.cpuL3CacheSize,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -56,6 +56,8 @@ var ConfigDefaults = Config{
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
logger *slog.Logger
|
||||
|
||||
perfDataCollector *pdh.Collector
|
||||
perfDataObject []perfDataCounterValues
|
||||
|
||||
@@ -147,7 +149,9 @@ func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
c.logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
var err error
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, subCollectorScopeMetrics) {
|
||||
@@ -405,6 +409,8 @@ func (c *Collector) collectServerMetrics(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
|
||||
} else if len(c.perfDataObject) == 0 {
|
||||
return fmt.Errorf("failed to collect DHCP Server metrics: %w", types.ErrNoDataUnexpected)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
||||
@@ -38,7 +38,9 @@ var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for a few WMI metrics in Win32_DiskDrive.
|
||||
type Collector struct {
|
||||
config Config
|
||||
config Config
|
||||
logger *slog.Logger
|
||||
|
||||
miSession *mi.Session
|
||||
miQuery mi.Query
|
||||
|
||||
@@ -73,7 +75,9 @@ func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error {
|
||||
func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
||||
c.logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
c.diskInfo = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||
"General drive information",
|
||||
@@ -148,7 +152,7 @@ var (
|
||||
"Error",
|
||||
"Degraded",
|
||||
"Unknown",
|
||||
"Pred fail",
|
||||
"Pred Fail",
|
||||
"Starting",
|
||||
"Stopping",
|
||||
"Service",
|
||||
@@ -241,6 +245,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
if availNum == int(disk.Availability) {
|
||||
isCurrentState = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.availability,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -347,6 +347,8 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect DNS metrics: %w", err)
|
||||
} else if len(c.perfDataObject) == 0 {
|
||||
return fmt.Errorf("failed to collect DNS metrics: %w", types.ErrNoDataUnexpected)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -355,6 +357,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].AxfrRequestReceived,
|
||||
"full",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.zoneTransferRequestsReceived,
|
||||
prometheus.CounterValue,
|
||||
@@ -368,12 +371,14 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].AxfrRequestSent,
|
||||
"full",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.zoneTransferRequestsSent,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].IxfrRequestSent,
|
||||
"incremental",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.zoneTransferRequestsSent,
|
||||
prometheus.CounterValue,
|
||||
@@ -387,6 +392,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].AxfrResponseReceived,
|
||||
"full",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.zoneTransferResponsesReceived,
|
||||
prometheus.CounterValue,
|
||||
@@ -401,6 +407,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
"full",
|
||||
"tcp",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.zoneTransferSuccessReceived,
|
||||
prometheus.CounterValue,
|
||||
@@ -408,6 +415,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
"incremental",
|
||||
"tcp",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.zoneTransferSuccessReceived,
|
||||
prometheus.CounterValue,
|
||||
@@ -422,6 +430,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].AxfrSuccessSent,
|
||||
"full",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.zoneTransferSuccessSent,
|
||||
prometheus.CounterValue,
|
||||
@@ -441,30 +450,35 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].CachingMemory,
|
||||
"caching",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.memoryUsedBytes,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].DatabaseNodeMemory,
|
||||
"database_node",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.memoryUsedBytes,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].NbStatMemory,
|
||||
"nbstat",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.memoryUsedBytes,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].RecordFlowMemory,
|
||||
"record_flow",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.memoryUsedBytes,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].TcpMessageMemory,
|
||||
"tcp_message",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.memoryUsedBytes,
|
||||
prometheus.GaugeValue,
|
||||
@@ -478,23 +492,27 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].DynamicUpdateNoOperation,
|
||||
"noop",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dynamicUpdatesReceived,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DynamicUpdateWrittenToDatabase,
|
||||
"written",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dynamicUpdatesQueued,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].DynamicUpdateQueued,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dynamicUpdatesFailures,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].DynamicUpdateRejected,
|
||||
"rejected",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.dynamicUpdatesFailures,
|
||||
prometheus.CounterValue,
|
||||
@@ -507,6 +525,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].NotifyReceived,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.notifySent,
|
||||
prometheus.CounterValue,
|
||||
@@ -518,11 +537,13 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].RecursiveQueries,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.recursiveQueryFailures,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].RecursiveQueryFailure,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.recursiveQuerySendTimeouts,
|
||||
prometheus.CounterValue,
|
||||
@@ -535,6 +556,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].TcpQueryReceived,
|
||||
"tcp",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.queries,
|
||||
prometheus.CounterValue,
|
||||
@@ -548,6 +570,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].TcpResponseSent,
|
||||
"tcp",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.responses,
|
||||
prometheus.CounterValue,
|
||||
@@ -567,6 +590,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].WinsLookupReceived,
|
||||
"forward",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.winsQueries,
|
||||
prometheus.CounterValue,
|
||||
@@ -580,6 +604,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
c.perfDataObject[0].WinsResponseSent,
|
||||
"forward",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.winsResponses,
|
||||
prometheus.CounterValue,
|
||||
@@ -592,6 +617,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SecureUpdateFailure,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.secureUpdateReceived,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -66,11 +66,6 @@ var ConfigDefaults = Config{
|
||||
}
|
||||
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||
closeFns []func()
|
||||
|
||||
collectorADAccessProcesses
|
||||
collectorActiveSync
|
||||
collectorAutoDiscover
|
||||
@@ -81,6 +76,11 @@ type Collector struct {
|
||||
collectorRpcClientAccess
|
||||
collectorTransportQueues
|
||||
collectorWorkloadManagementWorkloads
|
||||
|
||||
config Config
|
||||
|
||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||
closeFns []func()
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
|
||||
@@ -82,11 +82,13 @@ func (c *Collector) collectActiveSync(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
data.RequestsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.pingCommandsPending,
|
||||
prometheus.GaugeValue,
|
||||
data.PingCommandsPending,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.syncCommandsPerSec,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -113,24 +113,28 @@ func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error
|
||||
utils.MilliSecToSec(data.LdapReadTime),
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ldapSearchTime,
|
||||
prometheus.CounterValue,
|
||||
utils.MilliSecToSec(data.LdapSearchTime),
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ldapWriteTime,
|
||||
prometheus.CounterValue,
|
||||
utils.MilliSecToSec(data.LdapWriteTime),
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ldapTimeoutErrorsPerSec,
|
||||
prometheus.CounterValue,
|
||||
data.LdapTimeoutErrorsPerSec,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.longRunningLDAPOperationsPerMin,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -111,30 +111,35 @@ func (c *Collector) collectHTTPProxy(ch chan<- prometheus.Metric) error {
|
||||
utils.MilliSecToSec(data.MailboxServerLocatorAverageLatency),
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.averageAuthenticationLatency,
|
||||
prometheus.GaugeValue,
|
||||
data.AverageAuthenticationLatency,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.averageCASProcessingLatency,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.AverageCASProcessingLatency),
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.mailboxServerProxyFailureRate,
|
||||
prometheus.GaugeValue,
|
||||
data.MailboxServerProxyFailureRate,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.outstandingProxyRequests,
|
||||
prometheus.GaugeValue,
|
||||
data.OutstandingProxyRequests,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.proxyRequestsPerSec,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -74,6 +74,7 @@ func (c *Collector) collectOWA(ch chan<- prometheus.Metric) error {
|
||||
prometheus.GaugeValue,
|
||||
data.CurrentUniqueUsers,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.owaRequestsPerSec,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -107,26 +107,31 @@ func (c *Collector) collectRpcClientAccess(ch chan<- prometheus.Metric) error {
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.RpcAveragedLatency),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.rpcRequests,
|
||||
prometheus.GaugeValue,
|
||||
data.RpcRequests,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.activeUserCount,
|
||||
prometheus.GaugeValue,
|
||||
data.ActiveUserCount,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.connectionCount,
|
||||
prometheus.GaugeValue,
|
||||
data.ConnectionCount,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.rpcOperationsPerSec,
|
||||
prometheus.CounterValue,
|
||||
data.RpcOperationsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.userCount,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -215,108 +215,126 @@ func (c *Collector) collectTransportQueues(ch chan<- prometheus.Metric) error {
|
||||
data.ExternalActiveRemoteDeliveryQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.internalActiveRemoteDeliveryQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.InternalActiveRemoteDeliveryQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.activeMailboxDeliveryQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.ActiveMailboxDeliveryQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.retryMailboxDeliveryQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.RetryMailboxDeliveryQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.unreachableQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.UnreachableQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.externalLargestDeliveryQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.ExternalLargestDeliveryQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.internalLargestDeliveryQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.InternalLargestDeliveryQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.poisonQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.PoisonQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.messagesQueuedForDeliveryTotal,
|
||||
prometheus.CounterValue,
|
||||
data.MessagesQueuedForDeliveryTotal,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.messagesSubmittedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.MessagesSubmittedTotal,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.messagesDelayedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.MessagesDelayedTotal,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.messagesCompletedDeliveryTotal,
|
||||
prometheus.CounterValue,
|
||||
data.MessagesCompletedDeliveryTotal,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.aggregateShadowQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.AggregateShadowQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.submissionQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.SubmissionQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.delayQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.DelayQueueLength,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.itemsCompletedDeliveryTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ItemsCompletedDeliveryTotal,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.itemsQueuedForDeliveryExpiredTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ItemsQueuedForDeliveryExpiredTotal,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.itemsQueuedForDeliveryTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ItemsQueuedForDeliveryTotal,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.itemsResubmittedTotal,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -103,24 +103,28 @@ func (c *Collector) collectWorkloadManagementWorkloads(ch chan<- prometheus.Metr
|
||||
data.ActiveTasks,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.completedTasks,
|
||||
prometheus.CounterValue,
|
||||
data.CompletedTasks,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.queuedTasks,
|
||||
prometheus.CounterValue,
|
||||
data.QueuedTasks,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.yieldedTasks,
|
||||
prometheus.CounterValue,
|
||||
data.YieldedTasks,
|
||||
labelName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.isActive,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -172,7 +172,7 @@ func (c *Collector) collectGlobFilePath(ch chan<- prometheus.Metric, filePattern
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.fileMTime,
|
||||
prometheus.GaugeValue,
|
||||
float64(fileInfo.ModTime().UTC().Unix()),
|
||||
float64(fileInfo.ModTime().UTC().UnixMicro())/1e6,
|
||||
filePath,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
path,
|
||||
template,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.size,
|
||||
prometheus.GaugeValue,
|
||||
@@ -197,6 +198,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
path,
|
||||
template,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.usage,
|
||||
prometheus.GaugeValue,
|
||||
@@ -204,12 +206,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
path,
|
||||
template,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.description,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
path, template, Description,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.disabled,
|
||||
prometheus.GaugeValue,
|
||||
@@ -217,6 +221,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
path,
|
||||
template,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.matchesTemplate,
|
||||
prometheus.GaugeValue,
|
||||
@@ -224,6 +229,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
path,
|
||||
template,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.softLimit,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -335,12 +335,14 @@ func (c *Collector) collectGpuAdapterMemoryMetrics(ch chan<- prometheus.Metric)
|
||||
dedicatedUsage,
|
||||
key.Phys,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.gpuAdapterMemorySharedUsage,
|
||||
prometheus.GaugeValue,
|
||||
sharedUsageMap[key],
|
||||
key.Phys,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.gpuAdapterMemoryTotalCommitted,
|
||||
prometheus.GaugeValue,
|
||||
@@ -437,24 +439,28 @@ func (c *Collector) collectGpuProcessMemoryMetrics(ch chan<- prometheus.Metric)
|
||||
dedicatedUsage,
|
||||
key.Pid, key.Phys,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.gpuProcessMemoryLocalUsage,
|
||||
prometheus.GaugeValue,
|
||||
processLocalUsageMap[key],
|
||||
key.Pid, key.Phys,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.gpuProcessMemoryNonLocalUsage,
|
||||
prometheus.GaugeValue,
|
||||
processNonLocalUsageMap[key],
|
||||
key.Pid, key.Phys,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.gpuProcessMemorySharedUsage,
|
||||
prometheus.GaugeValue,
|
||||
processSharedUsageMap[key],
|
||||
key.Pid, key.Phys,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.gpuProcessMemoryTotalCommitted,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -78,11 +78,6 @@ var ConfigDefaults = Config{
|
||||
|
||||
// Collector is a Prometheus Collector for hyper-v.
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||
closeFns []func()
|
||||
|
||||
collectorDataStore
|
||||
collectorDynamicMemoryBalancer
|
||||
collectorDynamicMemoryVM
|
||||
@@ -98,6 +93,11 @@ type Collector struct {
|
||||
collectorVirtualSMB
|
||||
collectorVirtualStorageDevice
|
||||
collectorVirtualSwitch
|
||||
|
||||
config Config
|
||||
|
||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||
closeFns []func()
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
|
||||
@@ -310,26 +310,31 @@ func (c *Collector) collectHypervisorRootPartition(ch chan<- prometheus.Metric)
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MDevicePages,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.hypervisorRootPartition2MGPAPages,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MGPAPages,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.hypervisorRootPartition4KDevicePages,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KDevicePages,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.hypervisorRootPartition4KGPAPages,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KGPAPages,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.hypervisorRootPartitionVirtualTLBFlushEntries,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBFlushEntries,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.hypervisorRootPartitionVirtualTLBPages,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -195,294 +195,343 @@ func (c *Collector) collectVirtualNetworkAdapterDropReasons(ch chan<- prometheus
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
|
||||
data.Name, "NativeFwdingReq", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
|
||||
data.Name, "NativeFwdingReq", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
|
||||
data.Name, "MTUMismatch", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingMTUMismatch,
|
||||
data.Name, "MTUMismatch", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
|
||||
data.Name, "InvalidConfig", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingInvalidConfig,
|
||||
data.Name, "InvalidConfig", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
|
||||
data.Name, "RequiredExtensionMissing", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
|
||||
data.Name, "RequiredExtensionMissing", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
|
||||
data.Name, "VirtualSubnetId", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
|
||||
data.Name, "VirtualSubnetId", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
|
||||
data.Name, "BridgeReserved", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingBridgeReserved,
|
||||
data.Name, "BridgeReserved", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingRouterGuard,
|
||||
data.Name, "RouterGuard", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingRouterGuard,
|
||||
data.Name, "RouterGuard", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
|
||||
data.Name, "DhcpGuard", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingDhcpGuard,
|
||||
data.Name, "DhcpGuard", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
|
||||
data.Name, "MacSpoofing", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingMacSpoofing,
|
||||
data.Name, "MacSpoofing", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingIpsec,
|
||||
data.Name, "Ipsec", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingIpsec,
|
||||
data.Name, "Ipsec", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingQos,
|
||||
data.Name, "Qos", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingQos,
|
||||
data.Name, "Qos", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
|
||||
data.Name, "FailedPvlanSetting", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
|
||||
data.Name, "FailedPvlanSetting", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
|
||||
data.Name, "FailedSecurityPolicy", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
|
||||
data.Name, "FailedSecurityPolicy", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
|
||||
data.Name, "UnauthorizedMAC", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
|
||||
data.Name, "UnauthorizedMAC", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
|
||||
data.Name, "UnauthorizedVLAN", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
|
||||
data.Name, "UnauthorizedVLAN", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
|
||||
data.Name, "FilteredVLAN", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
|
||||
data.Name, "FilteredVLAN", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingFiltered,
|
||||
data.Name, "Filtered", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingFiltered,
|
||||
data.Name, "Filtered", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingBusy,
|
||||
data.Name, "Busy", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingBusy,
|
||||
data.Name, "Busy", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingNotAccepted,
|
||||
data.Name, "NotAccepted", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingNotAccepted,
|
||||
data.Name, "NotAccepted", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingDisconnected,
|
||||
data.Name, "Disconnected", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingDisconnected,
|
||||
data.Name, "Disconnected", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingNotReady,
|
||||
data.Name, "NotReady", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingNotReady,
|
||||
data.Name, "NotReady", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingResources,
|
||||
data.Name, "Resources", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingResources,
|
||||
data.Name, "Resources", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
|
||||
data.Name, "InvalidPacket", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingInvalidPacket,
|
||||
data.Name, "InvalidPacket", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidData,
|
||||
data.Name, "InvalidData", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsIncomingInvalidData,
|
||||
data.Name, "InvalidData", "incoming",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualNetworkAdapterDropReasonsOutgoingUnknown,
|
||||
data.Name, "Unknown", "outgoing",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualNetworkAdapterDropReasons,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -265,6 +265,7 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
||||
data.VirtualSwitchDirectedPacketsReceived,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchDirectedPacketsSent,
|
||||
prometheus.CounterValue,
|
||||
@@ -278,18 +279,21 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
||||
data.VirtualSwitchDroppedPacketsIncoming,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchDroppedPacketsOutgoing,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualSwitchDroppedPacketsOutgoing,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchExtensionsDroppedPacketsIncoming,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualSwitchExtensionsDroppedPacketsIncoming,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchExtensionsDroppedPacketsOutgoing,
|
||||
prometheus.CounterValue,
|
||||
@@ -303,24 +307,28 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
||||
data.VirtualSwitchLearnedMacAddresses,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchMulticastPacketsReceived,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualSwitchMulticastPacketsReceived,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchMulticastPacketsSent,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualSwitchMulticastPacketsSent,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchNumberOfSendChannelMoves,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualSwitchNumberOfSendChannelMoves,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchNumberOfVMQMoves,
|
||||
prometheus.CounterValue,
|
||||
@@ -348,12 +356,14 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
||||
data.VirtualSwitchPacketsReceived,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchPacketsSent,
|
||||
prometheus.CounterValue,
|
||||
data.VirtualSwitchPacketsSent,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualSwitchPurgedMacAddresses,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -50,14 +50,18 @@ var ConfigDefaults = Config{
|
||||
}
|
||||
|
||||
type Collector struct {
|
||||
config Config
|
||||
iisVersion simpleVersion
|
||||
|
||||
info *prometheus.Desc
|
||||
collectorWebService
|
||||
collectorHttpServiceRequestQueues
|
||||
collectorAppPoolWAS
|
||||
collectorW3SVCW3WP
|
||||
collectorWebServiceCache
|
||||
|
||||
config Config
|
||||
iisVersion simpleVersion
|
||||
|
||||
logger *slog.Logger
|
||||
|
||||
info *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
@@ -150,6 +154,7 @@ func (c *Collector) GetName() string {
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
c.perfDataCollectorWebService.Close()
|
||||
c.perfDataCollectorHttpServiceRequestQueues.Close()
|
||||
c.perfDataCollectorAppPoolWAS.Close()
|
||||
c.w3SVCW3WPPerfDataCollector.Close()
|
||||
c.serviceCachePerfDataCollector.Close()
|
||||
@@ -158,9 +163,9 @@ func (c *Collector) Close() error {
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
logger = logger.With(slog.String("collector", Name))
|
||||
c.logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
c.iisVersion = c.getIISVersion(logger)
|
||||
c.iisVersion = c.getIISVersion()
|
||||
|
||||
c.info = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||
@@ -175,6 +180,10 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
errs = append(errs, fmt.Errorf("failed to build Web Service collector: %w", err))
|
||||
}
|
||||
|
||||
if err := c.buildHttpServiceRequestQueues(); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to build Http Service collector: %w", err))
|
||||
}
|
||||
|
||||
if err := c.buildAppPoolWAS(); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to build APP_POOL_WAS collector: %w", err))
|
||||
}
|
||||
@@ -195,10 +204,10 @@ type simpleVersion struct {
|
||||
minor uint64
|
||||
}
|
||||
|
||||
func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
|
||||
func (c *Collector) getIISVersion() simpleVersion {
|
||||
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\InetStp\`, registry.QUERY_VALUE)
|
||||
if err != nil {
|
||||
logger.Warn("couldn't open registry to determine IIS version",
|
||||
c.logger.Warn("couldn't open registry to determine IIS version",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
@@ -208,7 +217,7 @@ func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
|
||||
defer func() {
|
||||
err = k.Close()
|
||||
if err != nil {
|
||||
logger.Warn("Failed to close registry key",
|
||||
c.logger.Warn("Failed to close registry key",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
@@ -216,7 +225,7 @@ func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
|
||||
|
||||
major, _, err := k.GetIntegerValue("MajorVersion")
|
||||
if err != nil {
|
||||
logger.Warn("Couldn't open registry to determine IIS version",
|
||||
c.logger.Warn("Couldn't open registry to determine IIS version",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
@@ -225,14 +234,14 @@ func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
|
||||
|
||||
minor, _, err := k.GetIntegerValue("MinorVersion")
|
||||
if err != nil {
|
||||
logger.Warn("Couldn't open registry to determine IIS version",
|
||||
c.logger.Warn("Couldn't open registry to determine IIS version",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
|
||||
return simpleVersion{}
|
||||
}
|
||||
|
||||
logger.Debug(fmt.Sprintf("Detected IIS %d.%d\n", major, minor))
|
||||
c.logger.Debug(fmt.Sprintf("Detected IIS %d.%d\n", major, minor))
|
||||
|
||||
return simpleVersion{
|
||||
major: major,
|
||||
@@ -255,6 +264,10 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
errs = append(errs, fmt.Errorf("failed to collect Web Service metrics: %w", err))
|
||||
}
|
||||
|
||||
if err := c.collectHttpServiceRequestQueues(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect Http Service Request Queues metrics: %w", err))
|
||||
}
|
||||
|
||||
if err := c.collectAppPoolWAS(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err))
|
||||
}
|
||||
|
||||
@@ -201,66 +201,77 @@ func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
|
||||
data.CurrentApplicationPoolUptime,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.currentWorkerProcesses,
|
||||
prometheus.GaugeValue,
|
||||
data.CurrentWorkerProcesses,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.maximumWorkerProcesses,
|
||||
prometheus.GaugeValue,
|
||||
data.MaximumWorkerProcesses,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.recentWorkerProcessFailures,
|
||||
prometheus.GaugeValue,
|
||||
data.RecentWorkerProcessFailures,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timeSinceLastWorkerProcessFailure,
|
||||
prometheus.GaugeValue,
|
||||
data.TimeSinceLastWorkerProcessFailure,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalApplicationPoolRecycles,
|
||||
prometheus.CounterValue,
|
||||
data.TotalApplicationPoolRecycles,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalApplicationPoolUptime,
|
||||
prometheus.CounterValue,
|
||||
data.TotalApplicationPoolUptime,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalWorkerProcessesCreated,
|
||||
prometheus.CounterValue,
|
||||
data.TotalWorkerProcessesCreated,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalWorkerProcessFailures,
|
||||
prometheus.CounterValue,
|
||||
data.TotalWorkerProcessFailures,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalWorkerProcessPingFailures,
|
||||
prometheus.CounterValue,
|
||||
data.TotalWorkerProcessPingFailures,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalWorkerProcessShutdownFailures,
|
||||
prometheus.CounterValue,
|
||||
data.TotalWorkerProcessShutdownFailures,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalWorkerProcessStartupFailures,
|
||||
prometheus.CounterValue,
|
||||
|
||||
137
internal/collector/iis/iis_http_service_request_queues.go
Normal file
137
internal/collector/iis/iis_http_service_request_queues.go
Normal file
@@ -0,0 +1,137 @@
|
||||
// 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 iis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type collectorHttpServiceRequestQueues struct {
|
||||
perfDataCollectorHttpServiceRequestQueues *pdh.Collector
|
||||
perfDataObjectHttpServiceRequestQueues []perfDataCounterValuesHttpServiceRequestQueues
|
||||
|
||||
httpRequestQueuesCurrentQueueSize *prometheus.Desc
|
||||
httpRequestQueuesTotalRejectedRequest *prometheus.Desc
|
||||
httpRequestQueuesMaxQueueItemAge *prometheus.Desc
|
||||
httpRequestQueuesArrivalRate *prometheus.Desc
|
||||
}
|
||||
|
||||
type perfDataCounterValuesHttpServiceRequestQueues struct {
|
||||
Name string
|
||||
|
||||
HttpRequestQueuesCurrentQueueSize float64 `perfdata:"CurrentQueueSize"`
|
||||
HttpRequestQueuesTotalRejectedRequests float64 `perfdata:"RejectedRequests"`
|
||||
HttpRequestQueuesMaxQueueItemAge float64 `perfdata:"MaxQueueItemAge"`
|
||||
HttpRequestQueuesArrivalRate float64 `perfdata:"ArrivalRate"`
|
||||
}
|
||||
|
||||
func (p perfDataCounterValuesHttpServiceRequestQueues) GetName() string {
|
||||
return p.Name
|
||||
}
|
||||
|
||||
func (c *Collector) buildHttpServiceRequestQueues() error {
|
||||
var err error
|
||||
|
||||
c.logger.Info("IIS/HttpServiceRequestQueues collector is in an experimental state! The configuration and metrics may change in future. Please report any issues.")
|
||||
|
||||
c.perfDataCollectorHttpServiceRequestQueues, err = pdh.NewCollector[perfDataCounterValuesHttpServiceRequestQueues](pdh.CounterTypeRaw, "HTTP Service Request Queues", pdh.InstancesAll)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create Http Service collector: %w", err)
|
||||
}
|
||||
|
||||
c.httpRequestQueuesCurrentQueueSize = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "http_requests_current_queue_size"),
|
||||
"Http Request Current Queue Size",
|
||||
[]string{"site"},
|
||||
nil,
|
||||
)
|
||||
c.httpRequestQueuesTotalRejectedRequest = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "http_request_total_rejected_request"),
|
||||
"Http Request Total Rejected Request",
|
||||
[]string{"site"},
|
||||
nil,
|
||||
)
|
||||
c.httpRequestQueuesMaxQueueItemAge = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "http_requests_max_queue_item_age"),
|
||||
"Http Request Max Queue Item Age. The values might be bogus if the queue is empty.",
|
||||
[]string{"site"},
|
||||
nil,
|
||||
)
|
||||
c.httpRequestQueuesArrivalRate = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "http_requests_arrival_rate"),
|
||||
"Http Request Arrival Rate",
|
||||
[]string{"site"},
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectHttpServiceRequestQueues(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollectorHttpServiceRequestQueues.Collect(&c.perfDataObjectHttpServiceRequestQueues)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect Http Service Request Queues metrics: %w", err)
|
||||
}
|
||||
|
||||
deduplicateIISNames(c.perfDataObjectHttpServiceRequestQueues)
|
||||
|
||||
for _, data := range c.perfDataObjectHttpServiceRequestQueues {
|
||||
if strings.HasPrefix(data.Name, "---") {
|
||||
continue
|
||||
}
|
||||
|
||||
if c.config.SiteExclude.MatchString(data.Name) || !c.config.SiteInclude.MatchString(data.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.httpRequestQueuesCurrentQueueSize,
|
||||
prometheus.GaugeValue,
|
||||
data.HttpRequestQueuesCurrentQueueSize,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.httpRequestQueuesTotalRejectedRequest,
|
||||
prometheus.GaugeValue,
|
||||
data.HttpRequestQueuesTotalRejectedRequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.httpRequestQueuesMaxQueueItemAge,
|
||||
prometheus.GaugeValue,
|
||||
data.HttpRequestQueuesMaxQueueItemAge,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.httpRequestQueuesArrivalRate,
|
||||
prometheus.GaugeValue,
|
||||
data.HttpRequestQueuesArrivalRate,
|
||||
data.Name,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -441,6 +441,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||
pid,
|
||||
"401",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPRequestErrorsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -449,6 +450,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||
pid,
|
||||
"403",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPRequestErrorsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -457,6 +459,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||
pid,
|
||||
"404",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPRequestErrorsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -465,6 +468,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||
pid,
|
||||
"500",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPWebSocketRequestsActive,
|
||||
prometheus.CounterValue,
|
||||
@@ -472,6 +476,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPWebSocketConnectionAttempts,
|
||||
prometheus.CounterValue,
|
||||
@@ -479,6 +484,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPWebSocketConnectionsAccepted,
|
||||
prometheus.CounterValue,
|
||||
@@ -486,6 +492,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPWebSocketConnectionsRejected,
|
||||
prometheus.CounterValue,
|
||||
@@ -507,10 +514,6 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
deduplicateIISNames(c.perfDataObjectW3SVCW3WP)
|
||||
|
||||
for _, data := range c.perfDataObjectW3SVCW3WP {
|
||||
if c.config.AppExclude.MatchString(data.Name) || !c.config.AppInclude.MatchString(data.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Extract the apppool name from the format <PID>_<NAME>
|
||||
pid := workerProcessNameExtractor.ReplaceAllString(data.Name, "$1")
|
||||
|
||||
@@ -533,6 +536,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
pid,
|
||||
"busy",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMaximumThreads,
|
||||
prometheus.CounterValue,
|
||||
@@ -540,6 +544,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPRequestsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -547,6 +552,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPRequestsActive,
|
||||
prometheus.CounterValue,
|
||||
@@ -554,6 +560,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPActiveFlushedEntries,
|
||||
prometheus.GaugeValue,
|
||||
@@ -561,6 +568,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPCurrentFileCacheMemoryUsage,
|
||||
prometheus.GaugeValue,
|
||||
@@ -568,6 +576,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMaximumFileCacheMemoryUsage,
|
||||
prometheus.CounterValue,
|
||||
@@ -575,6 +584,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPFileCacheFlushesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -582,6 +592,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPFileCacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -589,6 +600,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPFileCacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -596,6 +608,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPFilesCached,
|
||||
prometheus.GaugeValue,
|
||||
@@ -603,6 +616,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPFilesCachedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -610,6 +624,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPFilesFlushedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -617,6 +632,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPURICacheFlushesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -624,6 +640,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPURICacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -631,6 +648,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPURICacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -638,6 +656,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPURIsCached,
|
||||
prometheus.GaugeValue,
|
||||
@@ -645,6 +664,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPURIsCachedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -652,6 +672,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPURIsFlushedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -659,6 +680,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMetadataCached,
|
||||
prometheus.GaugeValue,
|
||||
@@ -666,6 +688,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMetadataCacheFlushes,
|
||||
prometheus.CounterValue,
|
||||
@@ -673,6 +696,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMetadataCacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -680,6 +704,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMetadataCacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -687,6 +712,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMetadataCachedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -694,6 +720,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPMetadataFlushedTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -701,6 +728,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPOutputCacheActiveFlushedItems,
|
||||
prometheus.CounterValue,
|
||||
@@ -708,6 +736,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPOutputCacheItems,
|
||||
prometheus.CounterValue,
|
||||
@@ -715,6 +744,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPOutputCacheMemoryUsage,
|
||||
prometheus.CounterValue,
|
||||
@@ -722,6 +752,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPOutputCacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -729,6 +760,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPOutputCacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -736,6 +768,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPOutputCacheFlushedItemsTotal,
|
||||
prometheus.CounterValue,
|
||||
@@ -743,6 +776,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||
name,
|
||||
pid,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.w3SVCW3WPOutputCacheFlushesTotal,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -262,126 +262,147 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.WebServiceCurrentAnonymousUsers,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceCurrentBlockedAsyncIORequests,
|
||||
prometheus.GaugeValue,
|
||||
data.WebServiceCurrentBlockedAsyncIORequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceCurrentCGIRequests,
|
||||
prometheus.GaugeValue,
|
||||
data.WebServiceCurrentCGIRequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceCurrentConnections,
|
||||
prometheus.GaugeValue,
|
||||
data.WebServiceCurrentConnections,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceCurrentISAPIExtensionRequests,
|
||||
prometheus.GaugeValue,
|
||||
data.WebServiceCurrentISAPIExtensionRequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceCurrentNonAnonymousUsers,
|
||||
prometheus.GaugeValue,
|
||||
data.WebServiceCurrentNonAnonymousUsers,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceServiceUptime,
|
||||
prometheus.GaugeValue,
|
||||
data.WebServiceServiceUptime,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalBytesReceived,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalBytesReceived,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalBytesSent,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalBytesSent,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalAnonymousUsers,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalAnonymousUsers,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalBlockedAsyncIORequests,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalBlockedAsyncIORequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalCGIRequests,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalCGIRequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalConnectionAttemptsAllInstances,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalConnectionAttemptsAllInstances,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalFilesReceived,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalFilesReceived,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalFilesSent,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalFilesSent,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalISAPIExtensionRequests,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalISAPIExtensionRequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalLockedErrors,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalLockedErrors,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalLogonAttempts,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalLogonAttempts,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalNonAnonymousUsers,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalNonAnonymousUsers,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalNotFoundErrors,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalNotFoundErrors,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRejectedAsyncIORequests,
|
||||
prometheus.CounterValue,
|
||||
data.WebServiceTotalRejectedAsyncIORequests,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -389,6 +410,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"other",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -396,6 +418,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"COPY",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -403,6 +426,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"DELETE",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -410,6 +434,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"GET",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -417,6 +442,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"HEAD",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -424,6 +450,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"LOCK",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -431,6 +458,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"MKCOL",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -438,6 +466,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"MOVE",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -445,6 +474,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"OPTIONS",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -452,6 +482,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"POST",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -459,6 +490,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"PROPFIND",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -466,6 +498,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"PROPPATCH",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -473,6 +506,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"PUT",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -480,6 +514,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"SEARCH",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
@@ -487,6 +522,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||
data.Name,
|
||||
"TRACE",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.webServiceTotalRequests,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -64,8 +64,6 @@ type collectorWebServiceCache struct {
|
||||
}
|
||||
|
||||
type perfDataCounterServiceCache struct {
|
||||
Name string
|
||||
|
||||
ServiceCacheActiveFlushedEntries float64 `perfdata:"Active Flushed Entries"`
|
||||
ServiceCacheCurrentFileCacheMemoryUsage float64 `perfdata:"Current File Cache Memory Usage"`
|
||||
ServiceCacheMaximumFileCacheMemoryUsage float64 `perfdata:"Maximum File Cache Memory Usage"`
|
||||
@@ -102,10 +100,6 @@ type perfDataCounterServiceCache struct {
|
||||
ServiceCacheOutputCacheFlushesTotal float64 `perfdata:"Output Cache Total Flushes"`
|
||||
}
|
||||
|
||||
func (p perfDataCounterServiceCache) GetName() string {
|
||||
return p.Name
|
||||
}
|
||||
|
||||
func (c *Collector) buildWebServiceCache() error {
|
||||
var err error
|
||||
|
||||
@@ -293,190 +287,217 @@ func (c *Collector) collectWebServiceCache(ch chan<- prometheus.Metric) error {
|
||||
return fmt.Errorf("failed to collect Web Service Cache metrics: %w", err)
|
||||
}
|
||||
|
||||
deduplicateIISNames(c.perfDataObjectServiceCache)
|
||||
|
||||
for _, data := range c.perfDataObjectServiceCache {
|
||||
if c.config.SiteExclude.MatchString(data.Name) || !c.config.SiteInclude.MatchString(data.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheActiveFlushedEntries,
|
||||
prometheus.GaugeValue,
|
||||
data.ServiceCacheActiveFlushedEntries,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheCurrentFileCacheMemoryUsage,
|
||||
prometheus.GaugeValue,
|
||||
data.ServiceCacheCurrentFileCacheMemoryUsage,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheMaximumFileCacheMemoryUsage,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheMaximumFileCacheMemoryUsage,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheFileCacheFlushesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheFileCacheFlushesTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheFileCacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheFileCacheHitsTotal+data.ServiceCacheFileCacheMissesTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheFileCacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheFileCacheHitsTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheFilesCached,
|
||||
prometheus.GaugeValue,
|
||||
data.ServiceCacheFilesCached,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheFilesCachedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheFilesCachedTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheFilesFlushedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheFilesFlushedTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURICacheFlushesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURICacheFlushesTotal,
|
||||
"user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURICacheFlushesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURICacheFlushesTotalKernel,
|
||||
"kernel",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURICacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURICacheHitsTotal+data.ServiceCacheURICacheMissesTotal,
|
||||
"user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURICacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURICacheHitsTotalKernel+data.ServiceCacheURICacheMissesTotalKernel,
|
||||
"kernel",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURICacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURICacheHitsTotal,
|
||||
"user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURICacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURICacheHitsTotalKernel,
|
||||
"kernel",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURIsCached,
|
||||
prometheus.GaugeValue,
|
||||
data.ServiceCacheURIsCached,
|
||||
"user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURIsCached,
|
||||
prometheus.GaugeValue,
|
||||
data.ServiceCacheURIsCachedKernel,
|
||||
"kernel",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURIsCachedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURIsCachedTotal,
|
||||
"user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURIsCachedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURIsCachedTotalKernel,
|
||||
"kernel",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURIsFlushedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURIsFlushedTotal,
|
||||
"user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheURIsFlushedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheURIsFlushedTotalKernel,
|
||||
"kernel",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheMetadataCached,
|
||||
prometheus.GaugeValue,
|
||||
data.ServiceCacheMetadataCached,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheMetadataCacheFlushes,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheMetadataCacheFlushes,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheMetadataCacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheMetaDataCacheHits+data.ServiceCacheMetaDataCacheMisses,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheMetadataCacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
0, // data.ServiceCacheMetadataCacheHitsTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheMetadataCachedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheMetadataCachedTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheMetadataFlushedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheMetadataFlushedTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheOutputCacheActiveFlushedItems,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheOutputCacheActiveFlushedItems,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheOutputCacheItems,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheOutputCacheItems,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheOutputCacheMemoryUsage,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheOutputCacheMemoryUsage,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheOutputCacheQueriesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheOutputCacheHitsTotal+data.ServiceCacheOutputCacheMissesTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheOutputCacheHitsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheOutputCacheHitsTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheOutputCacheFlushedItemsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.ServiceCacheOutputCacheFlushedItemsTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.serviceCacheOutputCacheFlushesTotal,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -18,16 +18,22 @@
|
||||
package logical_disk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/go-ole/go-ole"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/propsys"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/shell32"
|
||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||
@@ -35,15 +41,23 @@ import (
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
const Name = "logical_disk"
|
||||
const (
|
||||
Name = "logical_disk"
|
||||
subCollectorMetrics = "metrics"
|
||||
subCollectorBitlocker = "bitlocker_status"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
VolumeInclude *regexp.Regexp `yaml:"volume-include"`
|
||||
VolumeExclude *regexp.Regexp `yaml:"volume-exclude"`
|
||||
CollectorsEnabled []string `yaml:"enabled"`
|
||||
VolumeInclude *regexp.Regexp `yaml:"volume-include"`
|
||||
VolumeExclude *regexp.Regexp `yaml:"volume-exclude"`
|
||||
}
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var ConfigDefaults = Config{
|
||||
CollectorsEnabled: []string{
|
||||
subCollectorMetrics,
|
||||
},
|
||||
VolumeInclude: types.RegExpAny,
|
||||
VolumeExclude: types.RegExpEmpty,
|
||||
}
|
||||
@@ -56,6 +70,14 @@ type Collector struct {
|
||||
perfDataCollector *pdh.Collector
|
||||
perfDataObject []perfDataCounterValues
|
||||
|
||||
bitlockerReqCh chan string
|
||||
bitlockerResCh chan struct {
|
||||
err error
|
||||
status int
|
||||
}
|
||||
|
||||
ctxCancelFunc context.CancelFunc
|
||||
|
||||
avgReadQueue *prometheus.Desc
|
||||
avgWriteQueue *prometheus.Desc
|
||||
freeSpace *prometheus.Desc
|
||||
@@ -74,6 +96,8 @@ type Collector struct {
|
||||
writeLatency *prometheus.Desc
|
||||
writesTotal *prometheus.Desc
|
||||
writeTime *prometheus.Desc
|
||||
|
||||
bitlockerStatus *prometheus.Desc
|
||||
}
|
||||
|
||||
type volumeInfo struct {
|
||||
@@ -109,8 +133,9 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
c := &Collector{
|
||||
config: ConfigDefaults,
|
||||
}
|
||||
c.config.CollectorsEnabled = make([]string, 0)
|
||||
|
||||
var volumeExclude, volumeInclude string
|
||||
var collectorsEnabled, volumeExclude, volumeInclude string
|
||||
|
||||
app.Flag(
|
||||
"collector.logical_disk.volume-exclude",
|
||||
@@ -122,7 +147,17 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
"Regexp of volumes to include. Volume name must both match include and not match exclude to be included.",
|
||||
).Default(".+").StringVar(&volumeInclude)
|
||||
|
||||
app.Flag(
|
||||
"collector.logical_disk.enabled",
|
||||
fmt.Sprintf("Comma-separated list of collectors to use. Available collectors: %s, %s. Defaults to metrics, if not specified.",
|
||||
subCollectorMetrics,
|
||||
subCollectorBitlocker,
|
||||
),
|
||||
).Default(strings.Join(ConfigDefaults.CollectorsEnabled, ",")).StringVar(&collectorsEnabled)
|
||||
|
||||
app.Action(func(*kingpin.ParseContext) error {
|
||||
c.config.CollectorsEnabled = strings.Split(collectorsEnabled, ",")
|
||||
|
||||
var err error
|
||||
|
||||
c.config.VolumeExclude, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", volumeExclude))
|
||||
@@ -146,12 +181,24 @@ func (c *Collector) GetName() string {
|
||||
}
|
||||
|
||||
func (c *Collector) Close() error {
|
||||
if slices.Contains(c.config.CollectorsEnabled, subCollectorBitlocker) {
|
||||
c.ctxCancelFunc()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
c.logger = logger.With(slog.String("collector", Name))
|
||||
|
||||
for _, collector := range c.config.CollectorsEnabled {
|
||||
if !slices.Contains([]string{subCollectorMetrics, subCollectorBitlocker}, collector) {
|
||||
return fmt.Errorf("unknown sub collector: %s. Possible values: %s", collector,
|
||||
strings.Join([]string{subCollectorMetrics, subCollectorBitlocker}, ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
c.information = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||
"A metric with a constant '1' value labeled with logical disk information",
|
||||
@@ -276,6 +323,13 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
nil,
|
||||
)
|
||||
|
||||
c.bitlockerStatus = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "bitlocker_status"),
|
||||
"BitLocker status for the logical disk",
|
||||
[]string{"volume", "status"},
|
||||
nil,
|
||||
)
|
||||
|
||||
var err error
|
||||
|
||||
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "LogicalDisk", pdh.InstancesAll)
|
||||
@@ -283,6 +337,25 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
return fmt.Errorf("failed to create LogicalDisk collector: %w", err)
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, subCollectorBitlocker) {
|
||||
initErrCh := make(chan error)
|
||||
c.bitlockerReqCh = make(chan string, 1)
|
||||
c.bitlockerResCh = make(chan struct {
|
||||
err error
|
||||
status int
|
||||
}, 1)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
c.ctxCancelFunc = cancel
|
||||
|
||||
go c.workerBitlocker(ctx, initErrCh)
|
||||
|
||||
if err = <-initErrCh; err != nil {
|
||||
return fmt.Errorf("failed to initialize BitLocker worker: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -325,117 +398,156 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
info.serialNumber,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.requestsQueued,
|
||||
prometheus.GaugeValue,
|
||||
data.CurrentDiskQueueLength,
|
||||
data.Name,
|
||||
)
|
||||
if slices.Contains(c.config.CollectorsEnabled, subCollectorMetrics) {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.requestsQueued,
|
||||
prometheus.GaugeValue,
|
||||
data.CurrentDiskQueueLength,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.avgReadQueue,
|
||||
prometheus.GaugeValue,
|
||||
data.AvgDiskReadQueueLength*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.avgReadQueue,
|
||||
prometheus.GaugeValue,
|
||||
data.AvgDiskReadQueueLength*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.avgWriteQueue,
|
||||
prometheus.GaugeValue,
|
||||
data.AvgDiskWriteQueueLength*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.avgWriteQueue,
|
||||
prometheus.GaugeValue,
|
||||
data.AvgDiskWriteQueueLength*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readBytesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskReadBytesPerSec,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readBytesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskReadBytesPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskReadsPerSec,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskReadsPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeBytesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskWriteBytesPerSec,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeBytesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskWriteBytesPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskWritesPerSec,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.DiskWritesPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readTime,
|
||||
prometheus.CounterValue,
|
||||
data.PercentDiskReadTime,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readTime,
|
||||
prometheus.CounterValue,
|
||||
data.PercentDiskReadTime,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeTime,
|
||||
prometheus.CounterValue,
|
||||
data.PercentDiskWriteTime,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeTime,
|
||||
prometheus.CounterValue,
|
||||
data.PercentDiskWriteTime,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.freeSpace,
|
||||
prometheus.GaugeValue,
|
||||
data.FreeSpace*1024*1024,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.freeSpace,
|
||||
prometheus.GaugeValue,
|
||||
data.FreeSpace*1024*1024,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalSpace,
|
||||
prometheus.GaugeValue,
|
||||
data.PercentFreeSpace*1024*1024,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalSpace,
|
||||
prometheus.GaugeValue,
|
||||
data.PercentFreeSpace*1024*1024,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.idleTime,
|
||||
prometheus.CounterValue,
|
||||
data.PercentIdleTime,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.idleTime,
|
||||
prometheus.CounterValue,
|
||||
data.PercentIdleTime,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.splitIOs,
|
||||
prometheus.CounterValue,
|
||||
data.SplitIOPerSec,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.splitIOs,
|
||||
prometheus.CounterValue,
|
||||
data.SplitIOPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readLatency,
|
||||
prometheus.CounterValue,
|
||||
data.AvgDiskSecPerRead*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readLatency,
|
||||
prometheus.CounterValue,
|
||||
data.AvgDiskSecPerRead*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeLatency,
|
||||
prometheus.CounterValue,
|
||||
data.AvgDiskSecPerWrite*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.writeLatency,
|
||||
prometheus.CounterValue,
|
||||
data.AvgDiskSecPerWrite*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readWriteLatency,
|
||||
prometheus.CounterValue,
|
||||
data.AvgDiskSecPerTransfer*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.readWriteLatency,
|
||||
prometheus.CounterValue,
|
||||
data.AvgDiskSecPerTransfer*pdh.TicksToSecondScaleFactor,
|
||||
data.Name,
|
||||
)
|
||||
}
|
||||
|
||||
if slices.Contains(c.config.CollectorsEnabled, subCollectorBitlocker) {
|
||||
c.bitlockerReqCh <- data.Name
|
||||
|
||||
bitlockerStatus := <-c.bitlockerResCh
|
||||
|
||||
if bitlockerStatus.err != nil {
|
||||
c.logger.Warn("failed to get BitLocker status for "+data.Name,
|
||||
slog.Any("err", bitlockerStatus.err),
|
||||
)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if bitlockerStatus.status == -1 {
|
||||
c.logger.Debug("BitLocker status for "+data.Name+" is unknown",
|
||||
slog.Int("status", bitlockerStatus.status),
|
||||
)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
for i, status := range []string{"disabled", "on", "off", "encrypting", "decrypting", "suspended", "locked", "unknown", "waiting_for_activation"} {
|
||||
val := 0.0
|
||||
if bitlockerStatus.status == i {
|
||||
val = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bitlockerStatus,
|
||||
prometheus.GaugeValue,
|
||||
val,
|
||||
data.Name,
|
||||
status,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -590,6 +702,11 @@ func getAllMountedVolumes() (map[string]string, error) {
|
||||
break
|
||||
}
|
||||
|
||||
if errors.Is(err, windows.ERROR_FILE_NOT_FOUND) {
|
||||
// the volume is not mounted
|
||||
break
|
||||
}
|
||||
|
||||
if errors.Is(err, windows.ERROR_NO_MORE_FILES) {
|
||||
rootPathBuf = make([]uint16, (rootPathLen+1)/2)
|
||||
|
||||
@@ -609,3 +726,133 @@ func getAllMountedVolumes() (map[string]string, error) {
|
||||
volumes[strings.TrimSuffix(mountPoint, `\`)] = strings.TrimSuffix(windows.UTF16ToString(guidBuf), `\`)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
++ References
|
||||
|
||||
| System.Volume. | Control Panel | manage-bde conversion | manage-bde | Get-BitlockerVolume | Get-BitlockerVolume |
|
||||
| BitLockerProtection | | | protection | VolumeStatus | ProtectionStatus |
|
||||
| ------------------- | -------------------------------- | ------------------------- | -------------- | ---------------------------- | ------------------- |
|
||||
| 1 | BitLocker on | Used Space Only Encrypted | Protection On | FullyEncrypted | On |
|
||||
| 1 | BitLocker on | Fully Encrypted | Protection On | FullyEncrypted | On |
|
||||
| 1 | BitLocker on | Fully Encrypted | Protection On | FullyEncryptedWipeInProgress | On |
|
||||
| 2 | BitLocker off | Fully Decrypted | Protection Off | FullyDecrypted | Off |
|
||||
| 3 | BitLocker Encrypting | Encryption In Progress | Protection Off | EncryptionInProgress | Off |
|
||||
| 3 | BitLocker Encryption Paused | Encryption Paused | Protection Off | EncryptionSuspended | Off |
|
||||
| 4 | BitLocker Decrypting | Decryption in progress | Protection Off | DecyptionInProgress | Off |
|
||||
| 4 | BitLocker Decryption Paused | Decryption Paused | Protection Off | DecryptionSuspended | Off |
|
||||
| 5 | BitLocker suspended | Used Space Only Encrypted | Protection Off | FullyEncrypted | Off |
|
||||
| 5 | BitLocker suspended | Fully Encrypted | Protection Off | FullyEncrypted | Off |
|
||||
| 6 | BitLocker on (Locked) | Unknown | Unknown | $null | Unknown |
|
||||
| 7 | | | | | |
|
||||
| 8 | BitLocker waiting for activation | Used Space Only Encrypted | Protection Off | FullyEncrypted | Off |
|
||||
|
||||
--
|
||||
*/
|
||||
func (c *Collector) workerBitlocker(ctx context.Context, initErrCh chan<- error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
c.logger.Error("workerBitlocker panic",
|
||||
slog.Any("panic", r),
|
||||
slog.String("stack", string(debug.Stack())),
|
||||
)
|
||||
|
||||
// Restart the workerBitlocker
|
||||
initErrCh := make(chan error)
|
||||
|
||||
go c.workerBitlocker(ctx, initErrCh)
|
||||
|
||||
if err := <-initErrCh; err != nil {
|
||||
c.logger.Error("workerBitlocker restart failed",
|
||||
slog.Any("err", err),
|
||||
)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// The only way to run WMI queries in parallel while being thread-safe is to
|
||||
// ensure the CoInitialize[Ex]() call is bound to its current OS thread.
|
||||
// Otherwise, attempting to initialize and run parallel queries across
|
||||
// goroutines will result in protected memory errors.
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
if err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_DISABLE_OLE1DDE); err != nil {
|
||||
var oleCode *ole.OleError
|
||||
if errors.As(err, &oleCode) && oleCode.Code() != ole.S_OK && oleCode.Code() != 0x00000001 {
|
||||
initErrCh <- fmt.Errorf("CoInitializeEx: %w", err)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
defer ole.CoUninitialize()
|
||||
|
||||
var pkey propsys.PROPERTYKEY
|
||||
|
||||
// The ideal solution to check the disk encryption (BitLocker) status is to
|
||||
// use the WMI APIs (Win32_EncryptableVolume). However, only programs running
|
||||
// with elevated priledges can access those APIs.
|
||||
//
|
||||
// Our alternative solution is based on the value of the undocumented (shell)
|
||||
// property: "System.Volume.BitLockerProtection". That property is essentially
|
||||
// an enum containing the current BitLocker status for a given volume. This
|
||||
// approached was suggested here:
|
||||
// https://stackoverflow.com/questions/41308245/detect-bitlocker-programmatically-from-c-sharp-without-admin/41310139
|
||||
//
|
||||
// Note that the link above doesn't give any explanation / meaning for the
|
||||
// enum values, it simply says that 1, 3 or 5 means the disk is encrypted.
|
||||
//
|
||||
// I directly tested and validated this strategy on a Windows 10 machine.
|
||||
// The values given in the BitLockerStatus enum contain the relevant values
|
||||
// for the shell property. I also directly validated them.
|
||||
if err := propsys.PSGetPropertyKeyFromName("System.Volume.BitLockerProtection", &pkey); err != nil {
|
||||
initErrCh <- fmt.Errorf("PSGetPropertyKeyFromName failed: %w", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
close(initErrCh)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case path, ok := <-c.bitlockerReqCh:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.Contains(path, `:`) {
|
||||
c.bitlockerResCh <- struct {
|
||||
err error
|
||||
status int
|
||||
}{err: nil, status: -1}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
status, err := func(path string) (int, error) {
|
||||
item, err := shell32.SHCreateItemFromParsingName(path)
|
||||
if err != nil {
|
||||
return -1, fmt.Errorf("SHCreateItemFromParsingName failed: %w", err)
|
||||
}
|
||||
|
||||
defer item.Release()
|
||||
|
||||
var v ole.VARIANT
|
||||
|
||||
if err := item.GetProperty(&pkey, &v); err != nil {
|
||||
return -1, fmt.Errorf("GetProperty failed: %w", err)
|
||||
}
|
||||
|
||||
return int(v.Val), v.Clear()
|
||||
}(path)
|
||||
|
||||
c.bitlockerResCh <- struct {
|
||||
err error
|
||||
status int
|
||||
}{err: err, status: status}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +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 logon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/secur32"
|
||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const Name = "logon"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI metrics.
|
||||
// Deprecated: Use windows_terminal_services_session_info instead.
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
sessionInfo *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 logon collector will be removed mid 2025. Use terminal_service instead."+
|
||||
" See https://github.com/prometheus-community/windows_exporter/pull/1957 for more information. If you see values in this collector"+
|
||||
" that you need, please open an issue to discuss how to get them into the new collector.",
|
||||
slog.String("collector", Name),
|
||||
)
|
||||
|
||||
c.sessionInfo = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "session_logon_timestamp_seconds"),
|
||||
"Deprecated. Use windows_terminal_services_session_info instead.",
|
||||
[]string{"id", "username", "domain", "type"},
|
||||
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 {
|
||||
logonSessions, err := secur32.GetLogonSessions()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get logon sessions: %w", err)
|
||||
}
|
||||
|
||||
for _, session := range logonSessions {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.sessionInfo,
|
||||
prometheus.GaugeValue,
|
||||
float64(session.LogonTime.Unix()),
|
||||
session.LogonId.String(), session.UserName, session.LogonDomain, session.LogonType.String(),
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,34 +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 logon_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/collector/logon"
|
||||
"github.com/prometheus-community/windows_exporter/internal/utils/testutils"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
// No context name required as Collector source is WMI
|
||||
testutils.FuncBenchmarkCollector(b, logon.Name, logon.NewWithFlags)
|
||||
}
|
||||
|
||||
func TestCollector(t *testing.T) {
|
||||
testutils.TestCollector(t, logon.New, nil)
|
||||
}
|
||||
@@ -57,14 +57,14 @@ var ConfigDefaults = Config{
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI MSCluster_Cluster metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
miSession *mi.Session
|
||||
|
||||
collectorCluster
|
||||
collectorNetwork
|
||||
collectorNode
|
||||
collectorResource
|
||||
collectorResourceGroup
|
||||
|
||||
config Config
|
||||
miSession *mi.Session
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
|
||||
@@ -265,6 +265,7 @@ func (c *Collector) collectResource(ch chan<- prometheus.Metric, nodeNames []str
|
||||
if v.OwnerNode == nodeName {
|
||||
isCurrentState = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.resourceOwnerNode,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -260,6 +260,7 @@ func (c *Collector) collectResourceGroup(ch chan<- prometheus.Metric, nodeNames
|
||||
if v.OwnerNode == nodeName {
|
||||
isCurrentState = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.resourceGroupOwnerNode,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -78,18 +78,6 @@ var ConfigDefaults = Config{
|
||||
|
||||
// A Collector is a Prometheus Collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics.
|
||||
type Collector struct {
|
||||
config Config
|
||||
|
||||
logger *slog.Logger
|
||||
|
||||
mssqlInstances []mssqlInstance
|
||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||
closeFns []func()
|
||||
|
||||
// meta
|
||||
mssqlScrapeDurationDesc *prometheus.Desc
|
||||
mssqlScrapeSuccessDesc *prometheus.Desc
|
||||
|
||||
collectorAccessMethods
|
||||
collectorAvailabilityReplica
|
||||
collectorBufferManager
|
||||
@@ -103,6 +91,18 @@ type Collector struct {
|
||||
collectorSQLStats
|
||||
collectorTransactions
|
||||
collectorWaitStats
|
||||
|
||||
config Config
|
||||
|
||||
logger *slog.Logger
|
||||
|
||||
mssqlInstances []mssqlInstance
|
||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||
closeFns []func()
|
||||
|
||||
// meta
|
||||
mssqlScrapeDurationDesc *prometheus.Desc
|
||||
mssqlScrapeSuccessDesc *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
@@ -405,6 +405,7 @@ func (c *Collector) collect(
|
||||
duration.Seconds(),
|
||||
collector, sqlInstance.name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.mssqlScrapeSuccessDesc,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -120,7 +120,7 @@ type perfDataCounterValuesAccessMethods struct {
|
||||
AccessMethodsWorkfilesCreatedPerSec float64 `perfdata:"Workfiles Created/sec"`
|
||||
AccessMethodsWorktablesCreatedPerSec float64 `perfdata:"Worktables Created/sec"`
|
||||
AccessMethodsWorktablesFromCacheRatio float64 `perfdata:"Worktables From Cache Ratio"`
|
||||
AccessMethodsWorktablesFromCacheRatioBase float64 `perfdata:"Worktables From Cache Base,secondvalue"`
|
||||
AccessMethodsWorktablesFromCacheRatioBase float64 `perfdata:"Worktables From Cache Ratio,secondvalue"`
|
||||
}
|
||||
|
||||
func (c *Collector) buildAccessMethods() error {
|
||||
|
||||
@@ -58,7 +58,7 @@ type collectorBufferManager struct {
|
||||
type perfDataCounterValuesBufMan struct {
|
||||
BufManBackgroundWriterPagesPerSec float64 `perfdata:"Background writer pages/sec"`
|
||||
BufManBufferCacheHitRatio float64 `perfdata:"Buffer cache hit ratio"`
|
||||
BufManBufferCacheHitRatioBase float64 `perfdata:"Buffer cache hit ratio base,secondvalue"`
|
||||
BufManBufferCacheHitRatioBase float64 `perfdata:"Buffer cache hit ratio,secondvalue"`
|
||||
BufManCheckpointPagesPerSec float64 `perfdata:"Checkpoint pages/sec"`
|
||||
BufManDatabasePages float64 `perfdata:"Database pages"`
|
||||
BufManExtensionAllocatedPages float64 `perfdata:"Extension allocated pages"`
|
||||
|
||||
@@ -95,7 +95,7 @@ type perfDataCounterValuesDatabases struct {
|
||||
DatabasesGroupCommitTimePerSec float64 `perfdata:"Group Commit Time/sec"`
|
||||
DatabasesLogBytesFlushedPerSec float64 `perfdata:"Log Bytes Flushed/sec"`
|
||||
DatabasesLogCacheHitRatio float64 `perfdata:"Log Cache Hit Ratio"`
|
||||
DatabasesLogCacheHitRatioBase float64 `perfdata:"Log Cache Hit Ratio Base,secondvalue"`
|
||||
DatabasesLogCacheHitRatioBase float64 `perfdata:"Log Cache Hit Ratio,secondvalue"`
|
||||
DatabasesLogCacheReadsPerSec float64 `perfdata:"Log Cache Reads/sec"`
|
||||
DatabasesLogFilesSizeKB float64 `perfdata:"Log File(s) Size (KB)"`
|
||||
DatabasesLogFilesUsedSizeKB float64 `perfdata:"Log File(s) Used Size (KB)"`
|
||||
|
||||
@@ -45,7 +45,7 @@ type perfDataCounterValuesLocks struct {
|
||||
Name string
|
||||
|
||||
LocksAverageWaitTimeMS float64 `perfdata:"Average Wait Time (ms)"`
|
||||
LocksAverageWaitTimeMSBase float64 `perfdata:"Average Wait Time Base,secondvalue"`
|
||||
LocksAverageWaitTimeMSBase float64 `perfdata:"Average Wait Time (ms),secondvalue"`
|
||||
LocksLockRequestsPerSec float64 `perfdata:"Lock Requests/sec"`
|
||||
LocksLockTimeoutsPerSec float64 `perfdata:"Lock Timeouts/sec"`
|
||||
LocksLockTimeoutsTimeout0PerSec float64 `perfdata:"Lock Timeouts (timeout > 0)/sec"`
|
||||
|
||||
@@ -44,7 +44,7 @@ func newMssqlInstance(key, name string) (mssqlInstance, error) {
|
||||
_ = key.Close()
|
||||
}(k)
|
||||
|
||||
patchVersion, _, err := k.GetStringValue("Version")
|
||||
patchVersion, _, err := k.GetStringValue("PatchLevel")
|
||||
if err != nil {
|
||||
return mssqlInstance{}, fmt.Errorf("couldn't get version from registry: %w", err)
|
||||
}
|
||||
|
||||
@@ -331,72 +331,84 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
data.BytesReceivedPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bytesSentTotal,
|
||||
prometheus.CounterValue,
|
||||
data.BytesSentPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bytesTotal,
|
||||
prometheus.CounterValue,
|
||||
data.BytesTotalPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.outputQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
data.OutputQueueLength,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsOutboundDiscarded,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsOutboundDiscarded,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsOutboundErrors,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsOutboundErrors,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsTotal,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsReceivedDiscarded,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsReceivedDiscarded,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsReceivedErrors,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsReceivedErrors,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsReceivedTotal,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsReceivedPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsReceivedUnknown,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsReceivedUnknown,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.packetsSentTotal,
|
||||
prometheus.CounterValue,
|
||||
data.PacketsSentPerSec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.currentBandwidth,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -23,17 +23,13 @@ import (
|
||||
"log/slog"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/kernel32"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/netapi32"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/sysinfoapi"
|
||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||
"github.com/prometheus-community/windows_exporter/internal/osversion"
|
||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
@@ -50,38 +46,6 @@ type Collector struct {
|
||||
|
||||
hostname *prometheus.Desc
|
||||
osInformation *prometheus.Desc
|
||||
|
||||
// users
|
||||
// Deprecated: Use windows_system_process_limit instead.
|
||||
processesLimit *prometheus.Desc
|
||||
|
||||
// users
|
||||
// Deprecated: Use `sum(windows_terminal_services_session_info{state="active"})` instead.
|
||||
users *prometheus.Desc
|
||||
|
||||
// physicalMemoryFreeBytes
|
||||
// Deprecated: Use windows_memory_physical_free_bytes instead.
|
||||
physicalMemoryFreeBytes *prometheus.Desc
|
||||
|
||||
// processMemoryLimitBytes
|
||||
// Deprecated: Use windows_memory_process_memory_limit_bytes instead.
|
||||
processMemoryLimitBytes *prometheus.Desc
|
||||
|
||||
// time
|
||||
// Deprecated: Use windows_time_current_timestamp_seconds instead.
|
||||
time *prometheus.Desc
|
||||
// timezone
|
||||
// Deprecated: Use windows_time_timezone instead.
|
||||
timezone *prometheus.Desc
|
||||
// virtualMemoryBytes
|
||||
// Deprecated: Use windows_memory_commit_limit instead.
|
||||
virtualMemoryBytes *prometheus.Desc
|
||||
// virtualMemoryFreeBytes
|
||||
// Deprecated: Use windows_memory_commit_limit instead.
|
||||
virtualMemoryFreeBytes *prometheus.Desc
|
||||
// visibleMemoryBytes
|
||||
// Deprecated: Use windows_memory_physical_total_bytes instead.
|
||||
visibleMemoryBytes *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
@@ -108,12 +72,7 @@ func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
logger.Warn("The os collector holds a number of deprecated metrics and will be removed mid 2025. "+
|
||||
"See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information.",
|
||||
slog.String("collector", Name),
|
||||
)
|
||||
|
||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||
productName, revision, err := c.getWindowsVersion()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Windows version: %w", err)
|
||||
@@ -150,61 +109,6 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
},
|
||||
nil,
|
||||
)
|
||||
c.physicalMemoryFreeBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "physical_memory_free_bytes"),
|
||||
"Deprecated: Use `windows_memory_physical_free_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.time = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "time"),
|
||||
"Deprecated: Use windows_time_current_timestamp_seconds instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.timezone = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "timezone"),
|
||||
"Deprecated: Use windows_time_timezone instead.",
|
||||
[]string{"timezone"},
|
||||
nil,
|
||||
)
|
||||
|
||||
c.processesLimit = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "processes_limit"),
|
||||
"Deprecated: Use `windows_system_process_limit` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.processMemoryLimitBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_limit_bytes"),
|
||||
"Deprecated: Use `windows_memory_process_memory_limit_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.users = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "users"),
|
||||
"Deprecated: Use `sum(windows_terminal_services_session_info{state=\"active\"})` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.virtualMemoryBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "virtual_memory_bytes"),
|
||||
"Deprecated: Use `windows_memory_commit_limit` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.visibleMemoryBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "visible_memory_bytes"),
|
||||
"Deprecated: Use `windows_memory_physical_total_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.virtualMemoryFreeBytes = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "virtual_memory_free_bytes"),
|
||||
"Deprecated: Use `windows_memory_commit_limit - windows_memory_committed_bytes` instead.",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -214,42 +118,19 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
errs := make([]error, 0)
|
||||
|
||||
c.collect(ch)
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.osInformation,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
)
|
||||
|
||||
if err := c.collectHostname(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect hostname metrics: %w", err))
|
||||
}
|
||||
|
||||
if err := c.collectLoggedInUserCount(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect user count metrics: %w", err))
|
||||
}
|
||||
|
||||
if err := c.collectMemory(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect memory metrics: %w", err))
|
||||
}
|
||||
|
||||
if err := c.collectTime(ch); err != nil {
|
||||
errs = append(errs, fmt.Errorf("failed to collect time metrics: %w", err))
|
||||
}
|
||||
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
func (c *Collector) collectLoggedInUserCount(ch chan<- prometheus.Metric) error {
|
||||
workstationInfo, err := netapi32.GetWorkstationInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.users,
|
||||
prometheus.GaugeValue,
|
||||
float64(workstationInfo.LoggedOnUsers),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectHostname(ch chan<- prometheus.Metric) error {
|
||||
hostname, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSHostname)
|
||||
if err != nil {
|
||||
@@ -278,87 +159,6 @@ func (c *Collector) collectHostname(ch chan<- prometheus.Metric) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectTime(ch chan<- prometheus.Metric) error {
|
||||
timeZoneInfo, err := kernel32.GetDynamicTimeZoneInformation()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// timeZoneKeyName contains the english name of the timezone.
|
||||
timezoneName := windows.UTF16ToString(timeZoneInfo.TimeZoneKeyName[:])
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.time,
|
||||
prometheus.GaugeValue,
|
||||
float64(time.Now().Unix()),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.timezone,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
timezoneName,
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collectMemory(ch chan<- prometheus.Metric) error {
|
||||
memoryStatusEx, err := sysinfoapi.GlobalMemoryStatusEx()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.physicalMemoryFreeBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.AvailPhys),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualMemoryFreeBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.AvailPageFile),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualMemoryBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalPageFile),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.visibleMemoryBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalPhys),
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processMemoryLimitBytes,
|
||||
prometheus.GaugeValue,
|
||||
float64(memoryStatusEx.TotalVirtual),
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) collect(ch chan<- prometheus.Metric) {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.osInformation,
|
||||
prometheus.GaugeValue,
|
||||
1.0,
|
||||
)
|
||||
|
||||
// Windows has no defined limit, and is based off available resources. This currently isn't calculated by WMI and is set to default value.
|
||||
// https://techcommunity.microsoft.com/t5/windows-blog-archive/pushing-the-limits-of-windows-processes-and-threads/ba-p/723824
|
||||
// https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-operatingsystem
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processesLimit,
|
||||
prometheus.GaugeValue,
|
||||
float64(4294967295),
|
||||
)
|
||||
}
|
||||
|
||||
func (c *Collector) getWindowsVersion() (string, string, error) {
|
||||
// Get build number and product name from registry
|
||||
ntKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
||||
|
||||
@@ -81,8 +81,6 @@ type Collector struct {
|
||||
poolBytes *prometheus.Desc
|
||||
priorityBase *prometheus.Desc
|
||||
privateBytes *prometheus.Desc
|
||||
// Deprecated: Use start_time_seconds_timestamp instead
|
||||
startTimeOld *prometheus.Desc
|
||||
startTime *prometheus.Desc
|
||||
threadCount *prometheus.Desc
|
||||
virtualBytes *prometheus.Desc
|
||||
@@ -180,20 +178,6 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
||||
|
||||
var err error
|
||||
|
||||
if c.config.EnableWorkerProcess {
|
||||
if miSession == nil {
|
||||
return errors.New("miSession is nil")
|
||||
}
|
||||
|
||||
miQuery, err := mi.NewQuery("SELECT AppPoolName, ProcessId FROM WorkerProcess")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create WMI query: %w", err)
|
||||
}
|
||||
|
||||
c.workerProcessMIQueryQuery = miQuery
|
||||
c.miSession = miSession
|
||||
}
|
||||
|
||||
switch c.config.CounterVersion {
|
||||
case 2:
|
||||
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Process V2", pdh.InstancesAll)
|
||||
@@ -235,13 +219,6 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
||||
nil,
|
||||
)
|
||||
|
||||
c.startTimeOld = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "start_time"),
|
||||
"DEPRECATED: Use start_time_seconds_timestamp instead",
|
||||
[]string{"process", "process_id"},
|
||||
nil,
|
||||
)
|
||||
|
||||
c.startTime = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "start_time_seconds_timestamp"),
|
||||
"Time of process start.",
|
||||
@@ -333,6 +310,28 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
||||
nil,
|
||||
)
|
||||
|
||||
if c.config.EnableWorkerProcess {
|
||||
if miSession == nil {
|
||||
return errors.New("miSession is nil")
|
||||
}
|
||||
|
||||
miQuery, err := mi.NewQuery("SELECT AppPoolName, ProcessId FROM WorkerProcess")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create WMI query: %w", err)
|
||||
}
|
||||
|
||||
c.workerProcessMIQueryQuery = miQuery
|
||||
c.miSession = miSession
|
||||
|
||||
var workerProcesses []WorkerProcess
|
||||
|
||||
if err = c.miSession.Query(&workerProcesses, mi.NamespaceRootWebAdministration, c.workerProcessMIQueryQuery); err != nil {
|
||||
c.config.EnableWorkerProcess = false
|
||||
|
||||
return fmt.Errorf("WMI query for collector.process.iis failed: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -45,10 +45,12 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
return fmt.Errorf("failed to collect metrics: %w", err)
|
||||
}
|
||||
|
||||
err = nil
|
||||
|
||||
var workerProcesses []WorkerProcess
|
||||
if c.config.EnableWorkerProcess {
|
||||
if err := c.miSession.Query(&workerProcesses, mi.NamespaceRootWebAdministration, c.workerProcessMIQueryQuery); err != nil {
|
||||
return fmt.Errorf("WMI query failed: %w", err)
|
||||
if err = c.miSession.Query(&workerProcesses, mi.NamespaceRootWebAdministration, c.workerProcessMIQueryQuery); err != nil {
|
||||
err = fmt.Errorf("WMI query for collector.process.iis failed: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +90,7 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
||||
|
||||
wg.Wait()
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Collector) collectWorker() {
|
||||
@@ -142,14 +144,7 @@ func (c *Collector) collectWorker() {
|
||||
name, pidString, parentPID, strconv.Itoa(int(processGroupID)), processOwner, cmdLine,
|
||||
)
|
||||
|
||||
startTime := float64(time.Now().Unix() - int64(data.ElapsedTime))
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.startTimeOld,
|
||||
prometheus.GaugeValue,
|
||||
startTime,
|
||||
name, pidString,
|
||||
)
|
||||
startTime := float64(time.Now().UnixMicro())/1e6 - data.ElapsedTime
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.startTime,
|
||||
|
||||
@@ -280,60 +280,70 @@ func (c *Collector) collectRemoteFXNetworkCount(ch chan<- prometheus.Metric) err
|
||||
utils.MilliSecToSec(data.BaseTCPRTT),
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.baseUDPRTT,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.BaseUDPRTT),
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.currentTCPBandwidth,
|
||||
prometheus.GaugeValue,
|
||||
(data.CurrentTCPBandwidth*1000)/8,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.currentTCPRTT,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.CurrentTCPRTT),
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.currentUDPBandwidth,
|
||||
prometheus.GaugeValue,
|
||||
(data.CurrentUDPBandwidth*1000)/8,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.currentUDPRTT,
|
||||
prometheus.GaugeValue,
|
||||
utils.MilliSecToSec(data.CurrentUDPRTT),
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalReceivedBytes,
|
||||
prometheus.CounterValue,
|
||||
data.TotalReceivedBytes,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.totalSentBytes,
|
||||
prometheus.CounterValue,
|
||||
data.TotalSentBytes,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.udpPacketsReceivedPerSec,
|
||||
prometheus.CounterValue,
|
||||
data.UDPPacketsReceivedPersec,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.udpPacketsSentPerSec,
|
||||
prometheus.CounterValue,
|
||||
data.UDPPacketsSentPersec,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.fecRate,
|
||||
prometheus.GaugeValue,
|
||||
@@ -378,12 +388,14 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
||||
utils.MilliSecToSec(data.AverageEncodingTime),
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.frameQuality,
|
||||
prometheus.GaugeValue,
|
||||
data.FrameQuality,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.framesSkippedPerSecondInsufficientResources,
|
||||
prometheus.CounterValue,
|
||||
@@ -391,6 +403,7 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
||||
sessionName,
|
||||
"client",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.framesSkippedPerSecondInsufficientResources,
|
||||
prometheus.CounterValue,
|
||||
@@ -398,6 +411,7 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
||||
sessionName,
|
||||
"network",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.framesSkippedPerSecondInsufficientResources,
|
||||
prometheus.CounterValue,
|
||||
@@ -405,24 +419,28 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
||||
sessionName,
|
||||
"server",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.graphicsCompressionRatio,
|
||||
prometheus.GaugeValue,
|
||||
data.GraphicsCompressionratio,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.inputFramesPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.InputFramesPerSecond,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.outputFramesPerSecond,
|
||||
prometheus.CounterValue,
|
||||
data.OutputFramesPerSecond,
|
||||
sessionName,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.sourceFramesPerSecond,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -143,7 +143,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
},
|
||||
}
|
||||
|
||||
c.queryAllServicesBuffer = make([]byte, 1024*100)
|
||||
c.queryAllServicesBuffer = make([]byte, 1024*200)
|
||||
|
||||
c.info = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||
@@ -242,6 +242,15 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
}
|
||||
|
||||
func (c *Collector) collectWorker(ch chan<- prometheus.Metric, service windows.ENUM_SERVICE_STATUS_PROCESS) {
|
||||
if uintptr(unsafe.Pointer(service.ServiceName)) == uintptr(windows.InvalidHandle) {
|
||||
c.logger.Log(context.Background(), slog.LevelWarn, "failed collecting service info",
|
||||
slog.String("err", "ServiceName is 0xffffffffffffffff"),
|
||||
slog.String("service", fmt.Sprintf("%+v", service)),
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
serviceName := windows.UTF16PtrToString(service.ServiceName)
|
||||
|
||||
if c.config.ServiceExclude.MatchString(serviceName) || !c.config.ServiceInclude.MatchString(serviceName) {
|
||||
@@ -307,6 +316,7 @@ func (c *Collector) collectService(ch chan<- prometheus.Metric, serviceName stri
|
||||
if startMode == c.apiStartModeValues[serviceConfig.StartType] {
|
||||
isCurrentStartMode = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.startMode,
|
||||
prometheus.GaugeValue,
|
||||
@@ -375,6 +385,8 @@ func (c *Collector) queryAllServices() ([]windows.ENUM_SERVICE_STATUS_PROCESS, e
|
||||
err error
|
||||
)
|
||||
|
||||
clear(c.queryAllServicesBuffer)
|
||||
|
||||
for {
|
||||
currentBufferSize := uint32(cap(c.queryAllServicesBuffer))
|
||||
|
||||
@@ -390,7 +402,6 @@ func (c *Collector) queryAllServices() ([]windows.ENUM_SERVICE_STATUS_PROCESS, e
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
@@ -432,7 +443,6 @@ func (c *Collector) getProcessStartTime(pid uint32) (uint64, error) {
|
||||
)
|
||||
|
||||
err = windows.GetProcessTimes(handle, &creation, &exit, &krn, &user)
|
||||
|
||||
if err := windows.CloseHandle(handle); err != nil {
|
||||
c.logger.LogAttrs(context.Background(), slog.LevelWarn, "failed to close process handle",
|
||||
slog.Any("err", err),
|
||||
|
||||
@@ -52,10 +52,8 @@ type Collector struct {
|
||||
processes *prometheus.Desc
|
||||
processesLimit *prometheus.Desc
|
||||
systemCallsTotal *prometheus.Desc
|
||||
// Deprecated: Use windows_system_boot_time_timestamp instead
|
||||
bootTimeSeconds *prometheus.Desc
|
||||
bootTime *prometheus.Desc
|
||||
threads *prometheus.Desc
|
||||
bootTime *prometheus.Desc
|
||||
threads *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
@@ -91,12 +89,6 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.bootTimeSeconds = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "boot_time_timestamp_seconds"),
|
||||
"Deprecated: Use windows_system_boot_time_timestamp instead",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.contextSwitchesTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "context_switches_total"),
|
||||
"Total number of context switches (WMI source: PerfOS_System.ContextSwitchesPersec)",
|
||||
@@ -141,7 +133,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||
nil,
|
||||
)
|
||||
|
||||
c.bootTimeTimestamp = float64(time.Now().Unix() - int64(kernel32.GetTickCount64()/1000))
|
||||
c.bootTimeTimestamp = float64(uint64(time.Now().UnixMilli())-kernel32.GetTickCount64()) / 1000
|
||||
|
||||
var err error
|
||||
|
||||
@@ -159,6 +151,8 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect System metrics: %w", err)
|
||||
} else if len(c.perfDataObject) == 0 {
|
||||
return fmt.Errorf("failed to collect System metrics: %w", types.ErrNoDataUnexpected)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -166,38 +160,37 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].ContextSwitchesPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.exceptionDispatchesTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].ExceptionDispatchesPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processorQueueLength,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].ProcessorQueueLength,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.processes,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].Processes,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.systemCallsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].SystemCallsPerSec,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.threads,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].Threads,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bootTimeSeconds,
|
||||
prometheus.GaugeValue,
|
||||
c.bootTimeTimestamp,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bootTime,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -259,48 +259,56 @@ func (c *Collector) writeTCPCounters(ch chan<- prometheus.Metric, metrics []perf
|
||||
metrics[0].ConnectionFailures,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.connectionsActive,
|
||||
prometheus.CounterValue,
|
||||
metrics[0].ConnectionsActive,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.connectionsEstablished,
|
||||
prometheus.GaugeValue,
|
||||
metrics[0].ConnectionsEstablished,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.connectionsPassive,
|
||||
prometheus.CounterValue,
|
||||
metrics[0].ConnectionsPassive,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.connectionsReset,
|
||||
prometheus.CounterValue,
|
||||
metrics[0].ConnectionsReset,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.segmentsTotal,
|
||||
prometheus.CounterValue,
|
||||
metrics[0].SegmentsPerSec,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.segmentsReceivedTotal,
|
||||
prometheus.CounterValue,
|
||||
metrics[0].SegmentsReceivedPerSec,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.segmentsRetransmittedTotal,
|
||||
prometheus.CounterValue,
|
||||
metrics[0].SegmentsRetransmittedPerSec,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.segmentsSentTotal,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -308,24 +308,28 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
||||
data.HandleCount,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.pageFaultsPerSec,
|
||||
prometheus.CounterValue,
|
||||
data.PageFaultsPersec,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.pageFileBytes,
|
||||
prometheus.GaugeValue,
|
||||
data.PageFileBytes,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.pageFileBytesPeak,
|
||||
prometheus.GaugeValue,
|
||||
data.PageFileBytesPeak,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.percentCPUTime,
|
||||
prometheus.CounterValue,
|
||||
@@ -333,6 +337,7 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
||||
data.Name,
|
||||
"privileged",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.percentCPUTime,
|
||||
prometheus.CounterValue,
|
||||
@@ -340,6 +345,7 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
||||
data.Name,
|
||||
"processor",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.percentCPUTime,
|
||||
prometheus.CounterValue,
|
||||
@@ -347,48 +353,56 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
||||
data.Name,
|
||||
"user",
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.poolNonPagedBytes,
|
||||
prometheus.GaugeValue,
|
||||
data.PoolNonpagedBytes,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.poolPagedBytes,
|
||||
prometheus.GaugeValue,
|
||||
data.PoolPagedBytes,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.privateBytes,
|
||||
prometheus.GaugeValue,
|
||||
data.PrivateBytes,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.threadCount,
|
||||
prometheus.GaugeValue,
|
||||
data.ThreadCount,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualBytes,
|
||||
prometheus.GaugeValue,
|
||||
data.VirtualBytes,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.virtualBytesPeak,
|
||||
prometheus.GaugeValue,
|
||||
data.VirtualBytesPeak,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.workingSet,
|
||||
prometheus.GaugeValue,
|
||||
data.WorkingSet,
|
||||
data.Name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.workingSetPeak,
|
||||
prometheus.GaugeValue,
|
||||
@@ -453,6 +467,7 @@ func (c *Collector) collectWTSSessions(ch chan<- prometheus.Metric) error {
|
||||
if session.State == stateID {
|
||||
isState = 1.0
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.sessionInfo,
|
||||
prometheus.GaugeValue,
|
||||
|
||||
@@ -217,6 +217,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M
|
||||
for _, q := range metric.GetSummary().GetQuantile() {
|
||||
quantiles[q.GetQuantile()] = q.GetValue()
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstSummary(
|
||||
prometheus.NewDesc(
|
||||
metricFamily.GetName(),
|
||||
@@ -232,6 +233,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M
|
||||
for _, b := range metric.GetHistogram().GetBucket() {
|
||||
buckets[b.GetUpperBound()] = b.GetCumulativeCount()
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstHistogram(
|
||||
prometheus.NewDesc(
|
||||
metricFamily.GetName(),
|
||||
@@ -290,8 +292,8 @@ type carriageReturnFilteringReader struct {
|
||||
// Read returns data from the underlying io.Reader, but with \r filtered out.
|
||||
func (cr carriageReturnFilteringReader) Read(p []byte) (int, error) {
|
||||
buf := make([]byte, len(p))
|
||||
n, err := cr.r.Read(buf)
|
||||
|
||||
n, err := cr.r.Read(buf)
|
||||
if err != nil && err != io.EOF {
|
||||
return n, err
|
||||
}
|
||||
@@ -356,7 +358,6 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil && directory != "" {
|
||||
errs = append(errs, fmt.Errorf("error reading textfile directory %q: %w", directory, err))
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ func TestDuplicateMetricEntry(t *testing.T) {
|
||||
}
|
||||
|
||||
var duplicateFamily []*dto.MetricFamily
|
||||
|
||||
duplicateFamily = append(duplicateFamily, &duplicate)
|
||||
|
||||
// Ensure detection for duplicate metrics
|
||||
|
||||
@@ -51,6 +51,7 @@ func TestMultipleDirectories(t *testing.T) {
|
||||
got := ""
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
go func() {
|
||||
errCh <- textFileCollector.Collect(metrics)
|
||||
|
||||
@@ -88,6 +89,7 @@ func TestDuplicateFileName(t *testing.T) {
|
||||
got := ""
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
go func() {
|
||||
errCh <- textFileCollector.Collect(metrics)
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ func (c *Collector) collectTime(ch chan<- prometheus.Metric) error {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.currentTime,
|
||||
prometheus.GaugeValue,
|
||||
float64(time.Now().Unix()),
|
||||
float64(time.Now().UnixMicro())/1e6,
|
||||
)
|
||||
|
||||
timeZoneInfo, err := kernel32.GetDynamicTimeZoneInformation()
|
||||
@@ -305,7 +305,9 @@ func (c *Collector) collectClockSource(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error {
|
||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to collect time metrics: %w", err)
|
||||
return fmt.Errorf("failed to collect Windows Time Service metrics: %w", err)
|
||||
} else if len(c.perfDataObject) == 0 {
|
||||
return fmt.Errorf("failed to collect Windows Time Service metrics: %w", types.ErrNoDataUnexpected)
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
@@ -327,21 +329,25 @@ func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error {
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].ComputedTimeOffset/1000000, // microseconds -> seconds
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ntpClientTimeSourceCount,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].NTPClientTimeSourceCount,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ntpRoundTripDelay,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].NTPRoundTripDelay/1000000, // microseconds -> seconds
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ntpServerIncomingRequestsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.perfDataObject[0].NTPServerIncomingRequestsTotal,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.ntpServerOutgoingResponsesTotal,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -160,18 +160,21 @@ func (c *Collector) writeUDPCounters(ch chan<- prometheus.Metric, metrics []perf
|
||||
metrics[0].DatagramsNoPortPerSec,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.datagramsReceivedErrorsTotal,
|
||||
prometheus.CounterValue,
|
||||
metrics[0].DatagramsReceivedErrors,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.datagramsReceivedTotal,
|
||||
prometheus.GaugeValue,
|
||||
metrics[0].DatagramsReceivedPerSec,
|
||||
af,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.datagramsSentTotal,
|
||||
prometheus.CounterValue,
|
||||
|
||||
@@ -87,21 +87,6 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
config: ConfigDefaults,
|
||||
}
|
||||
|
||||
var (
|
||||
online bool
|
||||
scrapeInterval time.Duration
|
||||
)
|
||||
|
||||
app.Flag(
|
||||
"collector.updates.online",
|
||||
"Deprecated: Please use collector.update.online instead",
|
||||
).Default(strconv.FormatBool(ConfigDefaults.Online)).BoolVar(&online)
|
||||
|
||||
app.Flag(
|
||||
"collector.updates.scrape-interval",
|
||||
"Deprecated: Please use collector.update.scrape-interval instead",
|
||||
).Default(ConfigDefaults.ScrapeInterval.String()).DurationVar(&scrapeInterval)
|
||||
|
||||
app.Flag(
|
||||
"collector.update.online",
|
||||
"Whether to search for updates online.",
|
||||
@@ -112,33 +97,6 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
||||
"Define the interval of scraping Windows Update information.",
|
||||
).Default(ConfigDefaults.ScrapeInterval.String()).DurationVar(&c.config.ScrapeInterval)
|
||||
|
||||
app.Action(func(*kingpin.ParseContext) error {
|
||||
// Use deprecated flags only if new ones weren't explicitly set
|
||||
if online {
|
||||
// If the new flag is set, ignore the old one
|
||||
if !c.config.Online {
|
||||
c.config.Online = online
|
||||
}
|
||||
|
||||
slog.Warn("Warning: --collector.updates.online is deprecated, use --collector.update.online instead.",
|
||||
slog.String("collector", Name),
|
||||
)
|
||||
}
|
||||
|
||||
if scrapeInterval != ConfigDefaults.ScrapeInterval {
|
||||
// If the new flag is set, ignore the old one
|
||||
if c.config.ScrapeInterval != scrapeInterval {
|
||||
c.config.ScrapeInterval = scrapeInterval
|
||||
}
|
||||
|
||||
slog.Warn("Warning: --collector.updates.scrape-interval is deprecated, use --collector.update.scrape-interval instead.",
|
||||
slog.String("collector", Name),
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
@@ -405,7 +363,7 @@ func (c *Collector) fetchUpdates(logger *slog.Logger, usd *ole.IDispatch) ([]pro
|
||||
metricsBuf = append(metricsBuf, prometheus.MustNewConstMetric(
|
||||
c.lastScrapeMetric,
|
||||
prometheus.GaugeValue,
|
||||
float64(time.Now().Unix()),
|
||||
float64(time.Now().UnixMicro())/1e6,
|
||||
))
|
||||
|
||||
return metricsBuf, nil
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -134,6 +135,11 @@ func NewConfigFileResolver(filePath string) (*Resolver, error) {
|
||||
decoder.KnownFields(true)
|
||||
|
||||
if err = decoder.Decode(&configFileStructure); err != nil {
|
||||
// Handle EOF error gracefully, indicating no configuration was found.
|
||||
if errors.Is(err, io.EOF) {
|
||||
return &Resolver{flags: flags}, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("configuration file validation error: %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) {
|
||||
var mibInfo *DHCP_MIB_INFO_V5
|
||||
|
||||
if err := dhcpGetMibInfoV5(&mibInfo); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("dhcpGetMibInfoV5: %w", err)
|
||||
}
|
||||
|
||||
defer dhcpRpcFreeMemory(unsafe.Pointer(mibInfo))
|
||||
@@ -56,7 +56,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) {
|
||||
var superScopeTable *DHCP_SUPER_SCOPE_TABLE
|
||||
|
||||
if err := dhcpGetSuperScopeInfoV4(&superScopeTable); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("dhcpGetSuperScopeInfoV4: %w", err)
|
||||
} else if superScopeTable == nil {
|
||||
return nil, errors.New("dhcpGetSuperScopeInfoV4 returned nil")
|
||||
}
|
||||
|
||||
@@ -1,96 +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 guid
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
type GUID windows.GUID
|
||||
|
||||
// FromString parses a string containing a GUID and returns the GUID. The only
|
||||
// format currently supported is the `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
|
||||
// format.
|
||||
func FromString(s string) (GUID, error) {
|
||||
if len(s) != 36 {
|
||||
return GUID{}, fmt.Errorf("invalid GUID %q", s)
|
||||
}
|
||||
|
||||
if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
|
||||
return GUID{}, fmt.Errorf("invalid GUID %q", s)
|
||||
}
|
||||
|
||||
var g GUID
|
||||
|
||||
data1, err := strconv.ParseUint(s[0:8], 16, 32)
|
||||
if err != nil {
|
||||
return GUID{}, fmt.Errorf("invalid GUID %q", s)
|
||||
}
|
||||
|
||||
g.Data1 = uint32(data1)
|
||||
|
||||
data2, err := strconv.ParseUint(s[9:13], 16, 16)
|
||||
if err != nil {
|
||||
return GUID{}, fmt.Errorf("invalid GUID %q", s)
|
||||
}
|
||||
|
||||
g.Data2 = uint16(data2)
|
||||
|
||||
data3, err := strconv.ParseUint(s[14:18], 16, 16)
|
||||
if err != nil {
|
||||
return GUID{}, fmt.Errorf("invalid GUID %q", s)
|
||||
}
|
||||
|
||||
g.Data3 = uint16(data3)
|
||||
|
||||
for i, x := range []int{19, 21, 24, 26, 28, 30, 32, 34} {
|
||||
v, err := strconv.ParseUint(s[x:x+2], 16, 8)
|
||||
if err != nil {
|
||||
return GUID{}, fmt.Errorf("invalid GUID %q", s)
|
||||
}
|
||||
|
||||
g.Data4[i] = uint8(v)
|
||||
}
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
func (g *GUID) UnmarshalJSON(b []byte) error {
|
||||
guid, err := FromString(strings.Trim(strings.Trim(string(b), `"`), `{}`))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*g = guid
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GUID) String() string {
|
||||
return fmt.Sprintf(
|
||||
"%08x-%04x-%04x-%04x-%012x",
|
||||
g.Data1,
|
||||
g.Data2,
|
||||
g.Data3,
|
||||
g.Data4[:2],
|
||||
g.Data4[2:])
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package hcn
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
||||
"github.com/go-ole/go-ole"
|
||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
@@ -30,7 +30,7 @@ var (
|
||||
defaultQuery = utils.Must(windows.UTF16PtrFromString(`{"SchemaVersion":{"Major": 2,"Minor": 0},"Flags":"None"}`))
|
||||
)
|
||||
|
||||
func GetEndpointProperties(endpointID guid.GUID) (EndpointProperties, error) {
|
||||
func GetEndpointProperties(endpointID ole.GUID) (EndpointProperties, error) {
|
||||
endpoint, err := OpenEndpoint(endpointID)
|
||||
if err != nil {
|
||||
return EndpointProperties{}, fmt.Errorf("failed to open endpoint: %w", err)
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
||||
"github.com/go-ole/go-ole"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/hcs"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
@@ -40,7 +40,7 @@ var (
|
||||
// EnumerateEndpoints enumerates the endpoints.
|
||||
//
|
||||
// https://learn.microsoft.com/en-us/virtualization/api/hcn/reference/hcnenumerateendpoints
|
||||
func EnumerateEndpoints() ([]guid.GUID, error) {
|
||||
func EnumerateEndpoints() ([]ole.GUID, error) {
|
||||
var (
|
||||
endpointsJSON *uint16
|
||||
errorRecord *uint16
|
||||
@@ -59,7 +59,7 @@ func EnumerateEndpoints() ([]guid.GUID, error) {
|
||||
return nil, fmt.Errorf("HcnEnumerateEndpoints failed: HRESULT 0x%X: %w", r1, hcs.Win32FromHResult(r1))
|
||||
}
|
||||
|
||||
var endpoints []guid.GUID
|
||||
var endpoints []ole.GUID
|
||||
|
||||
if err := json.Unmarshal([]byte(result), &endpoints); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)
|
||||
@@ -71,7 +71,7 @@ func EnumerateEndpoints() ([]guid.GUID, error) {
|
||||
// OpenEndpoint opens an endpoint.
|
||||
//
|
||||
// https://learn.microsoft.com/en-us/virtualization/api/hcn/reference/hcnopenendpoint
|
||||
func OpenEndpoint(id guid.GUID) (Endpoint, error) {
|
||||
func OpenEndpoint(id ole.GUID) (Endpoint, error) {
|
||||
var (
|
||||
endpoint Endpoint
|
||||
errorRecord *uint16
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package hcn
|
||||
|
||||
import (
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
||||
"github.com/go-ole/go-ole"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@ type EndpointPropertiesResources struct {
|
||||
Allocators []EndpointPropertiesAllocators `json:"Allocators"`
|
||||
}
|
||||
type EndpointPropertiesAllocators struct {
|
||||
AdapterNetCfgInstanceId *guid.GUID `json:"AdapterNetCfgInstanceId"`
|
||||
AdapterNetCfgInstanceId *ole.GUID `json:"AdapterNetCfgInstanceId"`
|
||||
}
|
||||
|
||||
type EndpointStats struct {
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
||||
"github.com/go-ole/go-ole"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
@@ -152,8 +152,9 @@ func GetIfEntry2Ex(row *MIB_IF_ROW2) error {
|
||||
// locally unique identifier (LUID) for the interface.
|
||||
//
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-convertinterfaceguidtoluid
|
||||
func ConvertInterfaceGUIDToLUID(guid guid.GUID) (uint64, error) {
|
||||
func ConvertInterfaceGUIDToLUID(guid ole.GUID) (uint64, error) {
|
||||
var luid uint64
|
||||
|
||||
ret, _, _ := procConvertInterfaceGuidToLuid.Call(
|
||||
uintptr(unsafe.Pointer(&guid)),
|
||||
uintptr(unsafe.Pointer(&luid)),
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
||||
"github.com/go-ole/go-ole"
|
||||
)
|
||||
|
||||
// MIB_TCPROW_OWNER_PID structure for IPv4.
|
||||
@@ -120,7 +120,7 @@ const (
|
||||
type MIB_IF_ROW2 struct {
|
||||
InterfaceLuid uint64
|
||||
InterfaceIndex uint32
|
||||
InterfaceGuid guid.GUID
|
||||
InterfaceGuid ole.GUID
|
||||
Alias [IF_MAX_STRING_SIZE + 1]uint16
|
||||
Description [IF_MAX_STRING_SIZE + 1]uint16
|
||||
PhysicalAddressLength uint32
|
||||
|
||||
55
internal/headers/propsys/propsys.go
Normal file
55
internal/headers/propsys/propsys.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// 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 propsys
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"github.com/go-ole/go-ole"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
modPropsys = windows.NewLazySystemDLL("propsys.dll")
|
||||
procPSGetPropertyKeyFromName = modPropsys.NewProc("PSGetPropertyKeyFromName")
|
||||
)
|
||||
|
||||
type PROPERTYKEY struct {
|
||||
Fmtid ole.GUID
|
||||
Pid uint32
|
||||
}
|
||||
|
||||
func PSGetPropertyKeyFromName(name string, key *PROPERTYKEY) error {
|
||||
namePtr, err := windows.UTF16PtrFromString(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to convert name to UTF16: %w", err)
|
||||
}
|
||||
|
||||
hr, _, err := procPSGetPropertyKeyFromName.Call(
|
||||
uintptr(unsafe.Pointer(namePtr)),
|
||||
uintptr(unsafe.Pointer(key)),
|
||||
)
|
||||
|
||||
if hr != 0 {
|
||||
return fmt.Errorf("PSGetPropertyKeyFromName failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -51,6 +51,7 @@ var (
|
||||
// GetPerformanceInfo returns the dereferenced version of GetLPPerformanceInfo.
|
||||
func GetPerformanceInfo() (PerformanceInformation, error) {
|
||||
var lppi PerformanceInformation
|
||||
|
||||
size := (uint32)(unsafe.Sizeof(lppi))
|
||||
lppi.cb = size
|
||||
r1, _, err := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&lppi)), uintptr(size))
|
||||
|
||||
84
internal/headers/shell32/shell32.go
Normal file
84
internal/headers/shell32/shell32.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// 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 shell32
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/go-ole/go-ole"
|
||||
"github.com/prometheus-community/windows_exporter/internal/headers/propsys"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var (
|
||||
modShell32 = windows.NewLazySystemDLL("shell32.dll")
|
||||
procSHCreateItemFromParsingName = modShell32.NewProc("SHCreateItemFromParsingName")
|
||||
|
||||
iidIShellItem2 = ole.NewGUID("{7E9FB0D3-919F-4307-AB2E-9B1860310C93}")
|
||||
)
|
||||
|
||||
func SHCreateItemFromParsingName(path string) (*IShellItem2, error) {
|
||||
ptrPath, err := windows.UTF16PtrFromString(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to convert path to UTF16: %w", err)
|
||||
}
|
||||
|
||||
var result *IShellItem2
|
||||
|
||||
hr, _, err := procSHCreateItemFromParsingName.Call(
|
||||
uintptr(unsafe.Pointer(ptrPath)),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(iidIShellItem2)),
|
||||
uintptr(unsafe.Pointer(&result)),
|
||||
)
|
||||
if hr != 0 {
|
||||
return nil, fmt.Errorf("syscall failed: %w", err)
|
||||
}
|
||||
|
||||
if result == nil {
|
||||
return nil, errors.New("SHCreateItemFromParsingName returned nil")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (item *IShellItem2) GetProperty(key *propsys.PROPERTYKEY, v *ole.VARIANT) error {
|
||||
hr, _, err := syscall.SyscallN(
|
||||
item.lpVtbl.GetProperty,
|
||||
uintptr(unsafe.Pointer(item)),
|
||||
uintptr(unsafe.Pointer(key)),
|
||||
uintptr(unsafe.Pointer(v)),
|
||||
)
|
||||
|
||||
if hr != 0 {
|
||||
return fmt.Errorf("GetProperty failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (item *IShellItem2) Release() {
|
||||
_, _, _ = syscall.SyscallN(
|
||||
item.lpVtbl.Release,
|
||||
uintptr(unsafe.Pointer(item)),
|
||||
)
|
||||
}
|
||||
51
internal/headers/shell32/types.go
Normal file
51
internal/headers/shell32/types.go
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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 shell32
|
||||
|
||||
type IShellItem2 struct {
|
||||
lpVtbl *IShellItem2Vtbl
|
||||
}
|
||||
|
||||
type IShellItem2Vtbl struct {
|
||||
// IUnknown
|
||||
QueryInterface uintptr
|
||||
AddRef uintptr
|
||||
Release uintptr
|
||||
|
||||
// IShellItem
|
||||
BindToHandler uintptr
|
||||
GetParent uintptr
|
||||
GetDisplayName uintptr
|
||||
GetAttributes uintptr
|
||||
Compare uintptr
|
||||
|
||||
// IShellItem2
|
||||
GetPropertyStore uintptr
|
||||
GetPropertyStoreWithCreateObject uintptr
|
||||
GetPropertyStoreForKeys uintptr
|
||||
GetPropertyDescriptionList uintptr
|
||||
Update uintptr
|
||||
GetProperty uintptr
|
||||
GetCLSID uintptr
|
||||
GetFileTime uintptr
|
||||
GetInt32 uintptr
|
||||
GetString uintptr
|
||||
GetUInt32 uintptr
|
||||
GetUInt64 uintptr
|
||||
GetBool uintptr
|
||||
}
|
||||
@@ -50,7 +50,6 @@ func SLIsWindowsGenuineLocal() (SL_GENUINE_STATE, error) {
|
||||
_, _, err := procSLIsWindowsGenuineLocal.Call(
|
||||
uintptr(unsafe.Pointer(&genuineState)),
|
||||
)
|
||||
|
||||
if !errors.Is(err, windows.NTE_OP_OK) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ var (
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex
|
||||
func GlobalMemoryStatusEx() (MemoryStatus, error) {
|
||||
var mse memoryStatusEx
|
||||
|
||||
mse.dwLength = (uint32)(unsafe.Sizeof(mse))
|
||||
r1, _, err := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&mse)))
|
||||
|
||||
|
||||
@@ -147,7 +147,6 @@ func WTSOpenServer(server string) (windows.Handle, error) {
|
||||
|
||||
func WTSCloseServer(server windows.Handle) error {
|
||||
r1, _, err := procWTSCloseServer.Call(uintptr(server))
|
||||
|
||||
if r1 != 1 && !errors.Is(err, windows.ERROR_SUCCESS) {
|
||||
return fmt.Errorf("failed to close server: %w", err)
|
||||
}
|
||||
@@ -196,6 +195,7 @@ func WTSEnumerateSessionsEx(server windows.Handle, logger *slog.Logger) ([]WTSSe
|
||||
}
|
||||
|
||||
var sizeTest wtsSessionInfo1
|
||||
|
||||
sessionSize := unsafe.Sizeof(sizeTest)
|
||||
|
||||
sessions := make([]WTSSession, 0, count)
|
||||
|
||||
@@ -42,9 +42,8 @@ type MetricsHTTPHandler struct {
|
||||
// the exporter itself.
|
||||
exporterMetricsRegistry *prometheus.Registry
|
||||
|
||||
logger *slog.Logger
|
||||
options Options
|
||||
concurrencyCh chan struct{}
|
||||
logger *slog.Logger
|
||||
options Options
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
@@ -64,9 +63,6 @@ func New(logger *slog.Logger, metricCollectors *collector.Collection, options *O
|
||||
metricCollectors: metricCollectors,
|
||||
logger: logger,
|
||||
options: *options,
|
||||
|
||||
// We are expose metrics directly from the memory region of the Win32 API. We should not allow more than one request at a time.
|
||||
concurrencyCh: make(chan struct{}, 1),
|
||||
}
|
||||
|
||||
if !options.DisableExporterMetrics {
|
||||
|
||||
@@ -113,7 +113,6 @@ func ApplicationInitialize() (*Application, error) {
|
||||
0,
|
||||
uintptr(unsafe.Pointer(application)),
|
||||
)
|
||||
|
||||
if !errors.Is(err, windows.NOERROR) {
|
||||
return nil, fmt.Errorf("syscall returned: %w", err)
|
||||
}
|
||||
|
||||
@@ -154,7 +154,6 @@ func (o *Operation) GetInstance() (*Instance, bool, error) {
|
||||
uintptr(unsafe.Pointer(&errorMessageUTF16)),
|
||||
uintptr(unsafe.Pointer(&errorDetails)),
|
||||
)
|
||||
|
||||
if !errors.Is(instanceResult, MI_RESULT_OK) {
|
||||
return nil, false, fmt.Errorf("instance result: %w (%s)", instanceResult, windows.UTF16PtrToString(errorMessageUTF16))
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user