mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-14 08:56:36 +00:00
Compare commits
50 Commits
v0.31.0-be
...
v0.31.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e85959a4d | ||
|
|
6253bf812d | ||
|
|
6c2380bd04 | ||
|
|
5266f9ebfe | ||
|
|
6c9a5b66e2 | ||
|
|
c4ab8cb8a5 | ||
|
|
7bcaf81d26 | ||
|
|
5f6ba2c6e7 | ||
|
|
75c85fbde1 | ||
|
|
120c244313 | ||
|
|
0e2d78affe | ||
|
|
f0591d85cd | ||
|
|
255b01f610 | ||
|
|
ab7db07836 | ||
|
|
52056a5cd9 | ||
|
|
524fea08c4 | ||
|
|
6b8c895a68 | ||
|
|
eade0da514 | ||
|
|
b07e866b4a | ||
|
|
98618408ce | ||
|
|
56b9f7fd27 | ||
|
|
8d267336c1 | ||
|
|
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:
|
body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
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
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
value: |-
|
value: |-
|
||||||
@@ -15,18 +19,18 @@ body:
|
|||||||
```
|
```
|
||||||
PS C:\WINDOWS\system32> cd c:\windows\system32
|
PS C:\WINDOWS\system32> cd c:\windows\system32
|
||||||
PS C:\windows\system32> lodctr /R
|
PS C:\windows\system32> lodctr /R
|
||||||
|
|
||||||
Error: Unable to rebuild performance counter setting from system backup store, error code is 2
|
Error: Unable to rebuild performance counter setting from system backup store, error code is 2
|
||||||
PS C:\windows\system32> cd ..
|
PS C:\windows\system32> cd ..
|
||||||
PS C:\windows> cd syswow64
|
PS C:\windows> cd syswow64
|
||||||
PS C:\windows\syswow64> lodctr /R
|
PS C:\windows\syswow64> lodctr /R
|
||||||
|
|
||||||
Info: Successfully rebuilt performance counter setting from system backup store
|
Info: Successfully rebuilt performance counter setting from system backup store
|
||||||
PS C:\windows\syswow64> winmgmt.exe /RESYNCPERF
|
PS C:\windows\syswow64> winmgmt.exe /RESYNCPERF
|
||||||
```
|
```
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Current Behavior
|
label: Current Behavior
|
||||||
@@ -36,7 +40,7 @@ body:
|
|||||||
```...```
|
```...```
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Expected Behavior
|
label: Expected Behavior
|
||||||
@@ -44,7 +48,7 @@ body:
|
|||||||
placeholder: When I do <X>, <Z> should happen instead.
|
placeholder: When I do <X>, <Z> should happen instead.
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Steps To Reproduce
|
label: Steps To Reproduce
|
||||||
@@ -57,7 +61,7 @@ body:
|
|||||||
render: Markdown
|
render: Markdown
|
||||||
validations:
|
validations:
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Environment
|
label: Environment
|
||||||
@@ -70,7 +74,7 @@ body:
|
|||||||
- Windows Server Version:
|
- Windows Server Version:
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: windows_exporter logs
|
label: windows_exporter logs
|
||||||
@@ -80,7 +84,7 @@ body:
|
|||||||
render: shell
|
render: shell
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Anything else?
|
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
|
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
||||||
with:
|
with:
|
||||||
# renovate: github=golangci/golangci-lint
|
# renovate: github=golangci/golangci-lint
|
||||||
version: v2.1.6
|
version: v2.3.1
|
||||||
args: "--max-same-issues=0"
|
args: "--max-same-issues=0"
|
||||||
|
|||||||
2
.github/workflows/pr-check.yaml
vendored
2
.github/workflows/pr-check.yaml
vendored
@@ -37,7 +37,7 @@ jobs:
|
|||||||
- name: check
|
- name: check
|
||||||
run: |
|
run: |
|
||||||
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1)
|
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1)
|
||||||
if [[ -d "internal/collector/$PR_TITLE_PREFIX" ]] || [[ -d "internal/$PR_TITLE_PREFIX" ]] || [[ -d "pkg/$PR_TITLE_PREFIX" ]] || [[ -d "$PR_TITLE_PREFIX" ]] || [[ "$PR_TITLE_PREFIX" == "docs" ]] || [[ "$PR_TITLE_PREFIX" == "ci" ]] || [[ "$PR_TITLE_PREFIX" == "revert" ]] || [[ "$PR_TITLE_PREFIX" == "fix" ]] || [[ "$PR_TITLE_PREFIX" == "fix(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "feat" ]] || [[ "$PR_TITLE_PREFIX" == "chore" ]] || [[ "$PR_TITLE_PREFIX" == "chore(docs)" ]] || [[ "$PR_TITLE_PREFIX" == "chore(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "*" ]] || [[ "$PR_TITLE_PREFIX" == "Release"* ]] || [[ "$PR_TITLE_PREFIX" == "Synchronize common files from prometheus/prometheus" ]]; then
|
if [[ -d "internal/collector/$PR_TITLE_PREFIX" ]] || [[ -d "internal/$PR_TITLE_PREFIX" ]] || [[ -d "pkg/$PR_TITLE_PREFIX" ]] || [[ -d "$PR_TITLE_PREFIX" ]] || [[ "$PR_TITLE_PREFIX" == "docs" ]] || [[ "$PR_TITLE_PREFIX" == "ci" ]] || [[ "$PR_TITLE_PREFIX" == "revert" ]] || [[ "$PR_TITLE_PREFIX" == "fix" ]] || [[ "$PR_TITLE_PREFIX" == "fix(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "feat" ]] || [[ "$PR_TITLE_PREFIX" == "chore" ]] || [[ "$PR_TITLE_PREFIX" == "chore(docs)" ]] || [[ "$PR_TITLE_PREFIX" == "chore(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "*" ]] || [[ "$PR_TITLE_PREFIX" == "Release"* ]] || [[ "$PR_TITLE_PREFIX" == "Synchronize common files from prometheus/prometheus" ]] || [[ "$PR_TITLE_PREFIX" == "[0."* ]] || [[ "$PR_TITLE_PREFIX" == "[1."* ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -214,7 +214,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
|
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
ghcr.io/prometheus-community/windows-exporter
|
ghcr.io/prometheus-community/windows-exporter
|
||||||
@@ -231,7 +231,7 @@ jobs:
|
|||||||
org.opencontainers.image.licenses=MIT
|
org.opencontainers.image.licenses=MIT
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- 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
|
- name: Build and push
|
||||||
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||||
|
|||||||
@@ -19,11 +19,13 @@ linters:
|
|||||||
- lll
|
- lll
|
||||||
- maintidx
|
- maintidx
|
||||||
- mnd
|
- mnd
|
||||||
|
- noinlineerr
|
||||||
- paralleltest
|
- paralleltest
|
||||||
- tagliatelle
|
- tagliatelle
|
||||||
- testpackage
|
- testpackage
|
||||||
- varnamelen
|
- varnamelen
|
||||||
- wrapcheck
|
- wrapcheck
|
||||||
|
- wsl
|
||||||
settings:
|
settings:
|
||||||
forbidigo:
|
forbidigo:
|
||||||
forbid:
|
forbid:
|
||||||
@@ -62,6 +64,13 @@ linters:
|
|||||||
disable:
|
disable:
|
||||||
- fieldalignment
|
- fieldalignment
|
||||||
- shadow
|
- 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:
|
sloglint:
|
||||||
no-mixed-args: true
|
no-mixed-args: true
|
||||||
kv-only: false
|
kv-only: false
|
||||||
|
|||||||
5
.idea/dictionaries/project.xml
generated
5
.idea/dictionaries/project.xml
generated
@@ -2,8 +2,13 @@
|
|||||||
<dictionary name="project">
|
<dictionary name="project">
|
||||||
<words>
|
<words>
|
||||||
<w>containerd</w>
|
<w>containerd</w>
|
||||||
|
<w>endpointstats</w>
|
||||||
|
<w>gochecknoglobals</w>
|
||||||
|
<w>luid</w>
|
||||||
<w>setupapi</w>
|
<w>setupapi</w>
|
||||||
<w>spdx</w>
|
<w>spdx</w>
|
||||||
|
<w>textfile</w>
|
||||||
|
<w>vmcompute</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
</component>
|
</component>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<configuration default="false" name="all" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="run">
|
<configuration default="false" name="all" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="run">
|
||||||
<module name="windows_exporter" />
|
<module name="windows_exporter" />
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
<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" />
|
<sudo value="true" />
|
||||||
<kind value="PACKAGE" />
|
<kind value="PACKAGE" />
|
||||||
<package value="github.com/prometheus-community/windows_exporter/cmd/windows_exporter" />
|
<package value="github.com/prometheus-community/windows_exporter/cmd/windows_exporter" />
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -29,7 +29,7 @@ test:
|
|||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
|
||||||
bench:
|
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:
|
lint:
|
||||||
golangci-lint -c .golangci.yaml run
|
golangci-lint -c .golangci.yaml run
|
||||||
|
|||||||
180
README.md
180
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)
|
||||||
[](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
|
## Collectors
|
||||||
|
|
||||||
Name | Description | Enabled by default
|
| Name | Description | Enabled by default |
|
||||||
------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------
|
|------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|
|
||||||
[ad](docs/collector.ad.md) | Active Directory Domain Services |
|
| [ad](docs/collector.ad.md) | Active Directory Domain Services | |
|
||||||
[adcs](docs/collector.adcs.md) | Active Directory Certificate Services |
|
| [adcs](docs/collector.adcs.md) | Active Directory Certificate Services | |
|
||||||
[adfs](docs/collector.adfs.md) | Active Directory Federation Services |
|
| [adfs](docs/collector.adfs.md) | Active Directory Federation Services | |
|
||||||
[cache](docs/collector.cache.md) | Cache metrics |
|
| [cache](docs/collector.cache.md) | Cache metrics | |
|
||||||
[cpu](docs/collector.cpu.md) | CPU usage | ✓
|
| [cpu](docs/collector.cpu.md) | CPU usage | ✓ |
|
||||||
[cpu_info](docs/collector.cpu_info.md) | CPU Information |
|
| [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 | |
|
||||||
[container](docs/collector.container.md) | Container metrics |
|
| [diskdrive](docs/collector.diskdrive.md) | Diskdrive metrics | |
|
||||||
[diskdrive](docs/collector.diskdrive.md) | Diskdrive metrics |
|
| [dfsr](docs/collector.dfsr.md) | DFSR metrics | |
|
||||||
[dfsr](docs/collector.dfsr.md) | DFSR metrics |
|
| [dhcp](docs/collector.dhcp.md) | DHCP Server | |
|
||||||
[dhcp](docs/collector.dhcp.md) | DHCP Server |
|
| [dns](docs/collector.dns.md) | DNS Server | |
|
||||||
[dns](docs/collector.dns.md) | DNS Server |
|
| [exchange](docs/collector.exchange.md) | Exchange metrics | |
|
||||||
[exchange](docs/collector.exchange.md) | Exchange metrics |
|
| [filetime](docs/collector.filetime.md) | FileTime metrics | |
|
||||||
[filetime](docs/collector.filetime.md) | FileTime metrics |
|
| [fsrmquota](docs/collector.fsrmquota.md) | Microsoft File Server Resource Manager (FSRM) Quotas collector | |
|
||||||
[fsrmquota](docs/collector.fsrmquota.md) | Microsoft File Server Resource Manager (FSRM) Quotas collector |
|
| [gpu](docs/collector.gpu.md) | GPU metrics | |
|
||||||
[gpu](docs/collector.gpu.md) | GPU metrics |
|
| [hyperv](docs/collector.hyperv.md) | Hyper-V hosts | |
|
||||||
[hyperv](docs/collector.hyperv.md) | Hyper-V hosts |
|
| [iis](docs/collector.iis.md) | IIS sites and applications | |
|
||||||
[iis](docs/collector.iis.md) | IIS sites and applications |
|
| [license](docs/collector.license.md) | Windows license status | |
|
||||||
[license](docs/collector.license.md) | Windows license status |
|
| [logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓ |
|
||||||
[logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | ✓
|
| [memory](docs/collector.memory.md) | Memory usage metrics | ✓ |
|
||||||
[memory](docs/collector.memory.md) | Memory usage metrics | ✓
|
| [mscluster](docs/collector.mscluster.md) | MSCluster metrics | |
|
||||||
[mscluster](docs/collector.mscluster.md) | MSCluster metrics |
|
| [msmq](docs/collector.msmq.md) | MSMQ queues | |
|
||||||
[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 | |
|
||||||
[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 | |
|
||||||
[netframework](docs/collector.netframework.md) | .NET Framework metrics |
|
| [net](docs/collector.net.md) | Network interface I/O | ✓ |
|
||||||
[net](docs/collector.net.md) | Network interface I/O | ✓
|
| [os](docs/collector.os.md) | OS metrics (memory, processes, users) | ✓ |
|
||||||
[os](docs/collector.os.md) | OS metrics (memory, processes, users) | ✓
|
| [pagefile](docs/collector.pagefile.md) | pagefile metrics | |
|
||||||
[pagefile](docs/collector.pagefile.md) | pagefile metrics |
|
| [performancecounter](docs/collector.performancecounter.md) | Custom performance counter metrics | |
|
||||||
[performancecounter](docs/collector.performancecounter.md) | Custom performance counter metrics |
|
| [physical_disk](docs/collector.physical_disk.md) | physical disk metrics | ✓ |
|
||||||
[physical_disk](docs/collector.physical_disk.md) | physical disk metrics | ✓
|
| [printer](docs/collector.printer.md) | Printer metrics | |
|
||||||
[printer](docs/collector.printer.md) | Printer metrics |
|
| [process](docs/collector.process.md) | Per-process metrics | |
|
||||||
[process](docs/collector.process.md) | Per-process metrics |
|
| [remote_fx](docs/collector.remote_fx.md) | RemoteFX protocol (RDP) metrics | |
|
||||||
[remote_fx](docs/collector.remote_fx.md) | RemoteFX protocol (RDP) metrics |
|
| [scheduled_task](docs/collector.scheduled_task.md) | Scheduled Tasks metrics | |
|
||||||
[scheduled_task](docs/collector.scheduled_task.md) | Scheduled Tasks metrics |
|
| [service](docs/collector.service.md) | Service state metrics | ✓ |
|
||||||
[service](docs/collector.service.md) | Service state metrics | ✓
|
| [smb](docs/collector.smb.md) | SMB Server | |
|
||||||
[smb](docs/collector.smb.md) | SMB Server |
|
| [smbclient](docs/collector.smbclient.md) | SMB Client | |
|
||||||
[smbclient](docs/collector.smbclient.md) | SMB Client |
|
| [smtp](docs/collector.smtp.md) | IIS SMTP Server | |
|
||||||
[smtp](docs/collector.smtp.md) | IIS SMTP Server |
|
| [system](docs/collector.system.md) | System calls | ✓ |
|
||||||
[system](docs/collector.system.md) | System calls | ✓
|
| [tcp](docs/collector.tcp.md) | TCP connections | |
|
||||||
[tcp](docs/collector.tcp.md) | TCP connections |
|
| [terminal_services](docs/collector.terminal_services.md) | Terminal services (RDS) | |
|
||||||
[terminal_services](docs/collector.terminal_services.md) | Terminal services (RDS)
|
| [textfile](docs/collector.textfile.md) | Read prometheus metrics from a text file | |
|
||||||
[textfile](docs/collector.textfile.md) | Read prometheus metrics from a text file |
|
| [thermalzone](docs/collector.thermalzone.md) | Thermal information | |
|
||||||
[thermalzone](docs/collector.thermalzone.md) | Thermal information |
|
| [time](docs/collector.time.md) | Windows Time Service | |
|
||||||
[time](docs/collector.time.md) | Windows Time Service |
|
| [udp](docs/collector.udp.md) | UDP connections | |
|
||||||
[udp](docs/collector.udp.md) | UDP connections |
|
| [update](docs/collector.update.md) | Windows Update Service | |
|
||||||
[update](docs/collector.update.md) | Windows Update Service |
|
| [vmware](docs/collector.vmware.md) | Performance counters installed by the Vmware Guest agent | |
|
||||||
[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.
|
See the linked documentation on each collector for more information on reported metrics, configuration settings and usage examples.
|
||||||
|
|
||||||
@@ -83,15 +82,15 @@ This can be useful for having different Prometheus servers collect specific metr
|
|||||||
|
|
||||||
windows_exporter accepts flags to configure certain behaviours. The ones configuring the global behaviour of the exporter are listed below, while collector-specific ones are documented in the respective collector documentation above.
|
windows_exporter accepts flags to configure certain behaviours. The ones configuring the global behaviour of the exporter are listed below, while collector-specific ones are documented in the respective collector documentation above.
|
||||||
|
|
||||||
| Flag | Description | Default value |
|
| Flag | Description | Default value |
|
||||||
|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
|
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
|
||||||
| `--web.listen-address` | host:port for exporter. | `:9182` |
|
| `--web.listen-address` | host:port for exporter. | `:9182` |
|
||||||
| `--telemetry.path` | URL path for surfacing collected metrics. | `/metrics` |
|
| `--telemetry.path` | URL path for surfacing collected metrics. | `/metrics` |
|
||||||
| `--collectors.enabled` | Comma-separated list of collectors to use. Use `[defaults]` as a placeholder which gets expanded containing all the collectors enabled by default. | `[defaults]` |
|
| `--collectors.enabled` | Comma-separated list of collectors to use. Use `[defaults]` as a placeholder which gets expanded containing all the collectors enabled by default. | `[defaults]` |
|
||||||
| `--scrape.timeout-margin` | Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads. | `0.5` |
|
| `--scrape.timeout-margin` | Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads. | `0.5` |
|
||||||
| `--web.config.file` | A [web config][web_config] for setting up TLS and Auth | None |
|
| `--web.config.file` | A [web config][web_config] for setting up TLS and Auth | None |
|
||||||
| `--config.file` | [Using a config file](#using-a-configuration-file) from path or URL | None |
|
| `--config.file` | [Using a config file](#using-a-configuration-file) from path | None |
|
||||||
| `--log.file` | Output file of log messages. One of [stdout, stderr, eventlog, \<path to log file>]<br>**NOTE:** The MSI installer will add a default argument to the installed service setting this to eventlog | stderr |
|
| `--log.file` | Output file of log messages. One of [stdout, stderr, eventlog, \<path to log file>]<br>**NOTE:** The MSI installer will add a default argument to the installed service setting this to eventlog | stderr |
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -113,20 +112,22 @@ The configuration file
|
|||||||
|
|
||||||
The following parameters are available:
|
The following parameters are available:
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `ENABLED_COLLECTORS` | As the `--collectors.enabled` flag, provide a comma-separated list of enabled collectors |
|
| `ENABLED_COLLECTORS` | As the `--collectors.enabled` flag, provide a comma-separated list of enabled collectors |
|
||||||
| `CONFIG_FILE` | Use the `--config.file` flag to specify a config file. If empty, no config file will be set. The special value `config.yaml` set the path to the config.yaml at install dir | |
|
| `CONFIG_FILE` | Use the `--config.file` flag to specify a config file. If empty, default config file at install dir will be used. If set, the config file must be exist before the installation is started. | |
|
||||||
| `LISTEN_ADDR` | The IP address to bind to. Defaults to an empty string. (any local address) |
|
| `LISTEN_ADDR` | The IP address to bind to. Defaults to an empty string. (any local address) |
|
||||||
| `LISTEN_PORT` | The port to bind to. Defaults to `9182`. |
|
| `LISTEN_PORT` | The port to bind to. Defaults to `9182`. |
|
||||||
| `METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` |
|
| `METRICS_PATH` | The path at which to serve metrics. Defaults to `/metrics` |
|
||||||
| `TEXTFILE_DIRS` | Use the `--collector.textfile.directories` flag to specify one or more directories, separated by commas, where the collector should read text files containing metrics |
|
| `TEXTFILE_DIRS` | Use the `--collector.textfile.directories` flag to specify one or more directories, separated by commas, where the collector should read text files containing metrics |
|
||||||
| `REMOTE_ADDR` | Allows setting comma separated remote IP addresses for the Windows Firewall exception (allow list). Defaults to an empty string (any remote address). |
|
| `REMOTE_ADDR` | Allows setting comma separated remote IP addresses for the Windows Firewall exception (allow list). Defaults to an empty string (any remote address). |
|
||||||
| `EXTRA_FLAGS` | Allows passing full CLI flags. Defaults to an empty string. For `--collectors.enabled` and `--config.file`, use the specialized properties `ENABLED_COLLECTORS` and `CONFIG_FILE` |
|
| `EXTRA_FLAGS` | Allows passing full CLI flags. Defaults to an empty string. For `--collectors.enabled` and `--config.file`, use the specialized properties `ENABLED_COLLECTORS` and `CONFIG_FILE` |
|
||||||
| `ADDLOCAL` | Enables features within the windows_exporter installer. Supported values: `FirewallException` |
|
| `ADDLOCAL` | Enables features within the windows_exporter installer. Supported values: `FirewallException` |
|
||||||
| `REMOVE` | Disables features within the windows_exporter installer. Supported values: `FirewallException` |
|
| `REMOVE` | Disables features within the windows_exporter installer. Supported values: `FirewallException` |
|
||||||
| `APPLICATIONFOLDER` | Directory to install windows_exporter. Defaults to `C:\Program Files\windows_exporter` |
|
| `APPLICATIONFOLDER` | Directory to install windows_exporter. Defaults to `C:\Program Files\windows_exporter` |
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The installer properties are always preferred over the values defined in the config file. If you prefer to configure via the config file, avoid using any of the properties listed above.
|
||||||
|
|
||||||
Parameters are sent to the installer via `msiexec`.
|
Parameters are sent to the installer via `msiexec`.
|
||||||
On PowerShell, the `--%` should be passed before defining properties.
|
On PowerShell, the `--%` should be passed before defining properties.
|
||||||
@@ -155,7 +156,7 @@ msiexec /i <path-to-msi-file> --% ADDLOCAL=FirewallException APPLICATIONFOLDER="
|
|||||||
On some older versions of Windows,
|
On some older versions of Windows,
|
||||||
you may need to surround parameter values with double quotes to get the installation command parsing properly:
|
you may need to surround parameter values with double quotes to get the installation command parsing properly:
|
||||||
```powershell
|
```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:
|
To install the exporter with creating a firewall exception, use the following command:
|
||||||
@@ -183,9 +184,6 @@ The windows_exporter can be run as a Docker container. The Docker image is avail
|
|||||||
|
|
||||||
The Docker image is tagged with the version of the exporter. The `latest` tag is also available and points to the latest release.
|
The Docker image is tagged with the version of the exporter. The `latest` tag is also available and points to the latest release.
|
||||||
|
|
||||||
Additionally, a flavor `hostprocess` with `-hostprocess` as suffix is based on the https://github.com/microsoft/windows-host-process-containers-base-image
|
|
||||||
which is designed to run as a Windows host process container. The size of that images is smaller than the default one.
|
|
||||||
|
|
||||||
## Kubernetes Implementation
|
## Kubernetes Implementation
|
||||||
|
|
||||||
See detailed steps to install on Windows Kubernetes [here](./kubernetes/kubernetes.md).
|
See detailed steps to install on Windows Kubernetes [here](./kubernetes/kubernetes.md).
|
||||||
@@ -194,17 +192,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_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
|
|
||||||
|
|
||||||
go get -u github.com/prometheus/promu
|
|
||||||
go get -u github.com/prometheus-community/windows_exporter
|
|
||||||
cd $env:GOPATH/src/github.com/prometheus-community/windows_exporter
|
|
||||||
promu build -v
|
|
||||||
.\windows_exporter.exe
|
|
||||||
|
|
||||||
The prometheus metrics will be exposed on [localhost:9182](http://localhost:9182)
|
|
||||||
|
|
||||||
### HTTP Endpoints
|
### HTTP Endpoints
|
||||||
|
|
||||||
@@ -214,18 +202,6 @@ windows_exporter provides the following HTTP endpoints:
|
|||||||
* `/health`: Returns 200 OK when the exporter is running.
|
* `/health`: Returns 200 OK when the exporter is running.
|
||||||
* `/debug/pprof/`: Exposes the [pprof](https://golang.org/pkg/net/http/pprof/) endpoints. Only, if `--debug.enabled` is set.
|
* `/debug/pprof/`: Exposes the [pprof](https://golang.org/pkg/net/http/pprof/) endpoints. Only, if `--debug.enabled` is set.
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Enable only service collector and specify a custom query
|
|
||||||
|
|
||||||
.\windows_exporter.exe --collectors.enabled "service" --collector.service.include="windows_exporter"
|
|
||||||
|
|
||||||
### Enable only process collector and specify a custom query
|
|
||||||
|
|
||||||
.\windows_exporter.exe --collectors.enabled "process" --collector.process.include="firefox.+"
|
|
||||||
|
|
||||||
When there are multiple processes with the same name, WMI represents those after the first instance as `process-name#index`. So to get them all, rather than just the first one, the [regular expression](https://en.wikipedia.org/wiki/Regular_expression) must use `.+`. See [process](docs/collector.process.md) for more information.
|
|
||||||
|
|
||||||
### Using [defaults] with `--collectors.enabled` argument
|
### Using [defaults] with `--collectors.enabled` argument
|
||||||
|
|
||||||
Using `[defaults]` with `--collectors.enabled` argument which gets expanded with all default collectors.
|
Using `[defaults]` with `--collectors.enabled` argument which gets expanded with all default collectors.
|
||||||
@@ -238,10 +214,6 @@ This enables the additional process and container collectors on top of the defau
|
|||||||
|
|
||||||
YAML configuration files can be specified with the `--config.file` flag. e.g. `.\windows_exporter.exe --config.file=config.yml`. If you are using the absolute path, make sure to quote the path, e.g. `.\windows_exporter.exe --config.file="C:\Program Files\windows_exporter\config.yml"`
|
YAML configuration files can be specified with the `--config.file` flag. e.g. `.\windows_exporter.exe --config.file=config.yml`. If you are using the absolute path, make sure to quote the path, e.g. `.\windows_exporter.exe --config.file="C:\Program Files\windows_exporter\config.yml"`
|
||||||
|
|
||||||
It is also possible to load the configuration from a URL. e.g. `.\windows_exporter.exe --config.file="https://example.com/config.yml"`
|
|
||||||
|
|
||||||
If you need to skip TLS verification, you can use the `--config.file.insecure-skip-verify` flag. e.g. `.\windows_exporter.exe --config.file="https://example.com/config.yml" --config.file.insecure-skip-verify`
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
collectors:
|
collectors:
|
||||||
enabled: cpu,net,service
|
enabled: cpu,net,service
|
||||||
@@ -258,7 +230,7 @@ An example configuration file can be found [here](docs/example_config.yml).
|
|||||||
|
|
||||||
Configuration file values can be mixed with CLI flags. E.G.
|
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
|
```yaml
|
||||||
log:
|
log:
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ type windowsExporterService struct{}
|
|||||||
// Execute is the entry point for the Windows service manager.
|
// 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) {
|
func (s *windowsExporterService) Execute(_ []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) {
|
||||||
changes <- svc.Status{State: svc.StartPending}
|
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}
|
changes <- svc.Status{State: svc.Running, Accepts: svc.AcceptStop | svc.AcceptShutdown}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@@ -179,6 +180,7 @@ func logToFile(msg string) {
|
|||||||
// https://github.com/DataDog/datadog-agent/blob/46740e82ef40a04c4be545ed8c16a4b0d1f046cf/pkg/util/winutil/servicemain/servicemain.go#L128
|
// https://github.com/DataDog/datadog-agent/blob/46740e82ef40a04c4be545ed8c16a4b0d1f046cf/pkg/util/winutil/servicemain/servicemain.go#L128
|
||||||
func isWindowsService() (bool, error) {
|
func isWindowsService() (bool, error) {
|
||||||
var currentProcess windows.PROCESS_BASIC_INFORMATION
|
var currentProcess windows.PROCESS_BASIC_INFORMATION
|
||||||
|
|
||||||
infoSize := uint32(unsafe.Sizeof(currentProcess))
|
infoSize := uint32(unsafe.Sizeof(currentProcess))
|
||||||
|
|
||||||
err := windows.NtQueryInformationProcess(windows.CurrentProcess(), windows.ProcessBasicInformation, unsafe.Pointer(¤tProcess), infoSize, &infoSize)
|
err := windows.NtQueryInformationProcess(windows.CurrentProcess(), windows.ProcessBasicInformation, unsafe.Pointer(¤tProcess), infoSize, &infoSize)
|
||||||
|
|||||||
@@ -171,8 +171,10 @@ func waitUntilListening(tb testing.TB, network, address string) error {
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dialer := &net.Dialer{Timeout: 100 * time.Millisecond}
|
||||||
|
|
||||||
for range 20 {
|
for range 20 {
|
||||||
conn, err = net.DialTimeout(network, address, 100*time.Millisecond)
|
conn, err = dialer.DialContext(tb.Context(), network, address)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
|
|
||||||
@@ -189,7 +191,6 @@ func waitUntilListening(tb testing.TB, network, address string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var winErr windows.Errno
|
var winErr windows.Errno
|
||||||
|
|
||||||
if errors.As(err, &winErr) {
|
if errors.As(err, &winErr) {
|
||||||
return fmt.Errorf("listener not listening: %w (#%d)", winErr, uint32(winErr))
|
return fmt.Errorf("listener not listening: %w (#%d)", winErr, uint32(winErr))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
# example configuration file for windows_exporter
|
# example configuration file for windows_exporter
|
||||||
|
|
||||||
collectors:
|
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:
|
collector:
|
||||||
|
textfile:
|
||||||
|
directories:
|
||||||
|
- 'C:\MyDir1'
|
||||||
|
- 'C:\MyDir2'
|
||||||
service:
|
service:
|
||||||
include: "windows_exporter"
|
include: "windows_exporter"
|
||||||
performancecounter:
|
performancecounter:
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ This directory contains documentation of the collectors in the windows_exporter,
|
|||||||
- [`container`](collector.container.md)
|
- [`container`](collector.container.md)
|
||||||
- [`cpu`](collector.cpu.md)
|
- [`cpu`](collector.cpu.md)
|
||||||
- [`cpu_info`](collector.cpu_info.md)
|
- [`cpu_info`](collector.cpu_info.md)
|
||||||
- [`cs`](collector.cs.md)
|
|
||||||
- [`dfsr`](collector.dfsr.md)
|
- [`dfsr`](collector.dfsr.md)
|
||||||
- [`dhcp`](collector.dhcp.md)
|
- [`dhcp`](collector.dhcp.md)
|
||||||
- [`diskdrive`](collector.diskdrive.md)
|
- [`diskdrive`](collector.diskdrive.md)
|
||||||
@@ -20,7 +19,6 @@ This directory contains documentation of the collectors in the windows_exporter,
|
|||||||
- [`iis`](collector.iis.md)
|
- [`iis`](collector.iis.md)
|
||||||
- [`license`](collector.license.md)
|
- [`license`](collector.license.md)
|
||||||
- [`logical_disk`](collector.logical_disk.md)
|
- [`logical_disk`](collector.logical_disk.md)
|
||||||
- [`logon`](collector.logon.md)
|
|
||||||
- [`memory`](collector.memory.md)
|
- [`memory`](collector.memory.md)
|
||||||
- [`mscluster`](collector.mscluster.md)
|
- [`mscluster`](collector.mscluster.md)
|
||||||
- [`msmq`](collector.msmq.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
|
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
|
## 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!_
|
_This collector does not yet have any useful queries added, we would appreciate your help adding them!_
|
||||||
|
|
||||||
## Alerting examples
|
## 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!_
|
||||||
|
|||||||
@@ -20,29 +20,32 @@ These metrics are available on supported versions of Windows with compatible GPU
|
|||||||
|
|
||||||
### Adapter-level Metrics
|
### Adapter-level Metrics
|
||||||
|
|
||||||
| Name | Description | Type | Labels |
|
| Name | Description | Type | Labels |
|
||||||
|----------------------------------------------|-------------------------------------------------------------------------|-------|--------------------------------------------------------------------------------------|
|
|--------------------------------------------------|------------------------------------------------------------------------------------|-------|---------------|
|
||||||
| `windows_gpu_adapter_memory_committed_bytes` | Total committed GPU memory in bytes per physical GPU | gauge | `phys` |
|
| `windows_gpu_info` | A metric with a constant '1' value labeled with gpu device information. | gauge | `luid`,`name`,`bus_number`,`phys`,`function_number` |
|
||||||
| `windows_gpu_adapter_memory_dedicated_bytes` | Dedicated GPU memory usage in bytes per physical GPU | gauge | `phys` |
|
| `windows_gpu_dedicated_system_memory_size_bytes` | The size, in bytes, of memory that is dedicated from system memory. | gauge | `luid` |
|
||||||
| `windows_gpu_adapter_memory_shared_bytes` | Shared GPU memory usage in bytes per physical GPU | gauge | `phys` |
|
| `windows_gpu_dedicated_video_memory_size_bytes` | The size, in bytes, of memory that is dedicated from video memory. | gauge | `luid` |
|
||||||
| `windows_gpu_info` | A metric with a constant '1' value labeled with gpu device information. | gauge | `phys`, `physical_device_object_name`, `hardware_id`, `friendly_name`, `description` |
|
| `windows_gpu_shared_system_memory_size_bytes` | The size, in bytes, of memory from system memory that can be shared by many users. | gauge | `luid` |
|
||||||
| `windows_gpu_local_adapter_memory_bytes` | Local adapter memory usage in bytes per physical GPU | gauge | `phys` |
|
| `windows_gpu_adapter_memory_committed_bytes` | Total committed GPU memory in bytes per physical GPU | gauge | `luid`,`phys` |
|
||||||
| `windows_gpu_non_local_adapter_memory_bytes` | Non-local adapter memory usage in bytes per physical GPU | gauge | `phys` |
|
| `windows_gpu_adapter_memory_dedicated_bytes` | Dedicated GPU memory usage in bytes per physical GPU | gauge | `luid`,`phys` |
|
||||||
|
| `windows_gpu_adapter_memory_shared_bytes` | Shared GPU memory usage in bytes per physical GPU | gauge | `luid`,`phys` |
|
||||||
|
| `windows_gpu_local_adapter_memory_bytes` | Local adapter memory usage in bytes per physical GPU | gauge | `luid`,`phys` |
|
||||||
|
| `windows_gpu_non_local_adapter_memory_bytes` | Non-local adapter memory usage in bytes per physical GPU | gauge | `luid`,`phys` |
|
||||||
|
|
||||||
### Per-process Metrics
|
### Per-process Metrics
|
||||||
|
|
||||||
| Name | Description | Type | Labels |
|
| Name | Description | Type | Labels |
|
||||||
|----------------------------------------------|-------------------------------------------------------------------------|---------|--------------------------------------------------------------------------------------|
|
|----------------------------------------------|-------------------------------------------------|---------|-----------------------------------------------|
|
||||||
| `windows_gpu_engine_time_seconds` | Total running time of the GPU engine in seconds | counter | `phys`, `eng`, `engtype`, `process_id` |
|
| `windows_gpu_engine_time_seconds` | Total running time of the GPU engine in seconds | counter | `luid`,`phys`, `eng`, `engtype`, `process_id` |
|
||||||
| `windows_gpu_process_memory_committed_bytes` | Total committed GPU memory in bytes per process | gauge | `phys`,`process_id` |
|
| `windows_gpu_process_memory_committed_bytes` | Total committed GPU memory in bytes per process | gauge | `luid`,`phys`,`process_id` |
|
||||||
| `windows_gpu_process_memory_dedicated_bytes` | Dedicated GPU memory usage in bytes per process | gauge | `phys`,`process_id` |
|
| `windows_gpu_process_memory_dedicated_bytes` | Dedicated GPU memory usage in bytes per process | gauge | `luid`,`phys`,`process_id` |
|
||||||
| `windows_gpu_process_memory_local_bytes` | Local GPU memory usage in bytes per process | gauge | `phys`,`process_id` |
|
| `windows_gpu_process_memory_local_bytes` | Local GPU memory usage in bytes per process | gauge | `luid`,`phys`,`process_id` |
|
||||||
| `windows_gpu_process_memory_non_local_bytes` | Non-local GPU memory usage in bytes per process | gauge | `phys`,`process_id` |
|
| `windows_gpu_process_memory_non_local_bytes` | Non-local GPU memory usage in bytes per process | gauge | `luid`,`phys`,`process_id` |
|
||||||
| `windows_gpu_process_memory_shared_bytes` | Shared GPU memory usage in bytes per process | gauge | `phys`,`process_id` |
|
| `windows_gpu_process_memory_shared_bytes` | Shared GPU memory usage in bytes per process | gauge | `luid`,`phys`,`process_id` |
|
||||||
|
|
||||||
## Metric Labels
|
## Metric Labels
|
||||||
|
|
||||||
* `phys`: Physical GPU index (e.g., "0")
|
* `luid`,`phys`: Physical GPU index (e.g., "0")
|
||||||
* `eng`: GPU engine index (e.g., "0", "1", ...)
|
* `eng`: GPU engine index (e.g., "0", "1", ...)
|
||||||
* `engtype`: GPU engine type (e.g., "3D", "Copy", "VideoDecode", etc.)
|
* `engtype`: GPU engine type (e.g., "3D", "Copy", "VideoDecode", etc.)
|
||||||
* `process_id`: Process ID
|
* `process_id`: Process ID
|
||||||
|
|||||||
@@ -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_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_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 |
|
| `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
|
### Example metric
|
||||||
_This collector does not yet have explained examples, we would appreciate your help adding them!_
|
_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)
|
The logical_disk collector exposes metrics about logical disks (in contrast to physical disks)
|
||||||
|
|
||||||
|||
|
| | |
|
||||||
-|-
|
|---------------------|------------------|
|
||||||
Metric name prefix | `logical_disk`
|
| Metric name prefix | `logical_disk` |
|
||||||
Data source | Perflib
|
| Data source | Performance Data |
|
||||||
Counters | `LogicalDisk` ([`Win32_PerfRawData_PerfDisk_LogicalDisk`](https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71)))
|
| Counters | `LogicalDisk` |
|
||||||
Enabled by default? | Yes
|
| Enabled by default? | Yes |
|
||||||
|
|
||||||
## Flags
|
## 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
|
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
|
## Metrics
|
||||||
|
|
||||||
Name | Description | Type | Labels
|
| 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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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
|
### 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.
|
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_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` |
|
| `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 |
|
| Name | Description | Type | Labels |
|
||||||
|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|--------|
|
|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|--------|
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ Disabled by default, and can be enabled with `--collector.process.iis`. NOTE: Ju
|
|||||||
Version of the process collector to use. 1 for Process V1, 2 for Process V2.
|
Version of the process collector to use. 1 for Process V1, 2 for Process V2.
|
||||||
Defaults to 0 which will use the latest version available.
|
Defaults to 0 which will use the latest version available.
|
||||||
|
|
||||||
|
### `--collector.process.cmdline`
|
||||||
|
|
||||||
|
Enables the `cmdline` label for the process metrics.
|
||||||
|
This label contains the command line used to start the process.
|
||||||
|
Enabled by default, and can be turned off with `--no-collector.process.cmdline`.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
To match all firefox processes: `--collector.process.include="firefox.*"`.
|
To match all firefox processes: `--collector.process.include="firefox.*"`.
|
||||||
|
|||||||
@@ -10,13 +10,8 @@ Enabled by default? | No
|
|||||||
|
|
||||||
## Flags
|
## Flags
|
||||||
|
|
||||||
### `--collector.textfile.directory`
|
|
||||||
:warning: DEPRECATED Use `--collector.textfile.directories`
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
### `--collector.textfile.directories`
|
### `--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"`
|
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_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_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_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_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` |
|
| `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
|
# Note this is not an exhaustive list of all configuration values
|
||||||
collectors:
|
collectors:
|
||||||
enabled: cpu,cs,logical_disk,net,os,service,system
|
enabled: cpu,logical_disk,net,os,service,system
|
||||||
collector:
|
collector:
|
||||||
service:
|
service:
|
||||||
include: "windows_exporter"
|
include: "windows_exporter"
|
||||||
@@ -13,6 +13,5 @@ scrape:
|
|||||||
timeout-margin: 0.5
|
timeout-margin: 0.5
|
||||||
telemetry:
|
telemetry:
|
||||||
path: /metrics
|
path: /metrics
|
||||||
max-requests: 5
|
|
||||||
web:
|
web:
|
||||||
listen-address: ":9182"
|
listen-address: ":9182"
|
||||||
|
|||||||
18
go.mod
18
go.mod
@@ -4,15 +4,15 @@ go 1.24
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alecthomas/kingpin/v2 v2.4.0
|
github.com/alecthomas/kingpin/v2 v2.4.0
|
||||||
github.com/bmatcuk/doublestar/v4 v4.8.1
|
github.com/bmatcuk/doublestar/v4 v4.9.1
|
||||||
github.com/dimchansky/utfbom v1.1.1
|
github.com/dimchansky/utfbom v1.1.1
|
||||||
github.com/go-ole/go-ole v1.3.0
|
github.com/go-ole/go-ole v1.3.0
|
||||||
github.com/prometheus/client_golang v1.22.0
|
github.com/prometheus/client_golang v1.23.0
|
||||||
github.com/prometheus/client_model v0.6.2
|
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/prometheus/exporter-toolkit v0.14.0
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.10.0
|
||||||
golang.org/x/sys v0.33.0
|
golang.org/x/sys v0.34.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,13 +28,13 @@ require (
|
|||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // 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/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
|
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
|
||||||
golang.org/x/crypto v0.38.0 // indirect
|
golang.org/x/crypto v0.40.0 // indirect
|
||||||
golang.org/x/net v0.40.0 // indirect
|
golang.org/x/net v0.42.0 // indirect
|
||||||
golang.org/x/oauth2 v0.30.0 // indirect
|
golang.org/x/oauth2 v0.30.0 // indirect
|
||||||
golang.org/x/sync v0.14.0 // indirect
|
golang.org/x/sync v0.16.0 // indirect
|
||||||
golang.org/x/text v0.25.0 // indirect
|
golang.org/x/text v0.27.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.6 // indirect
|
google.golang.org/protobuf v1.36.6 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
38
go.sum
38
go.sum
@@ -4,8 +4,8 @@ github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vS
|
|||||||
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs=
|
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b/go.mod h1:fvzegU4vN3H1qMT+8wDmzjAcDONcgo2/SZ/TyfdUOFs=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38=
|
github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE=
|
||||||
github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||||
@@ -41,16 +41,16 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
|
github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
|
||||||
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
|
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
|
||||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
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/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.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE=
|
||||||
github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
|
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 h1:NMlswfibpcZZ+H0sZBiTjrA3/aBFHkNZqE+iCj5EmRg=
|
||||||
github.com/prometheus/exporter-toolkit v0.14.0/go.mod h1:Gu5LnVvt7Nr/oqTBUC23WILZepW0nffNo10XdhQcwWA=
|
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.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
|
||||||
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
|
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 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
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=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
@@ -65,19 +65,21 @@ 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/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 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
|
||||||
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
|
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=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
||||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
||||||
|
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
|
||||||
|
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
|
||||||
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
|
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/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
|
||||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
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.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
||||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
|
||||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
|
||||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
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=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@@ -21,6 +21,14 @@
|
|||||||
<DirectoryRef Id="APPLICATIONFOLDER">
|
<DirectoryRef Id="APPLICATIONFOLDER">
|
||||||
<Component Transitive="yes">
|
<Component Transitive="yes">
|
||||||
<File Id="windows_exporter.exe" Name="windows_exporter.exe" Source="Work\windows_exporter.exe" KeyPath="yes" Vital="yes" Checksum="yes"/>
|
<File Id="windows_exporter.exe" Name="windows_exporter.exe" Source="Work\windows_exporter.exe" KeyPath="yes" Vital="yes" Checksum="yes"/>
|
||||||
|
|
||||||
|
<!-- The "Name" field must match the argument to eventlog.Open() -->
|
||||||
|
<util:EventSource Log="Application" Name="windows_exporter"
|
||||||
|
EventMessageFile="%SystemRoot%\System32\EventCreate.exe"
|
||||||
|
SupportsErrors="yes"
|
||||||
|
SupportsInformationals="yes"
|
||||||
|
SupportsWarnings="yes"/>
|
||||||
|
|
||||||
<ServiceInstall
|
<ServiceInstall
|
||||||
Id="InstallExporterService"
|
Id="InstallExporterService"
|
||||||
Name="windows_exporter"
|
Name="windows_exporter"
|
||||||
@@ -45,13 +53,8 @@
|
|||||||
/>
|
/>
|
||||||
<ServiceDependency Id="wmiApSrv" />
|
<ServiceDependency Id="wmiApSrv" />
|
||||||
</ServiceInstall>
|
</ServiceInstall>
|
||||||
<ServiceControl Id="ServiceStateControl" Name="windows_exporter" Remove="uninstall" Start="install" Stop="both"/>
|
<ServiceControl Id="StartService" Name="windows_exporter" Start="install" Wait="no" />
|
||||||
<!-- The "Name" field must match the argument to eventlog.Open() -->
|
<ServiceControl Id="StopService" Name="windows_exporter" Remove="uninstall" Stop="both" Wait="yes" />
|
||||||
<util:EventSource Log="Application" Name="windows_exporter"
|
|
||||||
EventMessageFile="%SystemRoot%\System32\EventCreate.exe"
|
|
||||||
SupportsErrors="yes"
|
|
||||||
SupportsInformationals="yes"
|
|
||||||
SupportsWarnings="yes"/>
|
|
||||||
</Component>
|
</Component>
|
||||||
<Component Id="CreateTextfileDirectory" Directory="textfile_inputs" Guid="d03ef58a-9cbf-4165-ad39-d143e9b27e14">
|
<Component Id="CreateTextfileDirectory" Directory="textfile_inputs" Guid="d03ef58a-9cbf-4165-ad39-d143e9b27e14">
|
||||||
<CreateFolder />
|
<CreateFolder />
|
||||||
|
|||||||
@@ -45,6 +45,40 @@
|
|||||||
Property="OLDERVERSIONBEINGUPGRADED" />
|
Property="OLDERVERSIONBEINGUPGRADED" />
|
||||||
</Upgrade>
|
</Upgrade>
|
||||||
|
|
||||||
|
<Media Id="1" Cabinet="windows_exporter.cab" EmbedCab="yes" />
|
||||||
|
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." AllowSameVersionUpgrades="yes" />
|
||||||
|
|
||||||
|
<Property Id="ENABLED_COLLECTORS" Secure="yes" />
|
||||||
|
<SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]" Condition="ENABLED_COLLECTORS" />
|
||||||
|
|
||||||
|
<Property Id="EXTRA_FLAGS" Secure="yes" />
|
||||||
|
<SetProperty Id="ExtraFlags" After="InstallFiles" Sequence="execute" Value="[EXTRA_FLAGS]" Condition="EXTRA_FLAGS" />
|
||||||
|
|
||||||
|
<Property Id="CONFIG_FILE" Secure="yes" Value="config.yaml" />
|
||||||
|
<SetProperty Id="ConfigFile_NonDefault" After="InstallFiles" Sequence="execute" Value="[CONFIG_FILE]" Condition="CONFIG_FILE AND CONFIG_FILE<>"config.yaml"" />
|
||||||
|
<SetProperty Id="ConfigFile_Default" After="InstallFiles" Sequence="execute" Value="[APPLICATIONFOLDER]config.yaml" Condition="CONFIG_FILE="config.yaml"" />
|
||||||
|
<SetProperty Id="ConfigFileFlag" After="InstallFiles" Sequence="execute" Value="--config.file="[ConfigFile_NonDefault][ConfigFile_Default]"" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
|
||||||
|
|
||||||
|
<Property Id="LISTEN_PORT" Secure="yes" Value="9182" />
|
||||||
|
<SetProperty Id="ListenFlag" After="InstallFiles" Sequence="execute" Value="--web.listen-address="[LISTEN_ADDR]:[LISTEN_PORT]"" Condition="LISTEN_ADDR<>"" OR LISTEN_PORT<>9182" />
|
||||||
|
|
||||||
|
<Property Id="METRICS_PATH" Secure="yes" />
|
||||||
|
<SetProperty Id="MetricsPathFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.path="[METRICS_PATH]"" Condition="METRICS_PATH" />
|
||||||
|
|
||||||
|
<Property Id="REMOTE_ADDR" Secure="yes" />
|
||||||
|
<SetProperty Id="RemoteAddressFlag" After="InstallFiles" Sequence="execute" Value="[REMOTE_ADDR]" Condition="REMOTE_ADDR" />
|
||||||
|
|
||||||
|
<Property Id="TEXTFILE_DIRS" Secure="yes" />
|
||||||
|
<SetProperty Id="TextfileDirsFlag" After="InstallFiles" Sequence="execute" Value="--collector.textfile.directories="[TEXTFILE_DIRS]"" Condition="TEXTFILE_DIRS" />
|
||||||
|
|
||||||
|
<Property Id="ARPHELPLINK" Value="https://github.com/prometheus-community/windows_exporter/issues" />
|
||||||
|
<Property Id="ARPSIZE" Value="9000" />
|
||||||
|
<Property Id="ARPURLINFOABOUT" Value="https://github.com/prometheus-community/windows_exporter" />
|
||||||
|
<!--<Property Id="ARPNOMODIFY" Value="0" />-->
|
||||||
|
<!--<Property Id="ARPNOREPAIR" Value="1" />-->
|
||||||
|
<Property Id="START_MENU_FOLDER" Value="0" />
|
||||||
|
<Property Id="NOSTART" Value="0" />
|
||||||
|
|
||||||
<CustomAction Id="CheckExtraFlags"
|
<CustomAction Id="CheckExtraFlags"
|
||||||
Error="The parameter '--config.file' must not be included in EXTRA_FLAGS. Use CONFIG_FILE instead. Please remove it and try again." />
|
Error="The parameter '--config.file' must not be included in EXTRA_FLAGS. Use CONFIG_FILE instead. Please remove it and try again." />
|
||||||
|
|
||||||
@@ -100,47 +134,13 @@
|
|||||||
Condition="Installed AND (NOT REMOVE) AND (NOT UPGRADINGPRODUCTCODE)"/>
|
Condition="Installed AND (NOT REMOVE) AND (NOT UPGRADINGPRODUCTCODE)"/>
|
||||||
<Custom Action="set_reinstall_all_property" Before="set_reinstallmode_property" Condition="MAINTENANCE"/>
|
<Custom Action="set_reinstall_all_property" Before="set_reinstallmode_property" Condition="MAINTENANCE"/>
|
||||||
<Custom Action="set_reinstallmode_property" Before="LaunchConditions" Condition="MAINTENANCE"/>
|
<Custom Action="set_reinstallmode_property" Before="LaunchConditions" Condition="MAINTENANCE"/>
|
||||||
<Custom Action="CreateConfigFile" Before="InstallServices" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
|
<Custom Action="CreateConfigFile" Before="InstallServices" Condition="ConfigFile_Default" />
|
||||||
<Custom Action="KillProcess" Before="RemoveFiles" />
|
<Custom Action="KillProcess" Before="RemoveFiles" />
|
||||||
|
|
||||||
<Custom Action="CheckExtraFlags" Before="InstallInitialize"
|
<Custom Action="CheckExtraFlags" Before="InstallInitialize"
|
||||||
Condition="EXTRA_FLAGS AND (EXTRA_FLAGS><"--config.file")" />
|
Condition="EXTRA_FLAGS AND (EXTRA_FLAGS><"--config.file")" />
|
||||||
</InstallExecuteSequence>
|
</InstallExecuteSequence>
|
||||||
|
|
||||||
<Media Id="1" Cabinet="windows_exporter.cab" EmbedCab="yes" />
|
|
||||||
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." AllowSameVersionUpgrades="yes" />
|
|
||||||
|
|
||||||
<Property Id="ENABLED_COLLECTORS" Secure="yes" />
|
|
||||||
<SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]" Condition="ENABLED_COLLECTORS" />
|
|
||||||
|
|
||||||
<Property Id="EXTRA_FLAGS" Secure="yes" />
|
|
||||||
<SetProperty Id="ExtraFlags" After="InstallFiles" Sequence="execute" Value="[EXTRA_FLAGS]" Condition="EXTRA_FLAGS" />
|
|
||||||
|
|
||||||
<Property Id="CONFIG_FILE" Secure="yes" Value="config.yaml" />
|
|
||||||
<SetProperty Id="ConfigFile_NonDefault" After="InstallFiles" Sequence="execute" Value="[CONFIG_FILE]" Condition="CONFIG_FILE AND CONFIG_FILE<>"config.yaml"" />
|
|
||||||
<SetProperty Id="ConfigFile_Default" After="InstallFiles" Sequence="execute" Value="[APPLICATIONFOLDER]config.yaml" Condition="CONFIG_FILE="config.yaml"" />
|
|
||||||
<SetProperty Id="ConfigFileFlag" After="InstallFiles" Sequence="execute" Value="--config.file="[ConfigFile_NonDefault][ConfigFile_Default]"" Condition="ConfigFile_NonDefault OR ConfigFile_Default" />
|
|
||||||
|
|
||||||
<Property Id="LISTEN_PORT" Secure="yes" Value="9182" />
|
|
||||||
<SetProperty Id="ListenFlag" After="InstallFiles" Sequence="execute" Value="--web.listen-address [LISTEN_ADDR]:[LISTEN_PORT]" Condition="LISTEN_ADDR<>"" OR LISTEN_PORT<>9182" />
|
|
||||||
|
|
||||||
<Property Id="METRICS_PATH" Secure="yes" />
|
|
||||||
<SetProperty Id="MetricsPathFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.path [METRICS_PATH]" Condition="METRICS_PATH" />
|
|
||||||
|
|
||||||
<Property Id="REMOTE_ADDR" Secure="yes" />
|
|
||||||
<SetProperty Id="RemoteAddressFlag" After="InstallFiles" Sequence="execute" Value="[REMOTE_ADDR]" Condition="REMOTE_ADDR" />
|
|
||||||
|
|
||||||
<Property Id="TEXTFILE_DIRS" Secure="yes" />
|
|
||||||
<SetProperty Id="TextfileDirsFlag" After="InstallFiles" Sequence="execute" Value="--collector.textfile.directories [TEXTFILE_DIRS]" Condition="TEXTFILE_DIRS" />
|
|
||||||
|
|
||||||
<Property Id="ARPHELPLINK" Value="https://github.com/prometheus-community/windows_exporter/issues" />
|
|
||||||
<Property Id="ARPSIZE" Value="9000" />
|
|
||||||
<Property Id="ARPURLINFOABOUT" Value="https://github.com/prometheus-community/windows_exporter" />
|
|
||||||
<!--<Property Id="ARPNOMODIFY" Value="0" />-->
|
|
||||||
<!--<Property Id="ARPNOREPAIR" Value="1" />-->
|
|
||||||
<Property Id="START_MENU_FOLDER" Value="0" />
|
|
||||||
<Property Id="NOSTART" Value="0" />
|
|
||||||
|
|
||||||
<Feature
|
<Feature
|
||||||
Id="DefaultFeature"
|
Id="DefaultFeature"
|
||||||
Level="1"
|
Level="1"
|
||||||
@@ -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" />
|
<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 -->
|
<!-- 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_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_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" />
|
<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)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", err)
|
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(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
@@ -530,30 +532,35 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].AbANRPerSec,
|
c.perfDataObject[0].AbANRPerSec,
|
||||||
"ambiguous_name_resolution",
|
"ambiguous_name_resolution",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].AbBrowsesPerSec,
|
c.perfDataObject[0].AbBrowsesPerSec,
|
||||||
"browse",
|
"browse",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].AbMatchesPerSec,
|
c.perfDataObject[0].AbMatchesPerSec,
|
||||||
"find",
|
"find",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].AbPropertyReadsPerSec,
|
c.perfDataObject[0].AbPropertyReadsPerSec,
|
||||||
"property_read",
|
"property_read",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].AbSearchesPerSec,
|
c.perfDataObject[0].AbSearchesPerSec,
|
||||||
"search",
|
"search",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -578,22 +585,26 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].AtqEstimatedQueueDelay/1000,
|
c.perfDataObject[0].AtqEstimatedQueueDelay/1000,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqOutstandingRequests,
|
c.atqOutstandingRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].AtqOutstandingQueuedRequests,
|
c.perfDataObject[0].AtqOutstandingQueuedRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqAverageRequestLatency,
|
c.atqAverageRequestLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].AtqRequestLatency,
|
c.perfDataObject[0].AtqRequestLatency,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqCurrentThreads,
|
c.atqCurrentThreads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].AtqThreadsLDAP,
|
c.perfDataObject[0].AtqThreadsLDAP,
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqCurrentThreads,
|
c.atqCurrentThreads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -607,12 +618,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].BaseSearchesPerSec,
|
c.perfDataObject[0].BaseSearchesPerSec,
|
||||||
"base",
|
"base",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.searchesTotal,
|
c.searchesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SubtreeSearchesPerSec,
|
c.perfDataObject[0].SubtreeSearchesPerSec,
|
||||||
"subtree",
|
"subtree",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.searchesTotal,
|
c.searchesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -626,18 +639,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].DatabaseAddsPerSec,
|
c.perfDataObject[0].DatabaseAddsPerSec,
|
||||||
"add",
|
"add",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databaseOperationsTotal,
|
c.databaseOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DatabaseDeletesPerSec,
|
c.perfDataObject[0].DatabaseDeletesPerSec,
|
||||||
"delete",
|
"delete",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databaseOperationsTotal,
|
c.databaseOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DatabaseModifiesPerSec,
|
c.perfDataObject[0].DatabaseModifiesPerSec,
|
||||||
"modify",
|
"modify",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databaseOperationsTotal,
|
c.databaseOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -651,48 +667,56 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].DigestBindsPerSec,
|
c.perfDataObject[0].DigestBindsPerSec,
|
||||||
"digest",
|
"digest",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DsClientBindsPerSec,
|
c.perfDataObject[0].DsClientBindsPerSec,
|
||||||
"ds_client",
|
"ds_client",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DsServerBindsPerSec,
|
c.perfDataObject[0].DsServerBindsPerSec,
|
||||||
"ds_server",
|
"ds_server",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].ExternalBindsPerSec,
|
c.perfDataObject[0].ExternalBindsPerSec,
|
||||||
"external",
|
"external",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].FastBindsPerSec,
|
c.perfDataObject[0].FastBindsPerSec,
|
||||||
"fast",
|
"fast",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].NegotiatedBindsPerSec,
|
c.perfDataObject[0].NegotiatedBindsPerSec,
|
||||||
"negotiate",
|
"negotiate",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].NTLMBindsPerSec,
|
c.perfDataObject[0].NTLMBindsPerSec,
|
||||||
"ntlm",
|
"ntlm",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SimpleBindsPerSec,
|
c.perfDataObject[0].SimpleBindsPerSec,
|
||||||
"simple",
|
"simple",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
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,
|
float64(uint64(c.perfDataObject[0].DRAHighestUSNCommittedHighPart)<<32)+c.perfDataObject[0].DRAHighestUSNCommittedLowPart,
|
||||||
"committed",
|
"committed",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationHighestUsn,
|
c.replicationHighestUsn,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -744,6 +769,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].DRAInboundBytesNotCompressedWithinSitePerSec,
|
c.perfDataObject[0].DRAInboundBytesNotCompressedWithinSitePerSec,
|
||||||
"inbound",
|
"inbound",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.intraSiteReplicationDataBytesTotal,
|
c.intraSiteReplicationDataBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -768,6 +794,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DRAInboundObjectsAppliedPerSec,
|
c.perfDataObject[0].DRAInboundObjectsAppliedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundObjectsFilteredTotal,
|
c.replicationInboundObjectsFilteredTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -779,6 +806,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DRAInboundPropertiesAppliedPerSec,
|
c.perfDataObject[0].DRAInboundPropertiesAppliedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundPropertiesFilteredTotal,
|
c.replicationInboundPropertiesFilteredTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -790,6 +818,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].DRAPendingReplicationOperations,
|
c.perfDataObject[0].DRAPendingReplicationOperations,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationPendingSynchronizations,
|
c.replicationPendingSynchronizations,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -801,11 +830,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DRASyncRequestsMade,
|
c.perfDataObject[0].DRASyncRequestsMade,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationSyncRequestsSuccessTotal,
|
c.replicationSyncRequestsSuccessTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DRASyncRequestsSuccessful,
|
c.perfDataObject[0].DRASyncRequestsSuccessful,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationSyncRequestsSchemaMismatchFailureTotal,
|
c.replicationSyncRequestsSchemaMismatchFailureTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -818,6 +849,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].DsClientNameTranslationsPerSec,
|
c.perfDataObject[0].DsClientNameTranslationsPerSec,
|
||||||
"client",
|
"client",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.nameTranslationsTotal,
|
c.nameTranslationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -830,6 +862,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].DsMonitorListSize,
|
c.perfDataObject[0].DsMonitorListSize,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.changeMonitorUpdatesPending,
|
c.changeMonitorUpdatesPending,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -841,6 +874,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DsNameCacheHitRate,
|
c.perfDataObject[0].DsNameCacheHitRate,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.nameCacheLookupsTotal,
|
c.nameCacheLookupsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -854,6 +888,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"read",
|
"read",
|
||||||
"replication_agent",
|
"replication_agent",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -861,6 +896,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"read",
|
"read",
|
||||||
"knowledge_consistency_checker",
|
"knowledge_consistency_checker",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -868,6 +904,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"read",
|
"read",
|
||||||
"local_security_authority",
|
"local_security_authority",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -875,6 +912,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"read",
|
"read",
|
||||||
"name_service_provider_interface",
|
"name_service_provider_interface",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -882,6 +920,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"read",
|
"read",
|
||||||
"directory_service_api",
|
"directory_service_api",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -889,6 +928,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"read",
|
"read",
|
||||||
"security_account_manager",
|
"security_account_manager",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -896,6 +936,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"read",
|
"read",
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -903,6 +944,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"replication_agent",
|
"replication_agent",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -910,6 +952,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"knowledge_consistency_checker",
|
"knowledge_consistency_checker",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -917,6 +960,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -924,6 +968,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"local_security_authority",
|
"local_security_authority",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -931,6 +976,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"name_service_provider_interface",
|
"name_service_provider_interface",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -938,6 +984,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"directory_service_api",
|
"directory_service_api",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -945,6 +992,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"security_account_manager",
|
"security_account_manager",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -952,6 +1000,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"search",
|
"search",
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -959,6 +1008,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"write",
|
"write",
|
||||||
"replication_agent",
|
"replication_agent",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -966,6 +1016,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"write",
|
"write",
|
||||||
"knowledge_consistency_checker",
|
"knowledge_consistency_checker",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -973,6 +1024,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"write",
|
"write",
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -980,6 +1032,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"write",
|
"write",
|
||||||
"local_security_authority",
|
"local_security_authority",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -987,6 +1040,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"write",
|
"write",
|
||||||
"name_service_provider_interface",
|
"name_service_provider_interface",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -994,6 +1048,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"write",
|
"write",
|
||||||
"directory_service_api",
|
"directory_service_api",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1001,6 +1056,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
"write",
|
"write",
|
||||||
"security_account_manager",
|
"security_account_manager",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1020,16 +1076,19 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DsSecurityDescriptorSubOperationsPerSec,
|
c.perfDataObject[0].DsSecurityDescriptorSubOperationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.securityDescriptorPropagationEventsQueued,
|
c.securityDescriptorPropagationEventsQueued,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].DsSecurityDescriptorPropagationsEvents,
|
c.perfDataObject[0].DsSecurityDescriptorPropagationsEvents,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.securityDescriptorPropagationAccessWaitTotalSeconds,
|
c.securityDescriptorPropagationAccessWaitTotalSeconds,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].DsSecurityDescriptorPropagatorAverageExclusionTime,
|
c.perfDataObject[0].DsSecurityDescriptorPropagatorAverageExclusionTime,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.securityDescriptorPropagationItemsQueuedTotal,
|
c.securityDescriptorPropagationItemsQueuedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1047,12 +1106,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].LdapClosedConnectionsPerSec,
|
c.perfDataObject[0].LdapClosedConnectionsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapOpenedConnectionsTotal,
|
c.ldapOpenedConnectionsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].LdapNewConnectionsPerSec,
|
c.perfDataObject[0].LdapNewConnectionsPerSec,
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapOpenedConnectionsTotal,
|
c.ldapOpenedConnectionsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1083,11 +1144,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].LdapUDPOperationsPerSec,
|
c.perfDataObject[0].LdapUDPOperationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapWritesTotal,
|
c.ldapWritesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].LdapWritesPerSec,
|
c.perfDataObject[0].LdapWritesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapClientSessions,
|
c.ldapClientSessions,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -1105,6 +1168,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].PhantomsCleanedPerSec,
|
c.perfDataObject[0].PhantomsCleanedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.phantomObjectsVisitedTotal,
|
c.phantomObjectsVisitedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1117,18 +1181,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].SamGlobalGroupMembershipEvaluationsPerSec,
|
c.perfDataObject[0].SamGlobalGroupMembershipEvaluationsPerSec,
|
||||||
"global",
|
"global",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsTotal,
|
c.samGroupMembershipEvaluationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SamDomainLocalGroupMembershipEvaluationsPerSec,
|
c.perfDataObject[0].SamDomainLocalGroupMembershipEvaluationsPerSec,
|
||||||
"domain_local",
|
"domain_local",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsTotal,
|
c.samGroupMembershipEvaluationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SamUniversalGroupMembershipEvaluationsPerSec,
|
c.perfDataObject[0].SamUniversalGroupMembershipEvaluationsPerSec,
|
||||||
"universal",
|
"universal",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipGlobalCatalogEvaluationsTotal,
|
c.samGroupMembershipGlobalCatalogEvaluationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1140,6 +1207,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SamNonTransitiveMembershipEvaluationsPerSec,
|
c.perfDataObject[0].SamNonTransitiveMembershipEvaluationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsTransitiveTotal,
|
c.samGroupMembershipEvaluationsTransitiveTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1152,6 +1220,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].SamAccountGroupEvaluationLatency,
|
c.perfDataObject[0].SamAccountGroupEvaluationLatency,
|
||||||
"account_group",
|
"account_group",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupEvaluationLatency,
|
c.samGroupEvaluationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -1164,6 +1233,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SamSuccessfulComputerCreationsPerSecIncludesAllRequests,
|
c.perfDataObject[0].SamSuccessfulComputerCreationsPerSecIncludesAllRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samComputerCreationSuccessfulRequestsTotal,
|
c.samComputerCreationSuccessfulRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1175,6 +1245,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SamUserCreationAttemptsPerSec,
|
c.perfDataObject[0].SamUserCreationAttemptsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samUserCreationSuccessfulRequestsTotal,
|
c.samUserCreationSuccessfulRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1186,6 +1257,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SamDisplayInformationQueriesPerSec,
|
c.perfDataObject[0].SamDisplayInformationQueriesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samEnumerationsTotal,
|
c.samEnumerationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -1209,6 +1281,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].TombstonesGarbageCollectedPerSec,
|
c.perfDataObject[0].TombstonesGarbageCollectedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.tombstonesObjectsVisitedTotal,
|
c.tombstonesObjectsVisitedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -186,72 +186,84 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
data.RequestsPerSecond,
|
data.RequestsPerSecond,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestProcessingTime,
|
c.requestProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.RequestProcessingTime),
|
utils.MilliSecToSec(data.RequestProcessingTime),
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retrievalsPerSecond,
|
c.retrievalsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.RetrievalsPerSecond,
|
data.RetrievalsPerSecond,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retrievalProcessingTime,
|
c.retrievalProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.RetrievalProcessingTime),
|
utils.MilliSecToSec(data.RetrievalProcessingTime),
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failedRequestsPerSecond,
|
c.failedRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.FailedRequestsPerSecond,
|
data.FailedRequestsPerSecond,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.issuedRequestsPerSecond,
|
c.issuedRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.IssuedRequestsPerSecond,
|
data.IssuedRequestsPerSecond,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pendingRequestsPerSecond,
|
c.pendingRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PendingRequestsPerSecond,
|
data.PendingRequestsPerSecond,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestCryptographicSigningTime,
|
c.requestCryptographicSigningTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.RequestCryptographicSigningTime),
|
utils.MilliSecToSec(data.RequestCryptographicSigningTime),
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestPolicyModuleProcessingTime,
|
c.requestPolicyModuleProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.RequestPolicyModuleProcessingTime),
|
utils.MilliSecToSec(data.RequestPolicyModuleProcessingTime),
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.challengeResponsesPerSecond,
|
c.challengeResponsesPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ChallengeResponsesPerSecond,
|
data.ChallengeResponsesPerSecond,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.challengeResponseProcessingTime,
|
c.challengeResponseProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.ChallengeResponseProcessingTime),
|
utils.MilliSecToSec(data.ChallengeResponseProcessingTime),
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.signedCertificateTimestampListsPerSecond,
|
c.signedCertificateTimestampListsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.SignedCertificateTimestampListsPerSecond,
|
data.SignedCertificateTimestampListsPerSecond,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.signedCertificateTimestampListProcessingTime,
|
c.signedCertificateTimestampListProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -387,6 +387,8 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect ADFS metrics: %w", err)
|
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(
|
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)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Cache metrics: %w", err)
|
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(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
|||||||
@@ -29,10 +29,8 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/hcn"
|
"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/hcs"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/iphlpapi"
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/kernel32"
|
"github.com/prometheus-community/windows_exporter/internal/headers/kernel32"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
@@ -437,6 +435,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
1,
|
1,
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "false",
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "false",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.usageCommitBytes,
|
c.usageCommitBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -444,6 +443,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.usageCommitPeakBytes,
|
c.usageCommitPeakBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -451,6 +451,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.usagePrivateWorkingSetBytes,
|
c.usagePrivateWorkingSetBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -458,6 +459,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeTotal,
|
c.runtimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -465,6 +467,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeUser,
|
c.runtimeUser,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -472,6 +475,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeKernel,
|
c.runtimeKernel,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -479,6 +483,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readCountNormalized,
|
c.readCountNormalized,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -486,6 +491,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readSizeBytes,
|
c.readSizeBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -493,6 +499,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeCountNormalized,
|
c.writeCountNormalized,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -500,6 +507,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeSizeBytes,
|
c.writeSizeBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -513,7 +521,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe
|
|||||||
|
|
||||||
// collectNetworkMetrics collects network metrics for containers.
|
// collectNetworkMetrics collects network metrics for containers.
|
||||||
func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error {
|
||||||
endpoints, err := hcn.EnumerateEndpoints()
|
endpoints, err := hcn.ListEndpoints()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error in fetching HCN endpoints: %w", err)
|
return fmt.Errorf("error in fetching HCN endpoints: %w", err)
|
||||||
}
|
}
|
||||||
@@ -523,56 +531,24 @@ func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, endpoint := range endpoints {
|
for _, endpoint := range endpoints {
|
||||||
properties, err := hcn.GetEndpointProperties(endpoint)
|
if len(endpoint.SharedContainers) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
endpointStats, err := hcn.GetHNSEndpointStats(endpoint.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Warn("Failed to collect properties for interface "+endpoint.String(),
|
c.logger.Warn("Failed to collect network stats for interface "+endpoint.ID,
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(properties.SharedContainers) == 0 {
|
for _, containerId := range endpoint.SharedContainers {
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var nicGUID *guid.GUID
|
|
||||||
|
|
||||||
for _, allocator := range properties.Resources.Allocators {
|
|
||||||
if allocator.AdapterNetCfgInstanceId != nil {
|
|
||||||
nicGUID = allocator.AdapterNetCfgInstanceId
|
|
||||||
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if nicGUID == nil {
|
|
||||||
c.logger.Warn("Failed to get nic GUID for endpoint " + endpoint.String())
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
luid, err := iphlpapi.ConvertInterfaceGUIDToLUID(*nicGUID)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error in converting interface GUID to LUID: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var endpointStats iphlpapi.MIB_IF_ROW2
|
|
||||||
endpointStats.InterfaceLuid = luid
|
|
||||||
|
|
||||||
if err := iphlpapi.GetIfEntry2Ex(&endpointStats); err != nil {
|
|
||||||
c.logger.Warn("Failed to get interface entry for endpoint "+endpoint.String(),
|
|
||||||
slog.Any("err", err),
|
|
||||||
)
|
|
||||||
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, containerId := range properties.SharedContainers {
|
|
||||||
containerInfo, ok := c.annotationsCacheHCS[containerId]
|
containerInfo, ok := c.annotationsCacheHCS[containerId]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
c.logger.Debug("Unknown container " + containerId + " for endpoint " + endpoint.String())
|
c.logger.Debug("Unknown container " + containerId + " for endpoint " + endpoint.ID)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -582,43 +558,47 @@ func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
endpointId := strings.ToUpper(endpoint.String())
|
endpointId := strings.ToUpper(endpoint.ID)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bytesReceived,
|
c.bytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(endpointStats.InOctets),
|
float64(endpointStats.BytesReceived),
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bytesSent,
|
c.bytesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(endpointStats.OutOctets),
|
float64(endpointStats.BytesSent),
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsReceived,
|
c.packetsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(endpointStats.InUcastPkts+endpointStats.InNUcastPkts),
|
float64(endpointStats.PacketsReceived),
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsSent,
|
c.packetsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(endpointStats.OutUcastPkts+endpointStats.OutNUcastPkts),
|
float64(endpointStats.PacketsSent),
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.droppedPacketsIncoming,
|
c.droppedPacketsIncoming,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(endpointStats.InDiscards+endpointStats.InErrors),
|
float64(endpointStats.DroppedPacketsIncoming),
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.droppedPacketsOutgoing,
|
c.droppedPacketsOutgoing,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(endpointStats.OutDiscards+endpointStats.OutErrors),
|
float64(endpointStats.DroppedPacketsOutgoing),
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -768,6 +748,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
1,
|
1,
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "true",
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "true",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.usageCommitBytes,
|
c.usageCommitBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -775,6 +756,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.usageCommitPeakBytes,
|
c.usageCommitPeakBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -782,6 +764,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.usagePrivateWorkingSetBytes,
|
c.usagePrivateWorkingSetBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -789,6 +772,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeTotal,
|
c.runtimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -796,6 +780,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeUser,
|
c.runtimeUser,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -803,6 +788,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeKernel,
|
c.runtimeKernel,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -810,6 +796,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readCountNormalized,
|
c.readCountNormalized,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -817,6 +804,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readSizeBytes,
|
c.readSizeBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -824,6 +812,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeCountNormalized,
|
c.writeCountNormalized,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -831,6 +820,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID
|
|||||||
|
|
||||||
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeSizeBytes,
|
c.writeSizeBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -234,12 +234,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
coreData.C1TimeSeconds,
|
coreData.C1TimeSeconds,
|
||||||
core, "c1",
|
core, "c1",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.C2TimeSeconds,
|
coreData.C2TimeSeconds,
|
||||||
core, "c2",
|
core, "c2",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -253,24 +255,28 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
coreData.IdleTimeSeconds,
|
coreData.IdleTimeSeconds,
|
||||||
core, "idle",
|
core, "idle",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.InterruptTimeSeconds,
|
coreData.InterruptTimeSeconds,
|
||||||
core, "interrupt",
|
core, "interrupt",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.DpcTimeSeconds,
|
coreData.DpcTimeSeconds,
|
||||||
core, "dpc",
|
core, "dpc",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.PrivilegedTimeSeconds,
|
coreData.PrivilegedTimeSeconds,
|
||||||
core, "privileged",
|
core, "privileged",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -284,18 +290,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
coreData.InterruptsTotal,
|
coreData.InterruptsTotal,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dpcsTotal,
|
c.dpcsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.DpcQueuedPerSecond,
|
coreData.DpcQueuedPerSecond,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.clockInterruptsTotal,
|
c.clockInterruptsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.ClockInterruptsTotal,
|
coreData.ClockInterruptsTotal,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.idleBreakEventsTotal,
|
c.idleBreakEventsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -316,30 +325,35 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
coreData.ProcessorFrequencyMHz,
|
coreData.ProcessorFrequencyMHz,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorPerformance,
|
c.processorPerformance,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.ProcessorPerformance,
|
coreData.ProcessorPerformance,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorMPerf,
|
c.processorMPerf,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
counterProcessorMPerfValues.Value(),
|
counterProcessorMPerfValues.Value(),
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorRTC,
|
c.processorRTC,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
counterProcessorRTCValues.Value(),
|
counterProcessorRTCValues.Value(),
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorUtility,
|
c.processorUtility,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData.ProcessorUtilityRate,
|
coreData.ProcessorUtilityRate,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorPrivilegedUtility,
|
c.processorPrivilegedUtility,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -194,36 +194,42 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
strconv.Itoa(int(processor.Family)),
|
strconv.Itoa(int(processor.Family)),
|
||||||
strings.TrimRight(processor.Name, " "),
|
strings.TrimRight(processor.Name, " "),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cpuCoreCount,
|
c.cpuCoreCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(processor.NumberOfCores),
|
float64(processor.NumberOfCores),
|
||||||
strings.TrimRight(processor.DeviceID, " "),
|
strings.TrimRight(processor.DeviceID, " "),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cpuEnabledCoreCount,
|
c.cpuEnabledCoreCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(processor.NumberOfEnabledCore),
|
float64(processor.NumberOfEnabledCore),
|
||||||
strings.TrimRight(processor.DeviceID, " "),
|
strings.TrimRight(processor.DeviceID, " "),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cpuLogicalProcessorsCount,
|
c.cpuLogicalProcessorsCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(processor.NumberOfLogicalProcessors),
|
float64(processor.NumberOfLogicalProcessors),
|
||||||
strings.TrimRight(processor.DeviceID, " "),
|
strings.TrimRight(processor.DeviceID, " "),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cpuThreadCount,
|
c.cpuThreadCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(processor.ThreadCount),
|
float64(processor.ThreadCount),
|
||||||
strings.TrimRight(processor.DeviceID, " "),
|
strings.TrimRight(processor.DeviceID, " "),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cpuL2CacheSize,
|
c.cpuL2CacheSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(processor.L2CacheSize),
|
float64(processor.L2CacheSize),
|
||||||
strings.TrimRight(processor.DeviceID, " "),
|
strings.TrimRight(processor.DeviceID, " "),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cpuL3CacheSize,
|
c.cpuL3CacheSize,
|
||||||
prometheus.GaugeValue,
|
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
|
|
||||||
}
|
|
||||||
@@ -56,6 +56,8 @@ var ConfigDefaults = Config{
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
|
logger *slog.Logger
|
||||||
|
|
||||||
perfDataCollector *pdh.Collector
|
perfDataCollector *pdh.Collector
|
||||||
perfDataObject []perfDataCounterValues
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
@@ -147,7 +149,9 @@ func (c *Collector) Close() error {
|
|||||||
return nil
|
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
|
var err error
|
||||||
|
|
||||||
if slices.Contains(c.config.CollectorsEnabled, subCollectorScopeMetrics) {
|
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)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
|
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(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ var ConfigDefaults = Config{}
|
|||||||
|
|
||||||
// A Collector is a Prometheus Collector for a few WMI metrics in Win32_DiskDrive.
|
// A Collector is a Prometheus Collector for a few WMI metrics in Win32_DiskDrive.
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
logger *slog.Logger
|
||||||
|
|
||||||
miSession *mi.Session
|
miSession *mi.Session
|
||||||
miQuery mi.Query
|
miQuery mi.Query
|
||||||
|
|
||||||
@@ -73,7 +75,9 @@ func (c *Collector) Close() error {
|
|||||||
return nil
|
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(
|
c.diskInfo = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||||
"General drive information",
|
"General drive information",
|
||||||
@@ -148,7 +152,7 @@ var (
|
|||||||
"Error",
|
"Error",
|
||||||
"Degraded",
|
"Degraded",
|
||||||
"Unknown",
|
"Unknown",
|
||||||
"Pred fail",
|
"Pred Fail",
|
||||||
"Starting",
|
"Starting",
|
||||||
"Stopping",
|
"Stopping",
|
||||||
"Service",
|
"Service",
|
||||||
@@ -241,6 +245,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
if availNum == int(disk.Availability) {
|
if availNum == int(disk.Availability) {
|
||||||
isCurrentState = 1.0
|
isCurrentState = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availability,
|
c.availability,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -347,6 +347,8 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DNS metrics: %w", err)
|
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(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
@@ -355,6 +357,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].AxfrRequestReceived,
|
c.perfDataObject[0].AxfrRequestReceived,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsReceived,
|
c.zoneTransferRequestsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -368,12 +371,14 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].AxfrRequestSent,
|
c.perfDataObject[0].AxfrRequestSent,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsSent,
|
c.zoneTransferRequestsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].IxfrRequestSent,
|
c.perfDataObject[0].IxfrRequestSent,
|
||||||
"incremental",
|
"incremental",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsSent,
|
c.zoneTransferRequestsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -387,6 +392,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].AxfrResponseReceived,
|
c.perfDataObject[0].AxfrResponseReceived,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferResponsesReceived,
|
c.zoneTransferResponsesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -401,6 +407,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
"full",
|
"full",
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessReceived,
|
c.zoneTransferSuccessReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -408,6 +415,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
"incremental",
|
"incremental",
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessReceived,
|
c.zoneTransferSuccessReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -422,6 +430,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].AxfrSuccessSent,
|
c.perfDataObject[0].AxfrSuccessSent,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessSent,
|
c.zoneTransferSuccessSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -441,30 +450,35 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].CachingMemory,
|
c.perfDataObject[0].CachingMemory,
|
||||||
"caching",
|
"caching",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].DatabaseNodeMemory,
|
c.perfDataObject[0].DatabaseNodeMemory,
|
||||||
"database_node",
|
"database_node",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].NbStatMemory,
|
c.perfDataObject[0].NbStatMemory,
|
||||||
"nbstat",
|
"nbstat",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].RecordFlowMemory,
|
c.perfDataObject[0].RecordFlowMemory,
|
||||||
"record_flow",
|
"record_flow",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].TcpMessageMemory,
|
c.perfDataObject[0].TcpMessageMemory,
|
||||||
"tcp_message",
|
"tcp_message",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -478,23 +492,27 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].DynamicUpdateNoOperation,
|
c.perfDataObject[0].DynamicUpdateNoOperation,
|
||||||
"noop",
|
"noop",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesReceived,
|
c.dynamicUpdatesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DynamicUpdateWrittenToDatabase,
|
c.perfDataObject[0].DynamicUpdateWrittenToDatabase,
|
||||||
"written",
|
"written",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesQueued,
|
c.dynamicUpdatesQueued,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].DynamicUpdateQueued,
|
c.perfDataObject[0].DynamicUpdateQueued,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesFailures,
|
c.dynamicUpdatesFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].DynamicUpdateRejected,
|
c.perfDataObject[0].DynamicUpdateRejected,
|
||||||
"rejected",
|
"rejected",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesFailures,
|
c.dynamicUpdatesFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -507,6 +525,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].NotifyReceived,
|
c.perfDataObject[0].NotifyReceived,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.notifySent,
|
c.notifySent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -518,11 +537,13 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].RecursiveQueries,
|
c.perfDataObject[0].RecursiveQueries,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.recursiveQueryFailures,
|
c.recursiveQueryFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].RecursiveQueryFailure,
|
c.perfDataObject[0].RecursiveQueryFailure,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.recursiveQuerySendTimeouts,
|
c.recursiveQuerySendTimeouts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -535,6 +556,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].TcpQueryReceived,
|
c.perfDataObject[0].TcpQueryReceived,
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.queries,
|
c.queries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -548,6 +570,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].TcpResponseSent,
|
c.perfDataObject[0].TcpResponseSent,
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.responses,
|
c.responses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -567,6 +590,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].WinsLookupReceived,
|
c.perfDataObject[0].WinsLookupReceived,
|
||||||
"forward",
|
"forward",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.winsQueries,
|
c.winsQueries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -580,6 +604,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.perfDataObject[0].WinsResponseSent,
|
c.perfDataObject[0].WinsResponseSent,
|
||||||
"forward",
|
"forward",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.winsResponses,
|
c.winsResponses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -592,6 +617,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SecureUpdateFailure,
|
c.perfDataObject[0].SecureUpdateFailure,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.secureUpdateReceived,
|
c.secureUpdateReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -66,11 +66,6 @@ var ConfigDefaults = Config{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
|
||||||
|
|
||||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
|
||||||
closeFns []func()
|
|
||||||
|
|
||||||
collectorADAccessProcesses
|
collectorADAccessProcesses
|
||||||
collectorActiveSync
|
collectorActiveSync
|
||||||
collectorAutoDiscover
|
collectorAutoDiscover
|
||||||
@@ -81,6 +76,11 @@ type Collector struct {
|
|||||||
collectorRpcClientAccess
|
collectorRpcClientAccess
|
||||||
collectorTransportQueues
|
collectorTransportQueues
|
||||||
collectorWorkloadManagementWorkloads
|
collectorWorkloadManagementWorkloads
|
||||||
|
|
||||||
|
config Config
|
||||||
|
|
||||||
|
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||||
|
closeFns []func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
|
|||||||
@@ -82,11 +82,13 @@ func (c *Collector) collectActiveSync(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.RequestsPerSec,
|
data.RequestsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pingCommandsPending,
|
c.pingCommandsPending,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PingCommandsPending,
|
data.PingCommandsPending,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.syncCommandsPerSec,
|
c.syncCommandsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -113,24 +113,28 @@ func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error
|
|||||||
utils.MilliSecToSec(data.LdapReadTime),
|
utils.MilliSecToSec(data.LdapReadTime),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapSearchTime,
|
c.ldapSearchTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
utils.MilliSecToSec(data.LdapSearchTime),
|
utils.MilliSecToSec(data.LdapSearchTime),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapWriteTime,
|
c.ldapWriteTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
utils.MilliSecToSec(data.LdapWriteTime),
|
utils.MilliSecToSec(data.LdapWriteTime),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapTimeoutErrorsPerSec,
|
c.ldapTimeoutErrorsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.LdapTimeoutErrorsPerSec,
|
data.LdapTimeoutErrorsPerSec,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.longRunningLDAPOperationsPerMin,
|
c.longRunningLDAPOperationsPerMin,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -111,30 +111,35 @@ func (c *Collector) collectHTTPProxy(ch chan<- prometheus.Metric) error {
|
|||||||
utils.MilliSecToSec(data.MailboxServerLocatorAverageLatency),
|
utils.MilliSecToSec(data.MailboxServerLocatorAverageLatency),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.averageAuthenticationLatency,
|
c.averageAuthenticationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.AverageAuthenticationLatency,
|
data.AverageAuthenticationLatency,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.averageCASProcessingLatency,
|
c.averageCASProcessingLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.AverageCASProcessingLatency),
|
utils.MilliSecToSec(data.AverageCASProcessingLatency),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.mailboxServerProxyFailureRate,
|
c.mailboxServerProxyFailureRate,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.MailboxServerProxyFailureRate,
|
data.MailboxServerProxyFailureRate,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.outstandingProxyRequests,
|
c.outstandingProxyRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.OutstandingProxyRequests,
|
data.OutstandingProxyRequests,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.proxyRequestsPerSec,
|
c.proxyRequestsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ func (c *Collector) collectOWA(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.CurrentUniqueUsers,
|
data.CurrentUniqueUsers,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.owaRequestsPerSec,
|
c.owaRequestsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -107,26 +107,31 @@ func (c *Collector) collectRpcClientAccess(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.RpcAveragedLatency),
|
utils.MilliSecToSec(data.RpcAveragedLatency),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.rpcRequests,
|
c.rpcRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.RpcRequests,
|
data.RpcRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeUserCount,
|
c.activeUserCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ActiveUserCount,
|
data.ActiveUserCount,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionCount,
|
c.connectionCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ConnectionCount,
|
data.ConnectionCount,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.rpcOperationsPerSec,
|
c.rpcOperationsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.RpcOperationsPerSec,
|
data.RpcOperationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.userCount,
|
c.userCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -215,108 +215,126 @@ func (c *Collector) collectTransportQueues(ch chan<- prometheus.Metric) error {
|
|||||||
data.ExternalActiveRemoteDeliveryQueueLength,
|
data.ExternalActiveRemoteDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.internalActiveRemoteDeliveryQueueLength,
|
c.internalActiveRemoteDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.InternalActiveRemoteDeliveryQueueLength,
|
data.InternalActiveRemoteDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeMailboxDeliveryQueueLength,
|
c.activeMailboxDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ActiveMailboxDeliveryQueueLength,
|
data.ActiveMailboxDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retryMailboxDeliveryQueueLength,
|
c.retryMailboxDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.RetryMailboxDeliveryQueueLength,
|
data.RetryMailboxDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.unreachableQueueLength,
|
c.unreachableQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.UnreachableQueueLength,
|
data.UnreachableQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.externalLargestDeliveryQueueLength,
|
c.externalLargestDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ExternalLargestDeliveryQueueLength,
|
data.ExternalLargestDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.internalLargestDeliveryQueueLength,
|
c.internalLargestDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.InternalLargestDeliveryQueueLength,
|
data.InternalLargestDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poisonQueueLength,
|
c.poisonQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PoisonQueueLength,
|
data.PoisonQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesQueuedForDeliveryTotal,
|
c.messagesQueuedForDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.MessagesQueuedForDeliveryTotal,
|
data.MessagesQueuedForDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesSubmittedTotal,
|
c.messagesSubmittedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.MessagesSubmittedTotal,
|
data.MessagesSubmittedTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesDelayedTotal,
|
c.messagesDelayedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.MessagesDelayedTotal,
|
data.MessagesDelayedTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesCompletedDeliveryTotal,
|
c.messagesCompletedDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.MessagesCompletedDeliveryTotal,
|
data.MessagesCompletedDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.aggregateShadowQueueLength,
|
c.aggregateShadowQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.AggregateShadowQueueLength,
|
data.AggregateShadowQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.submissionQueueLength,
|
c.submissionQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.SubmissionQueueLength,
|
data.SubmissionQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.delayQueueLength,
|
c.delayQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.DelayQueueLength,
|
data.DelayQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsCompletedDeliveryTotal,
|
c.itemsCompletedDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ItemsCompletedDeliveryTotal,
|
data.ItemsCompletedDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsQueuedForDeliveryExpiredTotal,
|
c.itemsQueuedForDeliveryExpiredTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ItemsQueuedForDeliveryExpiredTotal,
|
data.ItemsQueuedForDeliveryExpiredTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsQueuedForDeliveryTotal,
|
c.itemsQueuedForDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ItemsQueuedForDeliveryTotal,
|
data.ItemsQueuedForDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsResubmittedTotal,
|
c.itemsResubmittedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -103,24 +103,28 @@ func (c *Collector) collectWorkloadManagementWorkloads(ch chan<- prometheus.Metr
|
|||||||
data.ActiveTasks,
|
data.ActiveTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.completedTasks,
|
c.completedTasks,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.CompletedTasks,
|
data.CompletedTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.queuedTasks,
|
c.queuedTasks,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.QueuedTasks,
|
data.QueuedTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.yieldedTasks,
|
c.yieldedTasks,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.YieldedTasks,
|
data.YieldedTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.isActive,
|
c.isActive,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package filetime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -73,19 +74,10 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
}
|
}
|
||||||
c.config.FilePatterns = make([]string, 0)
|
c.config.FilePatterns = make([]string, 0)
|
||||||
|
|
||||||
var filePatterns string
|
|
||||||
|
|
||||||
app.Flag(
|
app.Flag(
|
||||||
"collector.filetime.file-patterns",
|
"collector.filetime.file-patterns",
|
||||||
"Comma-separated list of file patterns. Each pattern is a glob pattern that can contain `*`, `?`, and `**` (recursive). See https://github.com/bmatcuk/doublestar#patterns",
|
"Comma-separated list of file patterns. Each pattern is a glob pattern that can contain `*`, `?`, and `**` (recursive). See https://github.com/bmatcuk/doublestar#patterns",
|
||||||
).Default(strings.Join(ConfigDefaults.FilePatterns, ",")).StringVar(&filePatterns)
|
).Default(strings.Join(ConfigDefaults.FilePatterns, ",")).StringsVar(&c.config.FilePatterns)
|
||||||
|
|
||||||
app.Action(func(*kingpin.ParseContext) error {
|
|
||||||
// doublestar.Glob() requires forward slashes
|
|
||||||
c.config.FilePatterns = strings.Split(filepath.ToSlash(filePatterns), ",")
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@@ -148,16 +140,11 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectGlobFilePath(ch chan<- prometheus.Metric, filePattern string) error {
|
func (c *Collector) collectGlobFilePath(ch chan<- prometheus.Metric, filePattern string) error {
|
||||||
basePath, pattern := doublestar.SplitPattern(filePattern)
|
basePath, pattern := doublestar.SplitPattern(filepath.ToSlash(filePattern))
|
||||||
basePathFS := os.DirFS(basePath)
|
basePathFS := os.DirFS(basePath)
|
||||||
|
|
||||||
matches, err := doublestar.Glob(basePathFS, pattern, doublestar.WithFilesOnly())
|
err := doublestar.GlobWalk(basePathFS, pattern, func(path string, d fs.DirEntry) error {
|
||||||
if err != nil {
|
filePath := filepath.Join(basePath, path)
|
||||||
return fmt.Errorf("failed to glob: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, match := range matches {
|
|
||||||
filePath := filepath.Join(basePath, match)
|
|
||||||
|
|
||||||
fileInfo, err := os.Stat(filePath)
|
fileInfo, err := os.Stat(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -166,15 +153,20 @@ func (c *Collector) collectGlobFilePath(ch chan<- prometheus.Metric, filePattern
|
|||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
continue
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.fileMTime,
|
c.fileMTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(fileInfo.ModTime().UTC().Unix()),
|
float64(fileInfo.ModTime().UTC().UnixMicro())/1e6,
|
||||||
filePath,
|
filePath,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}, doublestar.WithFilesOnly(), doublestar.WithCaseInsensitive())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to glob: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
path,
|
path,
|
||||||
template,
|
template,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.size,
|
c.size,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -197,6 +198,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
path,
|
path,
|
||||||
template,
|
template,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.usage,
|
c.usage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -204,12 +206,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
path,
|
path,
|
||||||
template,
|
template,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.description,
|
c.description,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
1.0,
|
1.0,
|
||||||
path, template, Description,
|
path, template, Description,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.disabled,
|
c.disabled,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -217,6 +221,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
path,
|
path,
|
||||||
template,
|
template,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.matchesTemplate,
|
c.matchesTemplate,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -224,6 +229,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
path,
|
path,
|
||||||
template,
|
template,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.softLimit,
|
c.softLimit,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/setupapi"
|
"github.com/prometheus-community/windows_exporter/internal/headers/gdi32"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
@@ -41,6 +41,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
|
gpuDeviceCache map[string]gdi32.GPUDevice
|
||||||
|
|
||||||
// GPU Engine
|
// GPU Engine
|
||||||
gpuEnginePerfDataCollector *pdh.Collector
|
gpuEnginePerfDataCollector *pdh.Collector
|
||||||
gpuEnginePerfDataObject []gpuEnginePerfDataCounterValues
|
gpuEnginePerfDataObject []gpuEnginePerfDataCounterValues
|
||||||
@@ -48,6 +50,10 @@ type Collector struct {
|
|||||||
gpuInfo *prometheus.Desc
|
gpuInfo *prometheus.Desc
|
||||||
gpuEngineRunningTime *prometheus.Desc
|
gpuEngineRunningTime *prometheus.Desc
|
||||||
|
|
||||||
|
gpuSharedSystemMemorySize *prometheus.Desc
|
||||||
|
gpuDedicatedSystemMemorySize *prometheus.Desc
|
||||||
|
gpuDedicatedVideoMemorySize *prometheus.Desc
|
||||||
|
|
||||||
// GPU Adapter Memory
|
// GPU Adapter Memory
|
||||||
gpuAdapterMemoryPerfDataCollector *pdh.Collector
|
gpuAdapterMemoryPerfDataCollector *pdh.Collector
|
||||||
gpuAdapterMemoryPerfDataObject []gpuAdapterMemoryPerfDataCounterValues
|
gpuAdapterMemoryPerfDataObject []gpuAdapterMemoryPerfDataCounterValues
|
||||||
@@ -115,78 +121,97 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
c.gpuInfo = prometheus.NewDesc(
|
c.gpuInfo = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||||
"A metric with a constant '1' value labeled with gpu device information.",
|
"A metric with a constant '1' value labeled with gpu device information.",
|
||||||
[]string{"phys", "physical_device_object_name", "hardware_id", "friendly_name", "description"},
|
[]string{"luid", "name", "bus_number", "phys", "function_number"},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
|
||||||
|
c.gpuSharedSystemMemorySize = prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(types.Namespace, Name, "shared_system_memory_size_bytes"),
|
||||||
|
"The size, in bytes, of memory from system memory that can be shared by many users.",
|
||||||
|
[]string{"luid"},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
c.gpuDedicatedSystemMemorySize = prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(types.Namespace, Name, "dedicated_system_memory_size_bytes"),
|
||||||
|
"The size, in bytes, of memory that is dedicated from system memory.",
|
||||||
|
[]string{"luid"},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
c.gpuDedicatedVideoMemorySize = prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(types.Namespace, Name, "dedicated_video_memory_size_bytes"),
|
||||||
|
"The size, in bytes, of memory that is dedicated from video memory.",
|
||||||
|
[]string{"luid"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.gpuEngineRunningTime = prometheus.NewDesc(
|
c.gpuEngineRunningTime = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "engine_time_seconds"),
|
prometheus.BuildFQName(types.Namespace, Name, "engine_time_seconds"),
|
||||||
"Total running time of the GPU in seconds.",
|
"Total running time of the GPU in seconds.",
|
||||||
[]string{"process_id", "phys", "eng", "engtype"},
|
[]string{"process_id", "luid", "phys", "eng", "engtype"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.gpuAdapterMemoryDedicatedUsage = prometheus.NewDesc(
|
c.gpuAdapterMemoryDedicatedUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "adapter_memory_dedicated_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "adapter_memory_dedicated_bytes"),
|
||||||
"Dedicated GPU memory usage in bytes.",
|
"Dedicated GPU memory usage in bytes.",
|
||||||
[]string{"phys"},
|
[]string{"luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.gpuAdapterMemorySharedUsage = prometheus.NewDesc(
|
c.gpuAdapterMemorySharedUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "adapter_memory_shared_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "adapter_memory_shared_bytes"),
|
||||||
"Shared GPU memory usage in bytes.",
|
"Shared GPU memory usage in bytes.",
|
||||||
[]string{"phys"},
|
[]string{"luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.gpuAdapterMemoryTotalCommitted = prometheus.NewDesc(
|
c.gpuAdapterMemoryTotalCommitted = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "adapter_memory_committed_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "adapter_memory_committed_bytes"),
|
||||||
"Total committed GPU memory in bytes.",
|
"Total committed GPU memory in bytes.",
|
||||||
[]string{"phys"},
|
[]string{"luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.gpuLocalAdapterMemoryUsage = prometheus.NewDesc(
|
c.gpuLocalAdapterMemoryUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "local_adapter_memory_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "local_adapter_memory_bytes"),
|
||||||
"Local adapter memory usage in bytes.",
|
"Local adapter memory usage in bytes.",
|
||||||
[]string{"phys"},
|
[]string{"luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.gpuNonLocalAdapterMemoryUsage = prometheus.NewDesc(
|
c.gpuNonLocalAdapterMemoryUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "non_local_adapter_memory_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "non_local_adapter_memory_bytes"),
|
||||||
"Non-local adapter memory usage in bytes.",
|
"Non-local adapter memory usage in bytes.",
|
||||||
[]string{"phys"},
|
[]string{"luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.gpuProcessMemoryDedicatedUsage = prometheus.NewDesc(
|
c.gpuProcessMemoryDedicatedUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_dedicated_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "process_memory_dedicated_bytes"),
|
||||||
"Dedicated process memory usage in bytes.",
|
"Dedicated process memory usage in bytes.",
|
||||||
[]string{"process_id", "phys"},
|
[]string{"process_id", "luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.gpuProcessMemoryLocalUsage = prometheus.NewDesc(
|
c.gpuProcessMemoryLocalUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_local_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "process_memory_local_bytes"),
|
||||||
"Local process memory usage in bytes.",
|
"Local process memory usage in bytes.",
|
||||||
[]string{"process_id", "phys"},
|
[]string{"process_id", "luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.gpuProcessMemoryNonLocalUsage = prometheus.NewDesc(
|
c.gpuProcessMemoryNonLocalUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_non_local_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "process_memory_non_local_bytes"),
|
||||||
"Non-local process memory usage in bytes.",
|
"Non-local process memory usage in bytes.",
|
||||||
[]string{"process_id", "phys"},
|
[]string{"process_id", "luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.gpuProcessMemorySharedUsage = prometheus.NewDesc(
|
c.gpuProcessMemorySharedUsage = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_shared_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "process_memory_shared_bytes"),
|
||||||
"Shared process memory usage in bytes.",
|
"Shared process memory usage in bytes.",
|
||||||
[]string{"process_id", "phys"},
|
[]string{"process_id", "luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.gpuProcessMemoryTotalCommitted = prometheus.NewDesc(
|
c.gpuProcessMemoryTotalCommitted = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "process_memory_committed_bytes"),
|
prometheus.BuildFQName(types.Namespace, Name, "process_memory_committed_bytes"),
|
||||||
"Total committed process memory in bytes.",
|
"Total committed process memory in bytes.",
|
||||||
[]string{"process_id", "phys"},
|
[]string{"process_id", "luid", "phys"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -217,15 +242,31 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
errs = append(errs, fmt.Errorf("failed to create GPU Process Memory perf data collector: %w", err))
|
errs = append(errs, fmt.Errorf("failed to create GPU Process Memory perf data collector: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpus, err := gdi32.GetGPUDevices()
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("failed to get GPU devices: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, gpu := range gpus {
|
||||||
|
if gpu.AdapterString == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.gpuDeviceCache == nil {
|
||||||
|
c.gpuDeviceCache = make(map[string]gdi32.GPUDevice)
|
||||||
|
}
|
||||||
|
|
||||||
|
luidKey := fmt.Sprintf("0x%08X_0x%08X", gpu.LUID.HighPart, gpu.LUID.LowPart)
|
||||||
|
c.gpuDeviceCache[luidKey] = gpu
|
||||||
|
}
|
||||||
|
|
||||||
return errors.Join(errs...)
|
return errors.Join(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
errs := make([]error, 0)
|
errs := make([]error, 0)
|
||||||
|
|
||||||
if err := c.collectGpuInfo(ch); err != nil {
|
c.collectGpuInfo(ch)
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := c.collectGpuEngineMetrics(ch); err != nil {
|
if err := c.collectGpuEngineMetrics(ch); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
@@ -250,26 +291,40 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
return errors.Join(errs...)
|
return errors.Join(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectGpuInfo(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectGpuInfo(ch chan<- prometheus.Metric) {
|
||||||
gpus, err := setupapi.GetGPUDevices()
|
for luid, gpu := range c.gpuDeviceCache {
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to get GPU devices: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, gpu := range gpus {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuInfo,
|
c.gpuInfo,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
1.0,
|
1.0,
|
||||||
strconv.Itoa(i),
|
luid,
|
||||||
gpu.PhysicalDeviceObjectName,
|
gpu.AdapterString,
|
||||||
gpu.HardwareID,
|
strconv.FormatInt(int64(gpu.BusNumber), 10),
|
||||||
gpu.FriendlyName,
|
strconv.FormatInt(int64(gpu.DeviceNumber), 10),
|
||||||
gpu.DeviceDesc,
|
strconv.FormatInt(int64(gpu.FunctionNumber), 10),
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.gpuSharedSystemMemorySize,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(gpu.SharedSystemMemorySize),
|
||||||
|
luid,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.gpuDedicatedSystemMemorySize,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(gpu.DedicatedSystemMemorySize),
|
||||||
|
luid,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.gpuDedicatedVideoMemorySize,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(gpu.DedicatedVideoMemorySize),
|
||||||
|
luid,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectGpuEngineMetrics(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectGpuEngineMetrics(ch chan<- prometheus.Metric) error {
|
||||||
@@ -283,9 +338,14 @@ func (c *Collector) collectGpuEngineMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
for _, data := range c.gpuEnginePerfDataObject {
|
for _, data := range c.gpuEnginePerfDataObject {
|
||||||
instance := parseGPUCounterInstanceString(data.Name)
|
instance := parseGPUCounterInstanceString(data.Name)
|
||||||
|
|
||||||
|
if _, ok := c.gpuDeviceCache[instance.Luid]; !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
key := PidPhysEngEngType{
|
key := PidPhysEngEngType{
|
||||||
Pid: instance.Pid,
|
Pid: instance.Pid,
|
||||||
Phys: instance.Phys,
|
Phys: instance.Phys,
|
||||||
|
Luid: instance.Luid,
|
||||||
Eng: instance.Eng,
|
Eng: instance.Eng,
|
||||||
Engtype: instance.Engtype,
|
Engtype: instance.Engtype,
|
||||||
}
|
}
|
||||||
@@ -297,7 +357,7 @@ func (c *Collector) collectGpuEngineMetrics(ch chan<- prometheus.Metric) error {
|
|||||||
c.gpuEngineRunningTime,
|
c.gpuEngineRunningTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
runningTime,
|
runningTime,
|
||||||
key.Pid, key.Phys, key.Eng, key.Engtype,
|
key.Pid, key.Luid, key.Phys, key.Eng, key.Engtype,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,8 +377,13 @@ func (c *Collector) collectGpuAdapterMemoryMetrics(ch chan<- prometheus.Metric)
|
|||||||
for _, data := range c.gpuAdapterMemoryPerfDataObject {
|
for _, data := range c.gpuAdapterMemoryPerfDataObject {
|
||||||
instance := parseGPUCounterInstanceString(data.Name)
|
instance := parseGPUCounterInstanceString(data.Name)
|
||||||
|
|
||||||
|
if _, ok := c.gpuDeviceCache[instance.Luid]; !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
key := PidPhysEngEngType{
|
key := PidPhysEngEngType{
|
||||||
Pid: instance.Pid,
|
Pid: instance.Pid,
|
||||||
|
Luid: instance.Luid,
|
||||||
Phys: instance.Phys,
|
Phys: instance.Phys,
|
||||||
Eng: instance.Eng,
|
Eng: instance.Eng,
|
||||||
Engtype: instance.Engtype,
|
Engtype: instance.Engtype,
|
||||||
@@ -333,19 +398,21 @@ func (c *Collector) collectGpuAdapterMemoryMetrics(ch chan<- prometheus.Metric)
|
|||||||
c.gpuAdapterMemoryDedicatedUsage,
|
c.gpuAdapterMemoryDedicatedUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
dedicatedUsage,
|
dedicatedUsage,
|
||||||
key.Phys,
|
key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuAdapterMemorySharedUsage,
|
c.gpuAdapterMemorySharedUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
sharedUsageMap[key],
|
sharedUsageMap[key],
|
||||||
key.Phys,
|
key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuAdapterMemoryTotalCommitted,
|
c.gpuAdapterMemoryTotalCommitted,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
totalCommittedMap[key],
|
totalCommittedMap[key],
|
||||||
key.Phys,
|
key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,20 +425,29 @@ func (c *Collector) collectGpuLocalAdapterMemoryMetrics(ch chan<- prometheus.Met
|
|||||||
return fmt.Errorf("failed to collect GPU Local Adapter Memory perf data: %w", err)
|
return fmt.Errorf("failed to collect GPU Local Adapter Memory perf data: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localAdapterMemoryMap := make(map[string]float64)
|
localAdapterMemoryMap := make(map[PidPhysEngEngType]float64)
|
||||||
|
|
||||||
for _, data := range c.gpuLocalAdapterMemoryPerfDataObject {
|
for _, data := range c.gpuLocalAdapterMemoryPerfDataObject {
|
||||||
instance := parseGPUCounterInstanceString(data.Name)
|
instance := parseGPUCounterInstanceString(data.Name)
|
||||||
|
|
||||||
localAdapterMemoryMap[instance.Phys] += data.LocalUsage
|
if _, ok := c.gpuDeviceCache[instance.Luid]; !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
key := PidPhysEngEngType{
|
||||||
|
Luid: instance.Luid,
|
||||||
|
Phys: instance.Phys,
|
||||||
|
}
|
||||||
|
|
||||||
|
localAdapterMemoryMap[key] += data.LocalUsage
|
||||||
}
|
}
|
||||||
|
|
||||||
for phys, localUsage := range localAdapterMemoryMap {
|
for key, localUsage := range localAdapterMemoryMap {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuLocalAdapterMemoryUsage,
|
c.gpuLocalAdapterMemoryUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
localUsage,
|
localUsage,
|
||||||
phys,
|
key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,20 +460,28 @@ func (c *Collector) collectGpuNonLocalAdapterMemoryMetrics(ch chan<- prometheus.
|
|||||||
return fmt.Errorf("failed to collect GPU Non Local Adapter Memory perf data: %w", err)
|
return fmt.Errorf("failed to collect GPU Non Local Adapter Memory perf data: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nonLocalAdapterMemoryMap := make(map[string]float64)
|
nonLocalAdapterMemoryMap := make(map[PidPhysEngEngType]float64)
|
||||||
|
|
||||||
for _, data := range c.gpuNonLocalAdapterMemoryPerfDataObject {
|
for _, data := range c.gpuNonLocalAdapterMemoryPerfDataObject {
|
||||||
instance := parseGPUCounterInstanceString(data.Name)
|
instance := parseGPUCounterInstanceString(data.Name)
|
||||||
|
|
||||||
nonLocalAdapterMemoryMap[instance.Phys] += data.NonLocalUsage
|
if _, ok := c.gpuDeviceCache[instance.Luid]; !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
key := PidPhysEngEngType{
|
||||||
|
Luid: instance.Luid,
|
||||||
|
Phys: instance.Phys,
|
||||||
|
}
|
||||||
|
nonLocalAdapterMemoryMap[key] += data.NonLocalUsage
|
||||||
}
|
}
|
||||||
|
|
||||||
for phys, nonLocalUsage := range nonLocalAdapterMemoryMap {
|
for key, nonLocalUsage := range nonLocalAdapterMemoryMap {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuNonLocalAdapterMemoryUsage,
|
c.gpuNonLocalAdapterMemoryUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
nonLocalUsage,
|
nonLocalUsage,
|
||||||
phys,
|
key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,8 +503,13 @@ func (c *Collector) collectGpuProcessMemoryMetrics(ch chan<- prometheus.Metric)
|
|||||||
for _, data := range c.gpuProcessMemoryPerfDataObject {
|
for _, data := range c.gpuProcessMemoryPerfDataObject {
|
||||||
instance := parseGPUCounterInstanceString(data.Name)
|
instance := parseGPUCounterInstanceString(data.Name)
|
||||||
|
|
||||||
|
if _, ok := c.gpuDeviceCache[instance.Luid]; !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
key := PidPhys{
|
key := PidPhys{
|
||||||
Pid: instance.Pid,
|
Pid: instance.Pid,
|
||||||
|
Luid: instance.Luid,
|
||||||
Phys: instance.Phys,
|
Phys: instance.Phys,
|
||||||
}
|
}
|
||||||
processDedicatedUsageMap[key] += data.DedicatedUsage
|
processDedicatedUsageMap[key] += data.DedicatedUsage
|
||||||
@@ -435,31 +524,35 @@ func (c *Collector) collectGpuProcessMemoryMetrics(ch chan<- prometheus.Metric)
|
|||||||
c.gpuProcessMemoryDedicatedUsage,
|
c.gpuProcessMemoryDedicatedUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
dedicatedUsage,
|
dedicatedUsage,
|
||||||
key.Pid, key.Phys,
|
key.Pid, key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuProcessMemoryLocalUsage,
|
c.gpuProcessMemoryLocalUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
processLocalUsageMap[key],
|
processLocalUsageMap[key],
|
||||||
key.Pid, key.Phys,
|
key.Pid, key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuProcessMemoryNonLocalUsage,
|
c.gpuProcessMemoryNonLocalUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
processNonLocalUsageMap[key],
|
processNonLocalUsageMap[key],
|
||||||
key.Pid, key.Phys,
|
key.Pid, key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuProcessMemorySharedUsage,
|
c.gpuProcessMemorySharedUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
processSharedUsageMap[key],
|
processSharedUsageMap[key],
|
||||||
key.Pid, key.Phys,
|
key.Pid, key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.gpuProcessMemoryTotalCommitted,
|
c.gpuProcessMemoryTotalCommitted,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
processTotalCommittedMap[key],
|
processTotalCommittedMap[key],
|
||||||
key.Pid, key.Phys,
|
key.Pid, key.Luid, key.Phys,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,13 @@
|
|||||||
package gpu
|
package gpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Instance struct {
|
type Instance struct {
|
||||||
Pid string
|
Pid string
|
||||||
Luid [2]string
|
Luid string
|
||||||
Phys string
|
Phys string
|
||||||
Eng string
|
Eng string
|
||||||
Engtype string
|
Engtype string
|
||||||
@@ -32,11 +33,13 @@ type Instance struct {
|
|||||||
|
|
||||||
type PidPhys struct {
|
type PidPhys struct {
|
||||||
Pid string
|
Pid string
|
||||||
|
Luid string
|
||||||
Phys string
|
Phys string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PidPhysEngEngType struct {
|
type PidPhysEngEngType struct {
|
||||||
Pid string
|
Pid string
|
||||||
|
Luid string
|
||||||
Phys string
|
Phys string
|
||||||
Eng string
|
Eng string
|
||||||
Engtype string
|
Engtype string
|
||||||
@@ -58,8 +61,7 @@ func parseGPUCounterInstanceString(s string) Instance {
|
|||||||
}
|
}
|
||||||
case "luid":
|
case "luid":
|
||||||
if i+2 < len(parts) {
|
if i+2 < len(parts) {
|
||||||
instance.Luid[0] = parts[i+1]
|
instance.Luid = fmt.Sprintf("%s_%s", parts[i+1], parts[i+2])
|
||||||
instance.Luid[1] = parts[i+2]
|
|
||||||
}
|
}
|
||||||
case "phys":
|
case "phys":
|
||||||
if i+1 < len(parts) {
|
if i+1 < len(parts) {
|
||||||
|
|||||||
@@ -78,11 +78,6 @@ var ConfigDefaults = Config{
|
|||||||
|
|
||||||
// Collector is a Prometheus Collector for hyper-v.
|
// Collector is a Prometheus Collector for hyper-v.
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
|
||||||
|
|
||||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
|
||||||
closeFns []func()
|
|
||||||
|
|
||||||
collectorDataStore
|
collectorDataStore
|
||||||
collectorDynamicMemoryBalancer
|
collectorDynamicMemoryBalancer
|
||||||
collectorDynamicMemoryVM
|
collectorDynamicMemoryVM
|
||||||
@@ -98,6 +93,11 @@ type Collector struct {
|
|||||||
collectorVirtualSMB
|
collectorVirtualSMB
|
||||||
collectorVirtualStorageDevice
|
collectorVirtualStorageDevice
|
||||||
collectorVirtualSwitch
|
collectorVirtualSwitch
|
||||||
|
|
||||||
|
config Config
|
||||||
|
|
||||||
|
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||||
|
closeFns []func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
|
|||||||
@@ -310,26 +310,31 @@ func (c *Collector) collectHypervisorRootPartition(ch chan<- prometheus.Metric)
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MDevicePages,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MDevicePages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition2MGPAPages,
|
c.hypervisorRootPartition2MGPAPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MGPAPages,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MGPAPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition4KDevicePages,
|
c.hypervisorRootPartition4KDevicePages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KDevicePages,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KDevicePages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition4KGPAPages,
|
c.hypervisorRootPartition4KGPAPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KGPAPages,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KGPAPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionVirtualTLBFlushEntries,
|
c.hypervisorRootPartitionVirtualTLBFlushEntries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBFlushEntries,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBFlushEntries,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionVirtualTLBPages,
|
c.hypervisorRootPartitionVirtualTLBPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -195,294 +195,343 @@ func (c *Collector) collectVirtualNetworkAdapterDropReasons(ch chan<- prometheus
|
|||||||
data.VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
|
data.VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
|
||||||
data.Name, "NativeFwdingReq", "outgoing",
|
data.Name, "NativeFwdingReq", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
|
data.VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
|
||||||
data.Name, "NativeFwdingReq", "incoming",
|
data.Name, "NativeFwdingReq", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
|
data.VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
|
||||||
data.Name, "MTUMismatch", "outgoing",
|
data.Name, "MTUMismatch", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingMTUMismatch,
|
data.VirtualNetworkAdapterDropReasonsIncomingMTUMismatch,
|
||||||
data.Name, "MTUMismatch", "incoming",
|
data.Name, "MTUMismatch", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
|
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
|
||||||
data.Name, "InvalidConfig", "outgoing",
|
data.Name, "InvalidConfig", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingInvalidConfig,
|
data.VirtualNetworkAdapterDropReasonsIncomingInvalidConfig,
|
||||||
data.Name, "InvalidConfig", "incoming",
|
data.Name, "InvalidConfig", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
|
data.VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
|
||||||
data.Name, "RequiredExtensionMissing", "outgoing",
|
data.Name, "RequiredExtensionMissing", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
|
data.VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
|
||||||
data.Name, "RequiredExtensionMissing", "incoming",
|
data.Name, "RequiredExtensionMissing", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
|
data.VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
|
||||||
data.Name, "VirtualSubnetId", "outgoing",
|
data.Name, "VirtualSubnetId", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
|
data.VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
|
||||||
data.Name, "VirtualSubnetId", "incoming",
|
data.Name, "VirtualSubnetId", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
|
data.VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
|
||||||
data.Name, "BridgeReserved", "outgoing",
|
data.Name, "BridgeReserved", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingBridgeReserved,
|
data.VirtualNetworkAdapterDropReasonsIncomingBridgeReserved,
|
||||||
data.Name, "BridgeReserved", "incoming",
|
data.Name, "BridgeReserved", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingRouterGuard,
|
data.VirtualNetworkAdapterDropReasonsOutgoingRouterGuard,
|
||||||
data.Name, "RouterGuard", "outgoing",
|
data.Name, "RouterGuard", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingRouterGuard,
|
data.VirtualNetworkAdapterDropReasonsIncomingRouterGuard,
|
||||||
data.Name, "RouterGuard", "incoming",
|
data.Name, "RouterGuard", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
|
data.VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
|
||||||
data.Name, "DhcpGuard", "outgoing",
|
data.Name, "DhcpGuard", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingDhcpGuard,
|
data.VirtualNetworkAdapterDropReasonsIncomingDhcpGuard,
|
||||||
data.Name, "DhcpGuard", "incoming",
|
data.Name, "DhcpGuard", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
|
data.VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
|
||||||
data.Name, "MacSpoofing", "outgoing",
|
data.Name, "MacSpoofing", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingMacSpoofing,
|
data.VirtualNetworkAdapterDropReasonsIncomingMacSpoofing,
|
||||||
data.Name, "MacSpoofing", "incoming",
|
data.Name, "MacSpoofing", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingIpsec,
|
data.VirtualNetworkAdapterDropReasonsOutgoingIpsec,
|
||||||
data.Name, "Ipsec", "outgoing",
|
data.Name, "Ipsec", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingIpsec,
|
data.VirtualNetworkAdapterDropReasonsIncomingIpsec,
|
||||||
data.Name, "Ipsec", "incoming",
|
data.Name, "Ipsec", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingQos,
|
data.VirtualNetworkAdapterDropReasonsOutgoingQos,
|
||||||
data.Name, "Qos", "outgoing",
|
data.Name, "Qos", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingQos,
|
data.VirtualNetworkAdapterDropReasonsIncomingQos,
|
||||||
data.Name, "Qos", "incoming",
|
data.Name, "Qos", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
|
||||||
data.Name, "FailedPvlanSetting", "outgoing",
|
data.Name, "FailedPvlanSetting", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
|
data.VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
|
||||||
data.Name, "FailedPvlanSetting", "incoming",
|
data.Name, "FailedPvlanSetting", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
|
||||||
data.Name, "FailedSecurityPolicy", "outgoing",
|
data.Name, "FailedSecurityPolicy", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
|
data.VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
|
||||||
data.Name, "FailedSecurityPolicy", "incoming",
|
data.Name, "FailedSecurityPolicy", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
|
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
|
||||||
data.Name, "UnauthorizedMAC", "outgoing",
|
data.Name, "UnauthorizedMAC", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
|
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
|
||||||
data.Name, "UnauthorizedMAC", "incoming",
|
data.Name, "UnauthorizedMAC", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
|
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
|
||||||
data.Name, "UnauthorizedVLAN", "outgoing",
|
data.Name, "UnauthorizedVLAN", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
|
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
|
||||||
data.Name, "UnauthorizedVLAN", "incoming",
|
data.Name, "UnauthorizedVLAN", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
|
||||||
data.Name, "FilteredVLAN", "outgoing",
|
data.Name, "FilteredVLAN", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
|
data.VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
|
||||||
data.Name, "FilteredVLAN", "incoming",
|
data.Name, "FilteredVLAN", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingFiltered,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFiltered,
|
||||||
data.Name, "Filtered", "outgoing",
|
data.Name, "Filtered", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingFiltered,
|
data.VirtualNetworkAdapterDropReasonsIncomingFiltered,
|
||||||
data.Name, "Filtered", "incoming",
|
data.Name, "Filtered", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingBusy,
|
data.VirtualNetworkAdapterDropReasonsOutgoingBusy,
|
||||||
data.Name, "Busy", "outgoing",
|
data.Name, "Busy", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingBusy,
|
data.VirtualNetworkAdapterDropReasonsIncomingBusy,
|
||||||
data.Name, "Busy", "incoming",
|
data.Name, "Busy", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingNotAccepted,
|
data.VirtualNetworkAdapterDropReasonsOutgoingNotAccepted,
|
||||||
data.Name, "NotAccepted", "outgoing",
|
data.Name, "NotAccepted", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingNotAccepted,
|
data.VirtualNetworkAdapterDropReasonsIncomingNotAccepted,
|
||||||
data.Name, "NotAccepted", "incoming",
|
data.Name, "NotAccepted", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingDisconnected,
|
data.VirtualNetworkAdapterDropReasonsOutgoingDisconnected,
|
||||||
data.Name, "Disconnected", "outgoing",
|
data.Name, "Disconnected", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingDisconnected,
|
data.VirtualNetworkAdapterDropReasonsIncomingDisconnected,
|
||||||
data.Name, "Disconnected", "incoming",
|
data.Name, "Disconnected", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingNotReady,
|
data.VirtualNetworkAdapterDropReasonsOutgoingNotReady,
|
||||||
data.Name, "NotReady", "outgoing",
|
data.Name, "NotReady", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingNotReady,
|
data.VirtualNetworkAdapterDropReasonsIncomingNotReady,
|
||||||
data.Name, "NotReady", "incoming",
|
data.Name, "NotReady", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingResources,
|
data.VirtualNetworkAdapterDropReasonsOutgoingResources,
|
||||||
data.Name, "Resources", "outgoing",
|
data.Name, "Resources", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingResources,
|
data.VirtualNetworkAdapterDropReasonsIncomingResources,
|
||||||
data.Name, "Resources", "incoming",
|
data.Name, "Resources", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
|
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
|
||||||
data.Name, "InvalidPacket", "outgoing",
|
data.Name, "InvalidPacket", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingInvalidPacket,
|
data.VirtualNetworkAdapterDropReasonsIncomingInvalidPacket,
|
||||||
data.Name, "InvalidPacket", "incoming",
|
data.Name, "InvalidPacket", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidData,
|
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidData,
|
||||||
data.Name, "InvalidData", "outgoing",
|
data.Name, "InvalidData", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsIncomingInvalidData,
|
data.VirtualNetworkAdapterDropReasonsIncomingInvalidData,
|
||||||
data.Name, "InvalidData", "incoming",
|
data.Name, "InvalidData", "incoming",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualNetworkAdapterDropReasonsOutgoingUnknown,
|
data.VirtualNetworkAdapterDropReasonsOutgoingUnknown,
|
||||||
data.Name, "Unknown", "outgoing",
|
data.Name, "Unknown", "outgoing",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
|||||||
data.VirtualSwitchDirectedPacketsReceived,
|
data.VirtualSwitchDirectedPacketsReceived,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchDirectedPacketsSent,
|
c.virtualSwitchDirectedPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -278,18 +279,21 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
|||||||
data.VirtualSwitchDroppedPacketsIncoming,
|
data.VirtualSwitchDroppedPacketsIncoming,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchDroppedPacketsOutgoing,
|
c.virtualSwitchDroppedPacketsOutgoing,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualSwitchDroppedPacketsOutgoing,
|
data.VirtualSwitchDroppedPacketsOutgoing,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchExtensionsDroppedPacketsIncoming,
|
c.virtualSwitchExtensionsDroppedPacketsIncoming,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualSwitchExtensionsDroppedPacketsIncoming,
|
data.VirtualSwitchExtensionsDroppedPacketsIncoming,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchExtensionsDroppedPacketsOutgoing,
|
c.virtualSwitchExtensionsDroppedPacketsOutgoing,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -303,24 +307,28 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
|||||||
data.VirtualSwitchLearnedMacAddresses,
|
data.VirtualSwitchLearnedMacAddresses,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchMulticastPacketsReceived,
|
c.virtualSwitchMulticastPacketsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualSwitchMulticastPacketsReceived,
|
data.VirtualSwitchMulticastPacketsReceived,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchMulticastPacketsSent,
|
c.virtualSwitchMulticastPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualSwitchMulticastPacketsSent,
|
data.VirtualSwitchMulticastPacketsSent,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchNumberOfSendChannelMoves,
|
c.virtualSwitchNumberOfSendChannelMoves,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualSwitchNumberOfSendChannelMoves,
|
data.VirtualSwitchNumberOfSendChannelMoves,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchNumberOfVMQMoves,
|
c.virtualSwitchNumberOfVMQMoves,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -348,12 +356,14 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
|||||||
data.VirtualSwitchPacketsReceived,
|
data.VirtualSwitchPacketsReceived,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchPacketsSent,
|
c.virtualSwitchPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.VirtualSwitchPacketsSent,
|
data.VirtualSwitchPacketsSent,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchPurgedMacAddresses,
|
c.virtualSwitchPurgedMacAddresses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -50,14 +50,18 @@ var ConfigDefaults = Config{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
|
||||||
iisVersion simpleVersion
|
|
||||||
|
|
||||||
info *prometheus.Desc
|
|
||||||
collectorWebService
|
collectorWebService
|
||||||
|
collectorHttpServiceRequestQueues
|
||||||
collectorAppPoolWAS
|
collectorAppPoolWAS
|
||||||
collectorW3SVCW3WP
|
collectorW3SVCW3WP
|
||||||
collectorWebServiceCache
|
collectorWebServiceCache
|
||||||
|
|
||||||
|
config Config
|
||||||
|
iisVersion simpleVersion
|
||||||
|
|
||||||
|
logger *slog.Logger
|
||||||
|
|
||||||
|
info *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
@@ -150,6 +154,7 @@ func (c *Collector) GetName() string {
|
|||||||
|
|
||||||
func (c *Collector) Close() error {
|
func (c *Collector) Close() error {
|
||||||
c.perfDataCollectorWebService.Close()
|
c.perfDataCollectorWebService.Close()
|
||||||
|
c.perfDataCollectorHttpServiceRequestQueues.Close()
|
||||||
c.perfDataCollectorAppPoolWAS.Close()
|
c.perfDataCollectorAppPoolWAS.Close()
|
||||||
c.w3SVCW3WPPerfDataCollector.Close()
|
c.w3SVCW3WPPerfDataCollector.Close()
|
||||||
c.serviceCachePerfDataCollector.Close()
|
c.serviceCachePerfDataCollector.Close()
|
||||||
@@ -158,9 +163,9 @@ func (c *Collector) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) 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(
|
c.info = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
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))
|
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 {
|
if err := c.buildAppPoolWAS(); err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to build APP_POOL_WAS collector: %w", err))
|
errs = append(errs, fmt.Errorf("failed to build APP_POOL_WAS collector: %w", err))
|
||||||
}
|
}
|
||||||
@@ -195,10 +204,10 @@ type simpleVersion struct {
|
|||||||
minor uint64
|
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)
|
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\InetStp\`, registry.QUERY_VALUE)
|
||||||
if err != nil {
|
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),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -208,7 +217,7 @@ func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
|
|||||||
defer func() {
|
defer func() {
|
||||||
err = k.Close()
|
err = k.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("Failed to close registry key",
|
c.logger.Warn("Failed to close registry key",
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -216,7 +225,7 @@ func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
|
|||||||
|
|
||||||
major, _, err := k.GetIntegerValue("MajorVersion")
|
major, _, err := k.GetIntegerValue("MajorVersion")
|
||||||
if err != nil {
|
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),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -225,14 +234,14 @@ func (c *Collector) getIISVersion(logger *slog.Logger) simpleVersion {
|
|||||||
|
|
||||||
minor, _, err := k.GetIntegerValue("MinorVersion")
|
minor, _, err := k.GetIntegerValue("MinorVersion")
|
||||||
if err != nil {
|
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),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
return simpleVersion{}
|
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{
|
return simpleVersion{
|
||||||
major: major,
|
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))
|
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 {
|
if err := c.collectAppPoolWAS(ch); err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err))
|
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.CurrentApplicationPoolUptime,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentWorkerProcesses,
|
c.currentWorkerProcesses,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.CurrentWorkerProcesses,
|
data.CurrentWorkerProcesses,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.maximumWorkerProcesses,
|
c.maximumWorkerProcesses,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.MaximumWorkerProcesses,
|
data.MaximumWorkerProcesses,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.recentWorkerProcessFailures,
|
c.recentWorkerProcessFailures,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.RecentWorkerProcessFailures,
|
data.RecentWorkerProcessFailures,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeSinceLastWorkerProcessFailure,
|
c.timeSinceLastWorkerProcessFailure,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.TimeSinceLastWorkerProcessFailure,
|
data.TimeSinceLastWorkerProcessFailure,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalApplicationPoolRecycles,
|
c.totalApplicationPoolRecycles,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalApplicationPoolRecycles,
|
data.TotalApplicationPoolRecycles,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalApplicationPoolUptime,
|
c.totalApplicationPoolUptime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalApplicationPoolUptime,
|
data.TotalApplicationPoolUptime,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessesCreated,
|
c.totalWorkerProcessesCreated,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalWorkerProcessesCreated,
|
data.TotalWorkerProcessesCreated,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessFailures,
|
c.totalWorkerProcessFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalWorkerProcessFailures,
|
data.TotalWorkerProcessFailures,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessPingFailures,
|
c.totalWorkerProcessPingFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalWorkerProcessPingFailures,
|
data.TotalWorkerProcessPingFailures,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessShutdownFailures,
|
c.totalWorkerProcessShutdownFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalWorkerProcessShutdownFailures,
|
data.TotalWorkerProcessShutdownFailures,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessStartupFailures,
|
c.totalWorkerProcessStartupFailures,
|
||||||
prometheus.CounterValue,
|
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,
|
pid,
|
||||||
"401",
|
"401",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPRequestErrorsTotal,
|
c.w3SVCW3WPRequestErrorsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -449,6 +450,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
|||||||
pid,
|
pid,
|
||||||
"403",
|
"403",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPRequestErrorsTotal,
|
c.w3SVCW3WPRequestErrorsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -457,6 +459,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
|||||||
pid,
|
pid,
|
||||||
"404",
|
"404",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPRequestErrorsTotal,
|
c.w3SVCW3WPRequestErrorsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -465,6 +468,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
|||||||
pid,
|
pid,
|
||||||
"500",
|
"500",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPWebSocketRequestsActive,
|
c.w3SVCW3WPWebSocketRequestsActive,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -472,6 +476,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPWebSocketConnectionAttempts,
|
c.w3SVCW3WPWebSocketConnectionAttempts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -479,6 +484,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPWebSocketConnectionsAccepted,
|
c.w3SVCW3WPWebSocketConnectionsAccepted,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -486,6 +492,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPWebSocketConnectionsRejected,
|
c.w3SVCW3WPWebSocketConnectionsRejected,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -507,10 +514,6 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
deduplicateIISNames(c.perfDataObjectW3SVCW3WP)
|
deduplicateIISNames(c.perfDataObjectW3SVCW3WP)
|
||||||
|
|
||||||
for _, data := range 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>
|
// Extract the apppool name from the format <PID>_<NAME>
|
||||||
pid := workerProcessNameExtractor.ReplaceAllString(data.Name, "$1")
|
pid := workerProcessNameExtractor.ReplaceAllString(data.Name, "$1")
|
||||||
|
|
||||||
@@ -533,6 +536,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
pid,
|
pid,
|
||||||
"busy",
|
"busy",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMaximumThreads,
|
c.w3SVCW3WPMaximumThreads,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -540,6 +544,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPRequestsTotal,
|
c.w3SVCW3WPRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -547,6 +552,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPRequestsActive,
|
c.w3SVCW3WPRequestsActive,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -554,6 +560,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPActiveFlushedEntries,
|
c.w3SVCW3WPActiveFlushedEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -561,6 +568,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPCurrentFileCacheMemoryUsage,
|
c.w3SVCW3WPCurrentFileCacheMemoryUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -568,6 +576,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMaximumFileCacheMemoryUsage,
|
c.w3SVCW3WPMaximumFileCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -575,6 +584,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFileCacheFlushesTotal,
|
c.w3SVCW3WPFileCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -582,6 +592,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFileCacheQueriesTotal,
|
c.w3SVCW3WPFileCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -589,6 +600,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFileCacheHitsTotal,
|
c.w3SVCW3WPFileCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -596,6 +608,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFilesCached,
|
c.w3SVCW3WPFilesCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -603,6 +616,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFilesCachedTotal,
|
c.w3SVCW3WPFilesCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -610,6 +624,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFilesFlushedTotal,
|
c.w3SVCW3WPFilesFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -617,6 +632,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURICacheFlushesTotal,
|
c.w3SVCW3WPURICacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -624,6 +640,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURICacheQueriesTotal,
|
c.w3SVCW3WPURICacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -631,6 +648,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURICacheHitsTotal,
|
c.w3SVCW3WPURICacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -638,6 +656,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURIsCached,
|
c.w3SVCW3WPURIsCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -645,6 +664,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURIsCachedTotal,
|
c.w3SVCW3WPURIsCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -652,6 +672,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURIsFlushedTotal,
|
c.w3SVCW3WPURIsFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -659,6 +680,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCached,
|
c.w3SVCW3WPMetadataCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -666,6 +688,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCacheFlushes,
|
c.w3SVCW3WPMetadataCacheFlushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -673,6 +696,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCacheQueriesTotal,
|
c.w3SVCW3WPMetadataCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -680,6 +704,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCacheHitsTotal,
|
c.w3SVCW3WPMetadataCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -687,6 +712,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCachedTotal,
|
c.w3SVCW3WPMetadataCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -694,6 +720,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataFlushedTotal,
|
c.w3SVCW3WPMetadataFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -701,6 +728,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheActiveFlushedItems,
|
c.w3SVCW3WPOutputCacheActiveFlushedItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -708,6 +736,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheItems,
|
c.w3SVCW3WPOutputCacheItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -715,6 +744,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheMemoryUsage,
|
c.w3SVCW3WPOutputCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -722,6 +752,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheQueriesTotal,
|
c.w3SVCW3WPOutputCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -729,6 +760,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheHitsTotal,
|
c.w3SVCW3WPOutputCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -736,6 +768,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheFlushedItemsTotal,
|
c.w3SVCW3WPOutputCacheFlushedItemsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -743,6 +776,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
|||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheFlushesTotal,
|
c.w3SVCW3WPOutputCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -262,126 +262,147 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.WebServiceCurrentAnonymousUsers,
|
data.WebServiceCurrentAnonymousUsers,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentBlockedAsyncIORequests,
|
c.webServiceCurrentBlockedAsyncIORequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.WebServiceCurrentBlockedAsyncIORequests,
|
data.WebServiceCurrentBlockedAsyncIORequests,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentCGIRequests,
|
c.webServiceCurrentCGIRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.WebServiceCurrentCGIRequests,
|
data.WebServiceCurrentCGIRequests,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentConnections,
|
c.webServiceCurrentConnections,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.WebServiceCurrentConnections,
|
data.WebServiceCurrentConnections,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentISAPIExtensionRequests,
|
c.webServiceCurrentISAPIExtensionRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.WebServiceCurrentISAPIExtensionRequests,
|
data.WebServiceCurrentISAPIExtensionRequests,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentNonAnonymousUsers,
|
c.webServiceCurrentNonAnonymousUsers,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.WebServiceCurrentNonAnonymousUsers,
|
data.WebServiceCurrentNonAnonymousUsers,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceServiceUptime,
|
c.webServiceServiceUptime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.WebServiceServiceUptime,
|
data.WebServiceServiceUptime,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalBytesReceived,
|
c.webServiceTotalBytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalBytesReceived,
|
data.WebServiceTotalBytesReceived,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalBytesSent,
|
c.webServiceTotalBytesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalBytesSent,
|
data.WebServiceTotalBytesSent,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalAnonymousUsers,
|
c.webServiceTotalAnonymousUsers,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalAnonymousUsers,
|
data.WebServiceTotalAnonymousUsers,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalBlockedAsyncIORequests,
|
c.webServiceTotalBlockedAsyncIORequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalBlockedAsyncIORequests,
|
data.WebServiceTotalBlockedAsyncIORequests,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalCGIRequests,
|
c.webServiceTotalCGIRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalCGIRequests,
|
data.WebServiceTotalCGIRequests,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalConnectionAttemptsAllInstances,
|
c.webServiceTotalConnectionAttemptsAllInstances,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalConnectionAttemptsAllInstances,
|
data.WebServiceTotalConnectionAttemptsAllInstances,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalFilesReceived,
|
c.webServiceTotalFilesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalFilesReceived,
|
data.WebServiceTotalFilesReceived,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalFilesSent,
|
c.webServiceTotalFilesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalFilesSent,
|
data.WebServiceTotalFilesSent,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalISAPIExtensionRequests,
|
c.webServiceTotalISAPIExtensionRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalISAPIExtensionRequests,
|
data.WebServiceTotalISAPIExtensionRequests,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalLockedErrors,
|
c.webServiceTotalLockedErrors,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalLockedErrors,
|
data.WebServiceTotalLockedErrors,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalLogonAttempts,
|
c.webServiceTotalLogonAttempts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalLogonAttempts,
|
data.WebServiceTotalLogonAttempts,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalNonAnonymousUsers,
|
c.webServiceTotalNonAnonymousUsers,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalNonAnonymousUsers,
|
data.WebServiceTotalNonAnonymousUsers,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalNotFoundErrors,
|
c.webServiceTotalNotFoundErrors,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalNotFoundErrors,
|
data.WebServiceTotalNotFoundErrors,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRejectedAsyncIORequests,
|
c.webServiceTotalRejectedAsyncIORequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.WebServiceTotalRejectedAsyncIORequests,
|
data.WebServiceTotalRejectedAsyncIORequests,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -389,6 +410,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -396,6 +418,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"COPY",
|
"COPY",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -403,6 +426,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"DELETE",
|
"DELETE",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -410,6 +434,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"GET",
|
"GET",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -417,6 +442,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"HEAD",
|
"HEAD",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -424,6 +450,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"LOCK",
|
"LOCK",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -431,6 +458,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"MKCOL",
|
"MKCOL",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -438,6 +466,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"MOVE",
|
"MOVE",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -445,6 +474,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"OPTIONS",
|
"OPTIONS",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -452,6 +482,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"POST",
|
"POST",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -459,6 +490,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"PROPFIND",
|
"PROPFIND",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -466,6 +498,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"PROPPATCH",
|
"PROPPATCH",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -473,6 +506,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"PUT",
|
"PUT",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -480,6 +514,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"SEARCH",
|
"SEARCH",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -487,6 +522,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
|||||||
data.Name,
|
data.Name,
|
||||||
"TRACE",
|
"TRACE",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ type collectorWebServiceCache struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type perfDataCounterServiceCache struct {
|
type perfDataCounterServiceCache struct {
|
||||||
Name string
|
|
||||||
|
|
||||||
ServiceCacheActiveFlushedEntries float64 `perfdata:"Active Flushed Entries"`
|
ServiceCacheActiveFlushedEntries float64 `perfdata:"Active Flushed Entries"`
|
||||||
ServiceCacheCurrentFileCacheMemoryUsage float64 `perfdata:"Current File Cache Memory Usage"`
|
ServiceCacheCurrentFileCacheMemoryUsage float64 `perfdata:"Current File Cache Memory Usage"`
|
||||||
ServiceCacheMaximumFileCacheMemoryUsage float64 `perfdata:"Maximum 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"`
|
ServiceCacheOutputCacheFlushesTotal float64 `perfdata:"Output Cache Total Flushes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p perfDataCounterServiceCache) GetName() string {
|
|
||||||
return p.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Collector) buildWebServiceCache() error {
|
func (c *Collector) buildWebServiceCache() error {
|
||||||
var err 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)
|
return fmt.Errorf("failed to collect Web Service Cache metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deduplicateIISNames(c.perfDataObjectServiceCache)
|
|
||||||
|
|
||||||
for _, data := range c.perfDataObjectServiceCache {
|
for _, data := range c.perfDataObjectServiceCache {
|
||||||
if c.config.SiteExclude.MatchString(data.Name) || !c.config.SiteInclude.MatchString(data.Name) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheActiveFlushedEntries,
|
c.serviceCacheActiveFlushedEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ServiceCacheActiveFlushedEntries,
|
data.ServiceCacheActiveFlushedEntries,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheCurrentFileCacheMemoryUsage,
|
c.serviceCacheCurrentFileCacheMemoryUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ServiceCacheCurrentFileCacheMemoryUsage,
|
data.ServiceCacheCurrentFileCacheMemoryUsage,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMaximumFileCacheMemoryUsage,
|
c.serviceCacheMaximumFileCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheMaximumFileCacheMemoryUsage,
|
data.ServiceCacheMaximumFileCacheMemoryUsage,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFileCacheFlushesTotal,
|
c.serviceCacheFileCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheFileCacheFlushesTotal,
|
data.ServiceCacheFileCacheFlushesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFileCacheQueriesTotal,
|
c.serviceCacheFileCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheFileCacheHitsTotal+data.ServiceCacheFileCacheMissesTotal,
|
data.ServiceCacheFileCacheHitsTotal+data.ServiceCacheFileCacheMissesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFileCacheHitsTotal,
|
c.serviceCacheFileCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheFileCacheHitsTotal,
|
data.ServiceCacheFileCacheHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFilesCached,
|
c.serviceCacheFilesCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ServiceCacheFilesCached,
|
data.ServiceCacheFilesCached,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFilesCachedTotal,
|
c.serviceCacheFilesCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheFilesCachedTotal,
|
data.ServiceCacheFilesCachedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFilesFlushedTotal,
|
c.serviceCacheFilesFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheFilesFlushedTotal,
|
data.ServiceCacheFilesFlushedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheFlushesTotal,
|
c.serviceCacheURICacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURICacheFlushesTotal,
|
data.ServiceCacheURICacheFlushesTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheFlushesTotal,
|
c.serviceCacheURICacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURICacheFlushesTotalKernel,
|
data.ServiceCacheURICacheFlushesTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheQueriesTotal,
|
c.serviceCacheURICacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURICacheHitsTotal+data.ServiceCacheURICacheMissesTotal,
|
data.ServiceCacheURICacheHitsTotal+data.ServiceCacheURICacheMissesTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheQueriesTotal,
|
c.serviceCacheURICacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURICacheHitsTotalKernel+data.ServiceCacheURICacheMissesTotalKernel,
|
data.ServiceCacheURICacheHitsTotalKernel+data.ServiceCacheURICacheMissesTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheHitsTotal,
|
c.serviceCacheURICacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURICacheHitsTotal,
|
data.ServiceCacheURICacheHitsTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheHitsTotal,
|
c.serviceCacheURICacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURICacheHitsTotalKernel,
|
data.ServiceCacheURICacheHitsTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCached,
|
c.serviceCacheURIsCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ServiceCacheURIsCached,
|
data.ServiceCacheURIsCached,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCached,
|
c.serviceCacheURIsCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ServiceCacheURIsCachedKernel,
|
data.ServiceCacheURIsCachedKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCachedTotal,
|
c.serviceCacheURIsCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURIsCachedTotal,
|
data.ServiceCacheURIsCachedTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCachedTotal,
|
c.serviceCacheURIsCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURIsCachedTotalKernel,
|
data.ServiceCacheURIsCachedTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsFlushedTotal,
|
c.serviceCacheURIsFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURIsFlushedTotal,
|
data.ServiceCacheURIsFlushedTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsFlushedTotal,
|
c.serviceCacheURIsFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheURIsFlushedTotalKernel,
|
data.ServiceCacheURIsFlushedTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCached,
|
c.serviceCacheMetadataCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ServiceCacheMetadataCached,
|
data.ServiceCacheMetadataCached,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCacheFlushes,
|
c.serviceCacheMetadataCacheFlushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheMetadataCacheFlushes,
|
data.ServiceCacheMetadataCacheFlushes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCacheQueriesTotal,
|
c.serviceCacheMetadataCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheMetaDataCacheHits+data.ServiceCacheMetaDataCacheMisses,
|
data.ServiceCacheMetaDataCacheHits+data.ServiceCacheMetaDataCacheMisses,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCacheHitsTotal,
|
c.serviceCacheMetadataCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
0, // data.ServiceCacheMetadataCacheHitsTotal,
|
0, // data.ServiceCacheMetadataCacheHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCachedTotal,
|
c.serviceCacheMetadataCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheMetadataCachedTotal,
|
data.ServiceCacheMetadataCachedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataFlushedTotal,
|
c.serviceCacheMetadataFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheMetadataFlushedTotal,
|
data.ServiceCacheMetadataFlushedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheActiveFlushedItems,
|
c.serviceCacheOutputCacheActiveFlushedItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheOutputCacheActiveFlushedItems,
|
data.ServiceCacheOutputCacheActiveFlushedItems,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheItems,
|
c.serviceCacheOutputCacheItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheOutputCacheItems,
|
data.ServiceCacheOutputCacheItems,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheMemoryUsage,
|
c.serviceCacheOutputCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheOutputCacheMemoryUsage,
|
data.ServiceCacheOutputCacheMemoryUsage,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheQueriesTotal,
|
c.serviceCacheOutputCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheOutputCacheHitsTotal+data.ServiceCacheOutputCacheMissesTotal,
|
data.ServiceCacheOutputCacheHitsTotal+data.ServiceCacheOutputCacheMissesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheHitsTotal,
|
c.serviceCacheOutputCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheOutputCacheHitsTotal,
|
data.ServiceCacheOutputCacheHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheFlushedItemsTotal,
|
c.serviceCacheOutputCacheFlushedItemsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.ServiceCacheOutputCacheFlushedItemsTotal,
|
data.ServiceCacheOutputCacheFlushedItemsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheFlushesTotal,
|
c.serviceCacheOutputCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -18,16 +18,22 @@
|
|||||||
package logical_disk
|
package logical_disk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"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/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
@@ -35,15 +41,23 @@ import (
|
|||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Name = "logical_disk"
|
const (
|
||||||
|
Name = "logical_disk"
|
||||||
|
subCollectorMetrics = "metrics"
|
||||||
|
subCollectorBitlocker = "bitlocker_status"
|
||||||
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
VolumeInclude *regexp.Regexp `yaml:"volume-include"`
|
CollectorsEnabled []string `yaml:"enabled"`
|
||||||
VolumeExclude *regexp.Regexp `yaml:"volume-exclude"`
|
VolumeInclude *regexp.Regexp `yaml:"volume-include"`
|
||||||
|
VolumeExclude *regexp.Regexp `yaml:"volume-exclude"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
//nolint:gochecknoglobals
|
||||||
var ConfigDefaults = Config{
|
var ConfigDefaults = Config{
|
||||||
|
CollectorsEnabled: []string{
|
||||||
|
subCollectorMetrics,
|
||||||
|
},
|
||||||
VolumeInclude: types.RegExpAny,
|
VolumeInclude: types.RegExpAny,
|
||||||
VolumeExclude: types.RegExpEmpty,
|
VolumeExclude: types.RegExpEmpty,
|
||||||
}
|
}
|
||||||
@@ -56,6 +70,14 @@ type Collector struct {
|
|||||||
perfDataCollector *pdh.Collector
|
perfDataCollector *pdh.Collector
|
||||||
perfDataObject []perfDataCounterValues
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
|
bitlockerReqCh chan string
|
||||||
|
bitlockerResCh chan struct {
|
||||||
|
err error
|
||||||
|
status int
|
||||||
|
}
|
||||||
|
|
||||||
|
ctxCancelFunc context.CancelFunc
|
||||||
|
|
||||||
avgReadQueue *prometheus.Desc
|
avgReadQueue *prometheus.Desc
|
||||||
avgWriteQueue *prometheus.Desc
|
avgWriteQueue *prometheus.Desc
|
||||||
freeSpace *prometheus.Desc
|
freeSpace *prometheus.Desc
|
||||||
@@ -74,6 +96,8 @@ type Collector struct {
|
|||||||
writeLatency *prometheus.Desc
|
writeLatency *prometheus.Desc
|
||||||
writesTotal *prometheus.Desc
|
writesTotal *prometheus.Desc
|
||||||
writeTime *prometheus.Desc
|
writeTime *prometheus.Desc
|
||||||
|
|
||||||
|
bitlockerStatus *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
type volumeInfo struct {
|
type volumeInfo struct {
|
||||||
@@ -109,8 +133,9 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
c := &Collector{
|
c := &Collector{
|
||||||
config: ConfigDefaults,
|
config: ConfigDefaults,
|
||||||
}
|
}
|
||||||
|
c.config.CollectorsEnabled = make([]string, 0)
|
||||||
|
|
||||||
var volumeExclude, volumeInclude string
|
var collectorsEnabled, volumeExclude, volumeInclude string
|
||||||
|
|
||||||
app.Flag(
|
app.Flag(
|
||||||
"collector.logical_disk.volume-exclude",
|
"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.",
|
"Regexp of volumes to include. Volume name must both match include and not match exclude to be included.",
|
||||||
).Default(".+").StringVar(&volumeInclude)
|
).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 {
|
app.Action(func(*kingpin.ParseContext) error {
|
||||||
|
c.config.CollectorsEnabled = strings.Split(collectorsEnabled, ",")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.config.VolumeExclude, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", volumeExclude))
|
c.config.VolumeExclude, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", volumeExclude))
|
||||||
@@ -146,12 +181,24 @@ func (c *Collector) GetName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Close() error {
|
func (c *Collector) Close() error {
|
||||||
|
if slices.Contains(c.config.CollectorsEnabled, subCollectorBitlocker) {
|
||||||
|
c.ctxCancelFunc()
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||||
c.logger = logger.With(slog.String("collector", Name))
|
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(
|
c.information = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
||||||
"A metric with a constant '1' value labeled with logical disk information",
|
"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,
|
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
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "LogicalDisk", pdh.InstancesAll)
|
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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,117 +398,156 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
info.serialNumber,
|
info.serialNumber,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
if slices.Contains(c.config.CollectorsEnabled, subCollectorMetrics) {
|
||||||
c.requestsQueued,
|
ch <- prometheus.MustNewConstMetric(
|
||||||
prometheus.GaugeValue,
|
c.requestsQueued,
|
||||||
data.CurrentDiskQueueLength,
|
prometheus.GaugeValue,
|
||||||
data.Name,
|
data.CurrentDiskQueueLength,
|
||||||
)
|
data.Name,
|
||||||
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.avgReadQueue,
|
c.avgReadQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.AvgDiskReadQueueLength*pdh.TicksToSecondScaleFactor,
|
data.AvgDiskReadQueueLength*pdh.TicksToSecondScaleFactor,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.avgWriteQueue,
|
c.avgWriteQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.AvgDiskWriteQueueLength*pdh.TicksToSecondScaleFactor,
|
data.AvgDiskWriteQueueLength*pdh.TicksToSecondScaleFactor,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readBytesTotal,
|
c.readBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.DiskReadBytesPerSec,
|
data.DiskReadBytesPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readsTotal,
|
c.readsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.DiskReadsPerSec,
|
data.DiskReadsPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeBytesTotal,
|
c.writeBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.DiskWriteBytesPerSec,
|
data.DiskWriteBytesPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writesTotal,
|
c.writesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.DiskWritesPerSec,
|
data.DiskWritesPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readTime,
|
c.readTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PercentDiskReadTime,
|
data.PercentDiskReadTime,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeTime,
|
c.writeTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PercentDiskWriteTime,
|
data.PercentDiskWriteTime,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.freeSpace,
|
c.freeSpace,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.FreeSpace*1024*1024,
|
data.FreeSpace*1024*1024,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalSpace,
|
c.totalSpace,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PercentFreeSpace*1024*1024,
|
data.PercentFreeSpace*1024*1024,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.idleTime,
|
c.idleTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PercentIdleTime,
|
data.PercentIdleTime,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.splitIOs,
|
c.splitIOs,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.SplitIOPerSec,
|
data.SplitIOPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readLatency,
|
c.readLatency,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.AvgDiskSecPerRead*pdh.TicksToSecondScaleFactor,
|
data.AvgDiskSecPerRead*pdh.TicksToSecondScaleFactor,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeLatency,
|
c.writeLatency,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.AvgDiskSecPerWrite*pdh.TicksToSecondScaleFactor,
|
data.AvgDiskSecPerWrite*pdh.TicksToSecondScaleFactor,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readWriteLatency,
|
c.readWriteLatency,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.AvgDiskSecPerTransfer*pdh.TicksToSecondScaleFactor,
|
data.AvgDiskSecPerTransfer*pdh.TicksToSecondScaleFactor,
|
||||||
data.Name,
|
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
|
return nil
|
||||||
@@ -590,6 +702,11 @@ func getAllMountedVolumes() (map[string]string, error) {
|
|||||||
break
|
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) {
|
if errors.Is(err, windows.ERROR_NO_MORE_FILES) {
|
||||||
rootPathBuf = make([]uint16, (rootPathLen+1)/2)
|
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), `\`)
|
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.
|
// A Collector is a Prometheus Collector for WMI MSCluster_Cluster metrics.
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
|
||||||
miSession *mi.Session
|
|
||||||
|
|
||||||
collectorCluster
|
collectorCluster
|
||||||
collectorNetwork
|
collectorNetwork
|
||||||
collectorNode
|
collectorNode
|
||||||
collectorResource
|
collectorResource
|
||||||
collectorResourceGroup
|
collectorResourceGroup
|
||||||
|
|
||||||
|
config Config
|
||||||
|
miSession *mi.Session
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ func (c *Collector) collectResource(ch chan<- prometheus.Metric, nodeNames []str
|
|||||||
if v.OwnerNode == nodeName {
|
if v.OwnerNode == nodeName {
|
||||||
isCurrentState = 1.0
|
isCurrentState = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.resourceOwnerNode,
|
c.resourceOwnerNode,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ func (c *Collector) collectResourceGroup(ch chan<- prometheus.Metric, nodeNames
|
|||||||
if v.OwnerNode == nodeName {
|
if v.OwnerNode == nodeName {
|
||||||
isCurrentState = 1.0
|
isCurrentState = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.resourceGroupOwnerNode,
|
c.resourceGroupOwnerNode,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -78,18 +78,6 @@ var ConfigDefaults = Config{
|
|||||||
|
|
||||||
// A Collector is a Prometheus Collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics.
|
// A Collector is a Prometheus Collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics.
|
||||||
type Collector struct {
|
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
|
collectorAccessMethods
|
||||||
collectorAvailabilityReplica
|
collectorAvailabilityReplica
|
||||||
collectorBufferManager
|
collectorBufferManager
|
||||||
@@ -103,6 +91,18 @@ type Collector struct {
|
|||||||
collectorSQLStats
|
collectorSQLStats
|
||||||
collectorTransactions
|
collectorTransactions
|
||||||
collectorWaitStats
|
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 {
|
func New(config *Config) *Collector {
|
||||||
@@ -405,6 +405,7 @@ func (c *Collector) collect(
|
|||||||
duration.Seconds(),
|
duration.Seconds(),
|
||||||
collector, sqlInstance.name,
|
collector, sqlInstance.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.mssqlScrapeSuccessDesc,
|
c.mssqlScrapeSuccessDesc,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ type perfDataCounterValuesAccessMethods struct {
|
|||||||
AccessMethodsWorkfilesCreatedPerSec float64 `perfdata:"Workfiles Created/sec"`
|
AccessMethodsWorkfilesCreatedPerSec float64 `perfdata:"Workfiles Created/sec"`
|
||||||
AccessMethodsWorktablesCreatedPerSec float64 `perfdata:"Worktables Created/sec"`
|
AccessMethodsWorktablesCreatedPerSec float64 `perfdata:"Worktables Created/sec"`
|
||||||
AccessMethodsWorktablesFromCacheRatio float64 `perfdata:"Worktables From Cache Ratio"`
|
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 {
|
func (c *Collector) buildAccessMethods() error {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ type collectorBufferManager struct {
|
|||||||
type perfDataCounterValuesBufMan struct {
|
type perfDataCounterValuesBufMan struct {
|
||||||
BufManBackgroundWriterPagesPerSec float64 `perfdata:"Background writer pages/sec"`
|
BufManBackgroundWriterPagesPerSec float64 `perfdata:"Background writer pages/sec"`
|
||||||
BufManBufferCacheHitRatio float64 `perfdata:"Buffer cache hit ratio"`
|
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"`
|
BufManCheckpointPagesPerSec float64 `perfdata:"Checkpoint pages/sec"`
|
||||||
BufManDatabasePages float64 `perfdata:"Database pages"`
|
BufManDatabasePages float64 `perfdata:"Database pages"`
|
||||||
BufManExtensionAllocatedPages float64 `perfdata:"Extension allocated pages"`
|
BufManExtensionAllocatedPages float64 `perfdata:"Extension allocated pages"`
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ type perfDataCounterValuesDatabases struct {
|
|||||||
DatabasesGroupCommitTimePerSec float64 `perfdata:"Group Commit Time/sec"`
|
DatabasesGroupCommitTimePerSec float64 `perfdata:"Group Commit Time/sec"`
|
||||||
DatabasesLogBytesFlushedPerSec float64 `perfdata:"Log Bytes Flushed/sec"`
|
DatabasesLogBytesFlushedPerSec float64 `perfdata:"Log Bytes Flushed/sec"`
|
||||||
DatabasesLogCacheHitRatio float64 `perfdata:"Log Cache Hit Ratio"`
|
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"`
|
DatabasesLogCacheReadsPerSec float64 `perfdata:"Log Cache Reads/sec"`
|
||||||
DatabasesLogFilesSizeKB float64 `perfdata:"Log File(s) Size (KB)"`
|
DatabasesLogFilesSizeKB float64 `perfdata:"Log File(s) Size (KB)"`
|
||||||
DatabasesLogFilesUsedSizeKB float64 `perfdata:"Log File(s) Used Size (KB)"`
|
DatabasesLogFilesUsedSizeKB float64 `perfdata:"Log File(s) Used Size (KB)"`
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ type perfDataCounterValuesLocks struct {
|
|||||||
Name string
|
Name string
|
||||||
|
|
||||||
LocksAverageWaitTimeMS float64 `perfdata:"Average Wait Time (ms)"`
|
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"`
|
LocksLockRequestsPerSec float64 `perfdata:"Lock Requests/sec"`
|
||||||
LocksLockTimeoutsPerSec float64 `perfdata:"Lock Timeouts/sec"`
|
LocksLockTimeoutsPerSec float64 `perfdata:"Lock Timeouts/sec"`
|
||||||
LocksLockTimeoutsTimeout0PerSec float64 `perfdata:"Lock Timeouts (timeout > 0)/sec"`
|
LocksLockTimeoutsTimeout0PerSec float64 `perfdata:"Lock Timeouts (timeout > 0)/sec"`
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func newMssqlInstance(key, name string) (mssqlInstance, error) {
|
|||||||
_ = key.Close()
|
_ = key.Close()
|
||||||
}(k)
|
}(k)
|
||||||
|
|
||||||
patchVersion, _, err := k.GetStringValue("Version")
|
patchVersion, _, err := k.GetStringValue("PatchLevel")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return mssqlInstance{}, fmt.Errorf("couldn't get version from registry: %w", err)
|
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.BytesReceivedPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bytesSentTotal,
|
c.bytesSentTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.BytesSentPerSec,
|
data.BytesSentPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bytesTotal,
|
c.bytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.BytesTotalPerSec,
|
data.BytesTotalPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.outputQueueLength,
|
c.outputQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.OutputQueueLength,
|
data.OutputQueueLength,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsOutboundDiscarded,
|
c.packetsOutboundDiscarded,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsOutboundDiscarded,
|
data.PacketsOutboundDiscarded,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsOutboundErrors,
|
c.packetsOutboundErrors,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsOutboundErrors,
|
data.PacketsOutboundErrors,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsTotal,
|
c.packetsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsPerSec,
|
data.PacketsPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsReceivedDiscarded,
|
c.packetsReceivedDiscarded,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsReceivedDiscarded,
|
data.PacketsReceivedDiscarded,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsReceivedErrors,
|
c.packetsReceivedErrors,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsReceivedErrors,
|
data.PacketsReceivedErrors,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsReceivedTotal,
|
c.packetsReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsReceivedPerSec,
|
data.PacketsReceivedPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsReceivedUnknown,
|
c.packetsReceivedUnknown,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsReceivedUnknown,
|
data.PacketsReceivedUnknown,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsSentTotal,
|
c.packetsSentTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PacketsSentPerSec,
|
data.PacketsSentPerSec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentBandwidth,
|
c.currentBandwidth,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -23,17 +23,13 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"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/headers/sysinfoapi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/osversion"
|
"github.com/prometheus-community/windows_exporter/internal/osversion"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"golang.org/x/sys/windows"
|
|
||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -50,38 +46,6 @@ type Collector struct {
|
|||||||
|
|
||||||
hostname *prometheus.Desc
|
hostname *prometheus.Desc
|
||||||
osInformation *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 {
|
func New(config *Config) *Collector {
|
||||||
@@ -108,12 +72,7 @@ func (c *Collector) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *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),
|
|
||||||
)
|
|
||||||
|
|
||||||
productName, revision, err := c.getWindowsVersion()
|
productName, revision, err := c.getWindowsVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get Windows version: %w", err)
|
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,
|
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
|
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 {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
errs := make([]error, 0)
|
errs := make([]error, 0)
|
||||||
|
|
||||||
c.collect(ch)
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.osInformation,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
1.0,
|
||||||
|
)
|
||||||
|
|
||||||
if err := c.collectHostname(ch); err != nil {
|
if err := c.collectHostname(ch); err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to collect hostname metrics: %w", err))
|
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...)
|
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 {
|
func (c *Collector) collectHostname(ch chan<- prometheus.Metric) error {
|
||||||
hostname, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSHostname)
|
hostname, err := sysinfoapi.GetComputerName(sysinfoapi.ComputerNameDNSHostname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -278,87 +159,6 @@ func (c *Collector) collectHostname(ch chan<- prometheus.Metric) error {
|
|||||||
return nil
|
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) {
|
func (c *Collector) getWindowsVersion() (string, string, error) {
|
||||||
// Get build number and product name from registry
|
// Get build number and product name from registry
|
||||||
ntKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
ntKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ type Config struct {
|
|||||||
ProcessInclude *regexp.Regexp `yaml:"include"`
|
ProcessInclude *regexp.Regexp `yaml:"include"`
|
||||||
ProcessExclude *regexp.Regexp `yaml:"exclude"`
|
ProcessExclude *regexp.Regexp `yaml:"exclude"`
|
||||||
EnableWorkerProcess bool `yaml:"iis"`
|
EnableWorkerProcess bool `yaml:"iis"`
|
||||||
|
EnableCMDLine bool `yaml:"cmdline"`
|
||||||
CounterVersion uint8 `yaml:"counter-version"`
|
CounterVersion uint8 `yaml:"counter-version"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ var ConfigDefaults = Config{
|
|||||||
ProcessInclude: types.RegExpAny,
|
ProcessInclude: types.RegExpAny,
|
||||||
ProcessExclude: types.RegExpEmpty,
|
ProcessExclude: types.RegExpEmpty,
|
||||||
EnableWorkerProcess: false,
|
EnableWorkerProcess: false,
|
||||||
|
EnableCMDLine: true,
|
||||||
CounterVersion: 0,
|
CounterVersion: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,8 +83,6 @@ type Collector struct {
|
|||||||
poolBytes *prometheus.Desc
|
poolBytes *prometheus.Desc
|
||||||
priorityBase *prometheus.Desc
|
priorityBase *prometheus.Desc
|
||||||
privateBytes *prometheus.Desc
|
privateBytes *prometheus.Desc
|
||||||
// Deprecated: Use start_time_seconds_timestamp instead
|
|
||||||
startTimeOld *prometheus.Desc
|
|
||||||
startTime *prometheus.Desc
|
startTime *prometheus.Desc
|
||||||
threadCount *prometheus.Desc
|
threadCount *prometheus.Desc
|
||||||
virtualBytes *prometheus.Desc
|
virtualBytes *prometheus.Desc
|
||||||
@@ -133,6 +133,11 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
"Enable IIS collectWorker process name queries. May cause the collector to leak memory.",
|
"Enable IIS collectWorker process name queries. May cause the collector to leak memory.",
|
||||||
).Default(strconv.FormatBool(c.config.EnableWorkerProcess)).BoolVar(&c.config.EnableWorkerProcess)
|
).Default(strconv.FormatBool(c.config.EnableWorkerProcess)).BoolVar(&c.config.EnableWorkerProcess)
|
||||||
|
|
||||||
|
app.Flag(
|
||||||
|
"collector.process.cmdline",
|
||||||
|
"If enabled, the full cmdline is exposed to the windows_process_info metrics.",
|
||||||
|
).Default(strconv.FormatBool(c.config.EnableCMDLine)).BoolVar(&c.config.EnableCMDLine)
|
||||||
|
|
||||||
app.Flag(
|
app.Flag(
|
||||||
"collector.process.counter-version",
|
"collector.process.counter-version",
|
||||||
"Version of the process collector to use. 1 for Process V1, 2 for Process V2. Defaults to 0 which will use the latest version available.",
|
"Version of the process collector to use. 1 for Process V1, 2 for Process V2. Defaults to 0 which will use the latest version available.",
|
||||||
@@ -180,20 +185,6 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
|||||||
|
|
||||||
var err 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 {
|
switch c.config.CounterVersion {
|
||||||
case 2:
|
case 2:
|
||||||
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Process V2", pdh.InstancesAll)
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Process V2", pdh.InstancesAll)
|
||||||
@@ -235,13 +226,6 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
|||||||
nil,
|
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(
|
c.startTime = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "start_time_seconds_timestamp"),
|
prometheus.BuildFQName(types.Namespace, Name, "start_time_seconds_timestamp"),
|
||||||
"Time of process start.",
|
"Time of process start.",
|
||||||
@@ -333,6 +317,28 @@ func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
|
|||||||
nil,
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,19 +422,25 @@ func (c *Collector) getExtendedProcessInformation(hProcess windows.Handle) (stri
|
|||||||
return "", 0, fmt.Errorf("failed to read process memory: %w", err)
|
return "", 0, fmt.Errorf("failed to read process memory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdLineUTF16 := make([]uint16, processParameters.CommandLine.Length)
|
var cmdLine string
|
||||||
|
|
||||||
err = windows.ReadProcessMemory(hProcess,
|
if c.config.EnableCMDLine {
|
||||||
uintptr(unsafe.Pointer(processParameters.CommandLine.Buffer)),
|
cmdLineUTF16 := make([]uint16, processParameters.CommandLine.Length)
|
||||||
(*byte)(unsafe.Pointer(&cmdLineUTF16[0])),
|
|
||||||
uintptr(processParameters.CommandLine.Length),
|
err = windows.ReadProcessMemory(hProcess,
|
||||||
nil,
|
uintptr(unsafe.Pointer(processParameters.CommandLine.Buffer)),
|
||||||
)
|
(*byte)(unsafe.Pointer(&cmdLineUTF16[0])),
|
||||||
if err != nil {
|
uintptr(processParameters.CommandLine.Length),
|
||||||
return "", processParameters.ProcessGroupId, fmt.Errorf("failed to read process memory: %w", err)
|
nil,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return "", processParameters.ProcessGroupId, fmt.Errorf("failed to read process memory: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdLine = strings.TrimSpace(windows.UTF16ToString(cmdLineUTF16))
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.TrimSpace(windows.UTF16ToString(cmdLineUTF16)), processParameters.ProcessGroupId, nil
|
return cmdLine, processParameters.ProcessGroupId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) getProcessOwner(logger *slog.Logger, hProcess windows.Handle) (string, error) {
|
func (c *Collector) getProcessOwner(logger *slog.Logger, hProcess windows.Handle) (string, error) {
|
||||||
|
|||||||
@@ -45,10 +45,12 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error {
|
|||||||
return fmt.Errorf("failed to collect metrics: %w", err)
|
return fmt.Errorf("failed to collect metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = nil
|
||||||
|
|
||||||
var workerProcesses []WorkerProcess
|
var workerProcesses []WorkerProcess
|
||||||
if c.config.EnableWorkerProcess {
|
if c.config.EnableWorkerProcess {
|
||||||
if err := c.miSession.Query(&workerProcesses, mi.NamespaceRootWebAdministration, c.workerProcessMIQueryQuery); err != nil {
|
if err = c.miSession.Query(&workerProcesses, mi.NamespaceRootWebAdministration, c.workerProcessMIQueryQuery); err != nil {
|
||||||
return fmt.Errorf("WMI query failed: %w", err)
|
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()
|
wg.Wait()
|
||||||
|
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectWorker() {
|
func (c *Collector) collectWorker() {
|
||||||
@@ -142,14 +144,12 @@ func (c *Collector) collectWorker() {
|
|||||||
name, pidString, parentPID, strconv.Itoa(int(processGroupID)), processOwner, cmdLine,
|
name, pidString, parentPID, strconv.Itoa(int(processGroupID)), processOwner, cmdLine,
|
||||||
)
|
)
|
||||||
|
|
||||||
startTime := float64(time.Now().Unix() - int64(data.ElapsedTime))
|
startTime := data.ElapsedTime
|
||||||
|
if c.config.CounterVersion == 2 {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
// For V2, the ElapsedTime is in seconds, so we need to convert it to a timestamp.
|
||||||
c.startTimeOld,
|
// The start time is the current time minus the elapsed time.
|
||||||
prometheus.GaugeValue,
|
startTime = float64(time.Now().UnixMicro())/1e6 - data.ElapsedTime
|
||||||
startTime,
|
}
|
||||||
name, pidString,
|
|
||||||
)
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.startTime,
|
c.startTime,
|
||||||
|
|||||||
@@ -280,60 +280,70 @@ func (c *Collector) collectRemoteFXNetworkCount(ch chan<- prometheus.Metric) err
|
|||||||
utils.MilliSecToSec(data.BaseTCPRTT),
|
utils.MilliSecToSec(data.BaseTCPRTT),
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.baseUDPRTT,
|
c.baseUDPRTT,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.BaseUDPRTT),
|
utils.MilliSecToSec(data.BaseUDPRTT),
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentTCPBandwidth,
|
c.currentTCPBandwidth,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
(data.CurrentTCPBandwidth*1000)/8,
|
(data.CurrentTCPBandwidth*1000)/8,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentTCPRTT,
|
c.currentTCPRTT,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.CurrentTCPRTT),
|
utils.MilliSecToSec(data.CurrentTCPRTT),
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentUDPBandwidth,
|
c.currentUDPBandwidth,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
(data.CurrentUDPBandwidth*1000)/8,
|
(data.CurrentUDPBandwidth*1000)/8,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentUDPRTT,
|
c.currentUDPRTT,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data.CurrentUDPRTT),
|
utils.MilliSecToSec(data.CurrentUDPRTT),
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalReceivedBytes,
|
c.totalReceivedBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalReceivedBytes,
|
data.TotalReceivedBytes,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalSentBytes,
|
c.totalSentBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.TotalSentBytes,
|
data.TotalSentBytes,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.udpPacketsReceivedPerSec,
|
c.udpPacketsReceivedPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.UDPPacketsReceivedPersec,
|
data.UDPPacketsReceivedPersec,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.udpPacketsSentPerSec,
|
c.udpPacketsSentPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.UDPPacketsSentPersec,
|
data.UDPPacketsSentPersec,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.fecRate,
|
c.fecRate,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -378,12 +388,14 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
|||||||
utils.MilliSecToSec(data.AverageEncodingTime),
|
utils.MilliSecToSec(data.AverageEncodingTime),
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.frameQuality,
|
c.frameQuality,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.FrameQuality,
|
data.FrameQuality,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.framesSkippedPerSecondInsufficientResources,
|
c.framesSkippedPerSecondInsufficientResources,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -391,6 +403,7 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
|||||||
sessionName,
|
sessionName,
|
||||||
"client",
|
"client",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.framesSkippedPerSecondInsufficientResources,
|
c.framesSkippedPerSecondInsufficientResources,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -398,6 +411,7 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
|||||||
sessionName,
|
sessionName,
|
||||||
"network",
|
"network",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.framesSkippedPerSecondInsufficientResources,
|
c.framesSkippedPerSecondInsufficientResources,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -405,24 +419,28 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric)
|
|||||||
sessionName,
|
sessionName,
|
||||||
"server",
|
"server",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.graphicsCompressionRatio,
|
c.graphicsCompressionRatio,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.GraphicsCompressionratio,
|
data.GraphicsCompressionratio,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.inputFramesPerSecond,
|
c.inputFramesPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.InputFramesPerSecond,
|
data.InputFramesPerSecond,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.outputFramesPerSecond,
|
c.outputFramesPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.OutputFramesPerSecond,
|
data.OutputFramesPerSecond,
|
||||||
sessionName,
|
sessionName,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sourceFramesPerSecond,
|
c.sourceFramesPerSecond,
|
||||||
prometheus.CounterValue,
|
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(
|
c.info = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
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) {
|
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)
|
serviceName := windows.UTF16PtrToString(service.ServiceName)
|
||||||
|
|
||||||
if c.config.ServiceExclude.MatchString(serviceName) || !c.config.ServiceInclude.MatchString(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] {
|
if startMode == c.apiStartModeValues[serviceConfig.StartType] {
|
||||||
isCurrentStartMode = 1.0
|
isCurrentStartMode = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.startMode,
|
c.startMode,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -375,6 +385,8 @@ func (c *Collector) queryAllServices() ([]windows.ENUM_SERVICE_STATUS_PROCESS, e
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
clear(c.queryAllServicesBuffer)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
currentBufferSize := uint32(cap(c.queryAllServicesBuffer))
|
currentBufferSize := uint32(cap(c.queryAllServicesBuffer))
|
||||||
|
|
||||||
@@ -390,7 +402,6 @@ func (c *Collector) queryAllServices() ([]windows.ENUM_SERVICE_STATUS_PROCESS, e
|
|||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -432,7 +443,6 @@ func (c *Collector) getProcessStartTime(pid uint32) (uint64, error) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
err = windows.GetProcessTimes(handle, &creation, &exit, &krn, &user)
|
err = windows.GetProcessTimes(handle, &creation, &exit, &krn, &user)
|
||||||
|
|
||||||
if err := windows.CloseHandle(handle); err != nil {
|
if err := windows.CloseHandle(handle); err != nil {
|
||||||
c.logger.LogAttrs(context.Background(), slog.LevelWarn, "failed to close process handle",
|
c.logger.LogAttrs(context.Background(), slog.LevelWarn, "failed to close process handle",
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
|
|||||||
@@ -52,10 +52,8 @@ type Collector struct {
|
|||||||
processes *prometheus.Desc
|
processes *prometheus.Desc
|
||||||
processesLimit *prometheus.Desc
|
processesLimit *prometheus.Desc
|
||||||
systemCallsTotal *prometheus.Desc
|
systemCallsTotal *prometheus.Desc
|
||||||
// Deprecated: Use windows_system_boot_time_timestamp instead
|
bootTime *prometheus.Desc
|
||||||
bootTimeSeconds *prometheus.Desc
|
threads *prometheus.Desc
|
||||||
bootTime *prometheus.Desc
|
|
||||||
threads *prometheus.Desc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
@@ -91,12 +89,6 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
nil,
|
nil,
|
||||||
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(
|
c.contextSwitchesTotal = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "context_switches_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "context_switches_total"),
|
||||||
"Total number of context switches (WMI source: PerfOS_System.ContextSwitchesPersec)",
|
"Total number of context switches (WMI source: PerfOS_System.ContextSwitchesPersec)",
|
||||||
@@ -141,7 +133,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.bootTimeTimestamp = float64(time.Now().Unix() - int64(kernel32.GetTickCount64()/1000))
|
c.bootTimeTimestamp = float64(uint64(time.Now().UnixMilli())-kernel32.GetTickCount64()) / 1000
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@@ -159,6 +151,8 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect System metrics: %w", err)
|
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(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
@@ -166,38 +160,37 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].ContextSwitchesPerSec,
|
c.perfDataObject[0].ContextSwitchesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.exceptionDispatchesTotal,
|
c.exceptionDispatchesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].ExceptionDispatchesPerSec,
|
c.perfDataObject[0].ExceptionDispatchesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorQueueLength,
|
c.processorQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].ProcessorQueueLength,
|
c.perfDataObject[0].ProcessorQueueLength,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processes,
|
c.processes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].Processes,
|
c.perfDataObject[0].Processes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.systemCallsTotal,
|
c.systemCallsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].SystemCallsPerSec,
|
c.perfDataObject[0].SystemCallsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.threads,
|
c.threads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].Threads,
|
c.perfDataObject[0].Threads,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.bootTimeSeconds,
|
|
||||||
prometheus.GaugeValue,
|
|
||||||
c.bootTimeTimestamp,
|
|
||||||
)
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bootTime,
|
c.bootTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -259,48 +259,56 @@ func (c *Collector) writeTCPCounters(ch chan<- prometheus.Metric, metrics []perf
|
|||||||
metrics[0].ConnectionFailures,
|
metrics[0].ConnectionFailures,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsActive,
|
c.connectionsActive,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[0].ConnectionsActive,
|
metrics[0].ConnectionsActive,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsEstablished,
|
c.connectionsEstablished,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
metrics[0].ConnectionsEstablished,
|
metrics[0].ConnectionsEstablished,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsPassive,
|
c.connectionsPassive,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[0].ConnectionsPassive,
|
metrics[0].ConnectionsPassive,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsReset,
|
c.connectionsReset,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[0].ConnectionsReset,
|
metrics[0].ConnectionsReset,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsTotal,
|
c.segmentsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[0].SegmentsPerSec,
|
metrics[0].SegmentsPerSec,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsReceivedTotal,
|
c.segmentsReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[0].SegmentsReceivedPerSec,
|
metrics[0].SegmentsReceivedPerSec,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsRetransmittedTotal,
|
c.segmentsRetransmittedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[0].SegmentsRetransmittedPerSec,
|
metrics[0].SegmentsRetransmittedPerSec,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsSentTotal,
|
c.segmentsSentTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -308,24 +308,28 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
|||||||
data.HandleCount,
|
data.HandleCount,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pageFaultsPerSec,
|
c.pageFaultsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data.PageFaultsPersec,
|
data.PageFaultsPersec,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pageFileBytes,
|
c.pageFileBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PageFileBytes,
|
data.PageFileBytes,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pageFileBytesPeak,
|
c.pageFileBytesPeak,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PageFileBytesPeak,
|
data.PageFileBytesPeak,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.percentCPUTime,
|
c.percentCPUTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -333,6 +337,7 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
|||||||
data.Name,
|
data.Name,
|
||||||
"privileged",
|
"privileged",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.percentCPUTime,
|
c.percentCPUTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -340,6 +345,7 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
|||||||
data.Name,
|
data.Name,
|
||||||
"processor",
|
"processor",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.percentCPUTime,
|
c.percentCPUTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
@@ -347,48 +353,56 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error
|
|||||||
data.Name,
|
data.Name,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poolNonPagedBytes,
|
c.poolNonPagedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PoolNonpagedBytes,
|
data.PoolNonpagedBytes,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poolPagedBytes,
|
c.poolPagedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PoolPagedBytes,
|
data.PoolPagedBytes,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.privateBytes,
|
c.privateBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.PrivateBytes,
|
data.PrivateBytes,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.threadCount,
|
c.threadCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.ThreadCount,
|
data.ThreadCount,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualBytes,
|
c.virtualBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.VirtualBytes,
|
data.VirtualBytes,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualBytesPeak,
|
c.virtualBytesPeak,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.VirtualBytesPeak,
|
data.VirtualBytesPeak,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.workingSet,
|
c.workingSet,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data.WorkingSet,
|
data.WorkingSet,
|
||||||
data.Name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.workingSetPeak,
|
c.workingSetPeak,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
@@ -453,6 +467,7 @@ func (c *Collector) collectWTSSessions(ch chan<- prometheus.Metric) error {
|
|||||||
if session.State == stateID {
|
if session.State == stateID {
|
||||||
isState = 1.0
|
isState = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sessionInfo,
|
c.sessionInfo,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M
|
|||||||
for _, q := range metric.GetSummary().GetQuantile() {
|
for _, q := range metric.GetSummary().GetQuantile() {
|
||||||
quantiles[q.GetQuantile()] = q.GetValue()
|
quantiles[q.GetQuantile()] = q.GetValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstSummary(
|
ch <- prometheus.MustNewConstSummary(
|
||||||
prometheus.NewDesc(
|
prometheus.NewDesc(
|
||||||
metricFamily.GetName(),
|
metricFamily.GetName(),
|
||||||
@@ -232,6 +233,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M
|
|||||||
for _, b := range metric.GetHistogram().GetBucket() {
|
for _, b := range metric.GetHistogram().GetBucket() {
|
||||||
buckets[b.GetUpperBound()] = b.GetCumulativeCount()
|
buckets[b.GetUpperBound()] = b.GetCumulativeCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstHistogram(
|
ch <- prometheus.MustNewConstHistogram(
|
||||||
prometheus.NewDesc(
|
prometheus.NewDesc(
|
||||||
metricFamily.GetName(),
|
metricFamily.GetName(),
|
||||||
@@ -290,8 +292,8 @@ type carriageReturnFilteringReader struct {
|
|||||||
// Read returns data from the underlying io.Reader, but with \r filtered out.
|
// Read returns data from the underlying io.Reader, but with \r filtered out.
|
||||||
func (cr carriageReturnFilteringReader) Read(p []byte) (int, error) {
|
func (cr carriageReturnFilteringReader) Read(p []byte) (int, error) {
|
||||||
buf := make([]byte, len(p))
|
buf := make([]byte, len(p))
|
||||||
n, err := cr.r.Read(buf)
|
|
||||||
|
|
||||||
|
n, err := cr.r.Read(buf)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
@@ -356,7 +358,6 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil && directory != "" {
|
if err != nil && directory != "" {
|
||||||
errs = append(errs, fmt.Errorf("error reading textfile directory %q: %w", directory, err))
|
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
|
var duplicateFamily []*dto.MetricFamily
|
||||||
|
|
||||||
duplicateFamily = append(duplicateFamily, &duplicate)
|
duplicateFamily = append(duplicateFamily, &duplicate)
|
||||||
|
|
||||||
// Ensure detection for duplicate metrics
|
// Ensure detection for duplicate metrics
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ func TestMultipleDirectories(t *testing.T) {
|
|||||||
got := ""
|
got := ""
|
||||||
|
|
||||||
errCh := make(chan error, 1)
|
errCh := make(chan error, 1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
errCh <- textFileCollector.Collect(metrics)
|
errCh <- textFileCollector.Collect(metrics)
|
||||||
|
|
||||||
@@ -88,6 +89,7 @@ func TestDuplicateFileName(t *testing.T) {
|
|||||||
got := ""
|
got := ""
|
||||||
|
|
||||||
errCh := make(chan error, 1)
|
errCh := make(chan error, 1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
errCh <- textFileCollector.Collect(metrics)
|
errCh <- textFileCollector.Collect(metrics)
|
||||||
|
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ func (c *Collector) collectTime(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentTime,
|
c.currentTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(time.Now().Unix()),
|
float64(time.Now().UnixMicro())/1e6,
|
||||||
)
|
)
|
||||||
|
|
||||||
timeZoneInfo, err := kernel32.GetDynamicTimeZoneInformation()
|
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 {
|
func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error {
|
||||||
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
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(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
@@ -327,21 +329,25 @@ func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].ComputedTimeOffset/1000000, // microseconds -> seconds
|
c.perfDataObject[0].ComputedTimeOffset/1000000, // microseconds -> seconds
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ntpClientTimeSourceCount,
|
c.ntpClientTimeSourceCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].NTPClientTimeSourceCount,
|
c.perfDataObject[0].NTPClientTimeSourceCount,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ntpRoundTripDelay,
|
c.ntpRoundTripDelay,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.perfDataObject[0].NTPRoundTripDelay/1000000, // microseconds -> seconds
|
c.perfDataObject[0].NTPRoundTripDelay/1000000, // microseconds -> seconds
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ntpServerIncomingRequestsTotal,
|
c.ntpServerIncomingRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.perfDataObject[0].NTPServerIncomingRequestsTotal,
|
c.perfDataObject[0].NTPServerIncomingRequestsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ntpServerOutgoingResponsesTotal,
|
c.ntpServerOutgoingResponsesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -160,18 +160,21 @@ func (c *Collector) writeUDPCounters(ch chan<- prometheus.Metric, metrics []perf
|
|||||||
metrics[0].DatagramsNoPortPerSec,
|
metrics[0].DatagramsNoPortPerSec,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.datagramsReceivedErrorsTotal,
|
c.datagramsReceivedErrorsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[0].DatagramsReceivedErrors,
|
metrics[0].DatagramsReceivedErrors,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.datagramsReceivedTotal,
|
c.datagramsReceivedTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
metrics[0].DatagramsReceivedPerSec,
|
metrics[0].DatagramsReceivedPerSec,
|
||||||
af,
|
af,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.datagramsSentTotal,
|
c.datagramsSentTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
|
|||||||
@@ -87,21 +87,6 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
config: ConfigDefaults,
|
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(
|
app.Flag(
|
||||||
"collector.update.online",
|
"collector.update.online",
|
||||||
"Whether to search for updates 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.",
|
"Define the interval of scraping Windows Update information.",
|
||||||
).Default(ConfigDefaults.ScrapeInterval.String()).DurationVar(&c.config.ScrapeInterval)
|
).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
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +363,7 @@ func (c *Collector) fetchUpdates(logger *slog.Logger, usd *ole.IDispatch) ([]pro
|
|||||||
metricsBuf = append(metricsBuf, prometheus.MustNewConstMetric(
|
metricsBuf = append(metricsBuf, prometheus.MustNewConstMetric(
|
||||||
c.lastScrapeMetric,
|
c.lastScrapeMetric,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(time.Now().Unix()),
|
float64(time.Now().UnixMicro())/1e6,
|
||||||
))
|
))
|
||||||
|
|
||||||
return metricsBuf, nil
|
return metricsBuf, nil
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@@ -134,6 +135,11 @@ func NewConfigFileResolver(filePath string) (*Resolver, error) {
|
|||||||
decoder.KnownFields(true)
|
decoder.KnownFields(true)
|
||||||
|
|
||||||
if err = decoder.Decode(&configFileStructure); err != nil {
|
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)
|
return nil, fmt.Errorf("configuration file validation error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,72 +19,52 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// flatten flattens the nested struct.
|
// convertMap converts a map with any comparable key type to a map with string keys.
|
||||||
//
|
func convertMap[K comparable, V any](originalMap map[K]V) map[string]V {
|
||||||
// All keys will be joined by dot
|
convertedMap := make(map[string]V, len(originalMap))
|
||||||
// e.g. {"a": {"b":"c"}} => {"a.b":"c"}
|
|
||||||
// or {"a": {"b":[1,2]}} => {"a.b.0":1, "a.b.1": 2}.
|
|
||||||
func flatten(data map[string]interface{}) map[string]string {
|
|
||||||
ret := make(map[string]string)
|
|
||||||
|
|
||||||
for k, v := range data {
|
|
||||||
switch typed := v.(type) {
|
|
||||||
case map[interface{}]interface{}:
|
|
||||||
for fk, fv := range flatten(convertMap(typed)) {
|
|
||||||
ret[fmt.Sprintf("%s.%s", k, fk)] = fv
|
|
||||||
}
|
|
||||||
case map[string]interface{}:
|
|
||||||
for fk, fv := range flatten(typed) {
|
|
||||||
ret[fmt.Sprintf("%s.%s", k, fk)] = fv
|
|
||||||
}
|
|
||||||
case []interface{}:
|
|
||||||
for fk, fv := range flattenSlice(typed) {
|
|
||||||
ret[fmt.Sprintf("%s.%s", k, fk)] = fv
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
ret[k] = fmt.Sprint(typed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func flattenSlice(data []interface{}) map[string]string {
|
|
||||||
ret := make(map[string]string)
|
|
||||||
|
|
||||||
for idx, v := range data {
|
|
||||||
switch typed := v.(type) {
|
|
||||||
case map[interface{}]interface{}:
|
|
||||||
for fk, fv := range flatten(convertMap(typed)) {
|
|
||||||
ret[fmt.Sprintf("%d,%s", idx, fk)] = fv
|
|
||||||
}
|
|
||||||
case map[string]interface{}:
|
|
||||||
for fk, fv := range flatten(typed) {
|
|
||||||
ret[fmt.Sprintf("%d,%s", idx, fk)] = fv
|
|
||||||
}
|
|
||||||
case []interface{}:
|
|
||||||
for fk, fv := range flattenSlice(typed) {
|
|
||||||
ret[fmt.Sprintf("%d,%s", idx, fk)] = fv
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
ret[strconv.Itoa(idx)] = fmt.Sprint(typed)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func convertMap(originalMap map[interface{}]interface{}) map[string]interface{} {
|
|
||||||
convertedMap := map[string]interface{}{}
|
|
||||||
|
|
||||||
for key, value := range originalMap {
|
for key, value := range originalMap {
|
||||||
if keyString, ok := key.(string); ok {
|
if keyString, ok := any(key).(string); ok {
|
||||||
convertedMap[keyString] = value
|
convertedMap[keyString] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertedMap
|
return convertedMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flatten flattens a nested map, joining keys with dots.
|
||||||
|
// e.g. {"a": {"b":"c"}} => {"a.b":"c"}
|
||||||
|
func flatten(data map[string]any) map[string]string {
|
||||||
|
result := make(map[string]string)
|
||||||
|
|
||||||
|
flattenHelper("", data, result)
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func flattenHelper(prefix string, data map[string]any, result map[string]string) {
|
||||||
|
for k, v := range data {
|
||||||
|
fullKey := k
|
||||||
|
if prefix != "" {
|
||||||
|
fullKey = prefix + "." + k
|
||||||
|
}
|
||||||
|
|
||||||
|
switch val := v.(type) {
|
||||||
|
case map[any]any:
|
||||||
|
flattenHelper(fullKey, convertMap(val), result)
|
||||||
|
case map[string]any:
|
||||||
|
flattenHelper(fullKey, val, result)
|
||||||
|
case []any:
|
||||||
|
strSlice := make([]string, len(val))
|
||||||
|
for i, elem := range val {
|
||||||
|
strSlice[i] = fmt.Sprint(elem)
|
||||||
|
}
|
||||||
|
|
||||||
|
result[fullKey] = strings.Join(strSlice, ",")
|
||||||
|
default:
|
||||||
|
result[fullKey] = fmt.Sprint(val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) {
|
|||||||
var mibInfo *DHCP_MIB_INFO_V5
|
var mibInfo *DHCP_MIB_INFO_V5
|
||||||
|
|
||||||
if err := dhcpGetMibInfoV5(&mibInfo); err != nil {
|
if err := dhcpGetMibInfoV5(&mibInfo); err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("dhcpGetMibInfoV5: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer dhcpRpcFreeMemory(unsafe.Pointer(mibInfo))
|
defer dhcpRpcFreeMemory(unsafe.Pointer(mibInfo))
|
||||||
@@ -56,7 +56,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) {
|
|||||||
var superScopeTable *DHCP_SUPER_SCOPE_TABLE
|
var superScopeTable *DHCP_SUPER_SCOPE_TABLE
|
||||||
|
|
||||||
if err := dhcpGetSuperScopeInfoV4(&superScopeTable); err != nil {
|
if err := dhcpGetSuperScopeInfoV4(&superScopeTable); err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("dhcpGetSuperScopeInfoV4: %w", err)
|
||||||
} else if superScopeTable == nil {
|
} else if superScopeTable == nil {
|
||||||
return nil, errors.New("dhcpGetSuperScopeInfoV4 returned nil")
|
return nil, errors.New("dhcpGetSuperScopeInfoV4 returned nil")
|
||||||
}
|
}
|
||||||
|
|||||||
192
internal/headers/gdi32/gdi32.go
Normal file
192
internal/headers/gdi32/gdi32.go
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
// 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 gdi32
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
// https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/d3dkmthk/ne-d3dkmthk-_kmtqueryadapterinfotype
|
||||||
|
// https://github.com/nalilord/AMDPlugin/blob/bb405b6d58ea543ff630f3488384473bee79f447/Common/d3dkmthk.pas#L54
|
||||||
|
const (
|
||||||
|
// KMTQAITYPE_GETSEGMENTSIZE pPrivateDriverData points to a D3DKMT_SEGMENTSIZEINFO structure that contains information about the size of memory and aperture segments.
|
||||||
|
KMTQAITYPE_GETSEGMENTSIZE = 3
|
||||||
|
// KMTQAITYPE_ADAPTERADDRESS pPrivateDriverData points to a D3DKMT_ADAPTERADDRESS structure that contains information about the physical location on the PCI bus of the adapter.
|
||||||
|
KMTQAITYPE_ADAPTERADDRESS = 6
|
||||||
|
// KMTQAITYPE_ADAPTERREGISTRYINFO pPrivateDriverData points to a D3DKMT_ADAPTERREGISTRYINFO structure that contains registry information about the graphics adapter.
|
||||||
|
KMTQAITYPE_ADAPTERREGISTRYINFO = 8
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrNoGPUDevices = errors.New("no GPU devices found")
|
||||||
|
|
||||||
|
func GetGPUDeviceByLUID(adapterLUID windows.LUID) (GPUDevice, error) {
|
||||||
|
open := D3DKMT_OPENADAPTERFROMLUID{
|
||||||
|
AdapterLUID: adapterLUID,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := D3DKMTOpenAdapterFromLuid(&open); err != nil {
|
||||||
|
return GPUDevice{}, fmt.Errorf("D3DKMTOpenAdapterFromLuid failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
errs := make([]error, 0)
|
||||||
|
|
||||||
|
gpuDevice, err := GetGPUDevice(open.HAdapter)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("GetGPUDevice failed: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := D3DKMTCloseAdapter(&D3DKMT_CLOSEADAPTER{
|
||||||
|
HAdapter: open.HAdapter,
|
||||||
|
}); err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("D3DKMTCloseAdapter failed: %w", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(errs) > 0 {
|
||||||
|
return gpuDevice, fmt.Errorf("errors occurred while getting GPU device: %w", errors.Join(errs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuDevice.LUID = adapterLUID
|
||||||
|
|
||||||
|
return gpuDevice, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetGPUDevice(hAdapter D3DKMT_HANDLE) (GPUDevice, error) {
|
||||||
|
var gpuDevice GPUDevice
|
||||||
|
|
||||||
|
// Try segment size first
|
||||||
|
var size D3DKMT_SEGMENTSIZEINFO
|
||||||
|
|
||||||
|
query := D3DKMT_QUERYADAPTERINFO{
|
||||||
|
hAdapter: hAdapter,
|
||||||
|
queryType: KMTQAITYPE_GETSEGMENTSIZE,
|
||||||
|
pPrivateDriverData: unsafe.Pointer(&size),
|
||||||
|
privateDriverDataSize: uint32(unsafe.Sizeof(size)),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := D3DKMTQueryAdapterInfo(&query); err != nil {
|
||||||
|
return gpuDevice, fmt.Errorf("D3DKMTQueryAdapterInfo (segment size) failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuDevice.DedicatedVideoMemorySize = size.DedicatedVideoMemorySize
|
||||||
|
gpuDevice.DedicatedSystemMemorySize = size.DedicatedSystemMemorySize
|
||||||
|
gpuDevice.SharedSystemMemorySize = size.SharedSystemMemorySize
|
||||||
|
|
||||||
|
// Now try registry info
|
||||||
|
var address D3DKMT_ADAPTERADDRESS
|
||||||
|
|
||||||
|
query.queryType = KMTQAITYPE_ADAPTERADDRESS
|
||||||
|
query.pPrivateDriverData = unsafe.Pointer(&address)
|
||||||
|
query.privateDriverDataSize = uint32(unsafe.Sizeof(address))
|
||||||
|
|
||||||
|
if err := D3DKMTQueryAdapterInfo(&query); err != nil {
|
||||||
|
return gpuDevice, fmt.Errorf("D3DKMTQueryAdapterInfo (adapter address) failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuDevice.BusNumber = address.BusNumber
|
||||||
|
gpuDevice.DeviceNumber = address.DeviceNumber
|
||||||
|
gpuDevice.FunctionNumber = address.FunctionNumber
|
||||||
|
|
||||||
|
// Now try registry info
|
||||||
|
var info D3DKMT_ADAPTERREGISTRYINFO
|
||||||
|
|
||||||
|
query.queryType = KMTQAITYPE_ADAPTERREGISTRYINFO
|
||||||
|
query.pPrivateDriverData = unsafe.Pointer(&info)
|
||||||
|
query.privateDriverDataSize = uint32(unsafe.Sizeof(info))
|
||||||
|
|
||||||
|
if err := D3DKMTQueryAdapterInfo(&query); err != nil && !errors.Is(err, windows.ERROR_FILE_NOT_FOUND) {
|
||||||
|
return gpuDevice, fmt.Errorf("D3DKMTQueryAdapterInfo (info) failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuDevice.AdapterString = windows.UTF16ToString(info.AdapterString[:])
|
||||||
|
|
||||||
|
return gpuDevice, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetGPUDevices() ([]GPUDevice, error) {
|
||||||
|
gpuDevices := make([]GPUDevice, 0, 2)
|
||||||
|
|
||||||
|
// First call: Get the number of adapters
|
||||||
|
enumAdapters := D3DKMT_ENUMADAPTERS2{
|
||||||
|
NumAdapters: 0,
|
||||||
|
PAdapters: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := D3DKMTEnumAdapters2(&enumAdapters); err != nil {
|
||||||
|
return gpuDevices, fmt.Errorf("D3DKMTEnumAdapters2 (get count) failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if enumAdapters.NumAdapters == 0 {
|
||||||
|
return gpuDevices, ErrNoGPUDevices
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second call: Get the actual adapter information
|
||||||
|
pAdapters := make([]D3DKMT_ADAPTERINFO, enumAdapters.NumAdapters)
|
||||||
|
enumAdapters.PAdapters = &pAdapters[0]
|
||||||
|
|
||||||
|
if err := D3DKMTEnumAdapters2(&enumAdapters); err != nil {
|
||||||
|
return gpuDevices, fmt.Errorf("D3DKMTEnumAdapters2 (get adapters) failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var errs []error
|
||||||
|
|
||||||
|
// Process each adapter
|
||||||
|
for i := range enumAdapters.NumAdapters {
|
||||||
|
adapter := pAdapters[i]
|
||||||
|
// Validate handle before using it
|
||||||
|
if adapter.HAdapter == 0 {
|
||||||
|
errs = append(errs, fmt.Errorf("adapter %d has null handle", i))
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
func() {
|
||||||
|
defer func() {
|
||||||
|
if closeErr := D3DKMTCloseAdapter(&D3DKMT_CLOSEADAPTER{
|
||||||
|
HAdapter: adapter.HAdapter,
|
||||||
|
}); closeErr != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("failed to close adapter %v: %w", adapter.AdapterLUID, closeErr))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
gpuDevice, err := GetGPUDevice(adapter.HAdapter)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("failed to get GPU device for adapter %v: %w", adapter.AdapterLUID, err))
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuDevice.LUID = adapter.AdapterLUID
|
||||||
|
|
||||||
|
gpuDevices = append(gpuDevices, gpuDevice)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(errs) > 0 {
|
||||||
|
return gpuDevices, errors.Join(errs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(gpuDevices) == 0 {
|
||||||
|
return gpuDevices, ErrNoGPUDevices
|
||||||
|
}
|
||||||
|
|
||||||
|
return gpuDevices, nil
|
||||||
|
}
|
||||||
@@ -13,19 +13,17 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build windows
|
package gdi32_test
|
||||||
|
|
||||||
package setupapi_test
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/setupapi"
|
"github.com/prometheus-community/windows_exporter/internal/headers/gdi32"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetGPUDevices(t *testing.T) {
|
func TestGetGPUDevices(t *testing.T) {
|
||||||
devices, err := setupapi.GetGPUDevices()
|
devices, err := gdi32.GetGPUDevices()
|
||||||
require.NoError(t, err, "Failed to get GPU devices")
|
require.NoError(t, err, "Failed to get GPU devices")
|
||||||
|
|
||||||
require.NotNil(t, devices)
|
require.NotNil(t, devices)
|
||||||
77
internal/headers/gdi32/syscall.go
Normal file
77
internal/headers/gdi32/syscall.go
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
package gdi32
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/prometheus-community/windows_exporter/internal/headers/ntdll"
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
//nolint:gochecknoglobals
|
||||||
|
var (
|
||||||
|
modGdi32 = windows.NewLazySystemDLL("gdi32.dll")
|
||||||
|
procD3DKMTOpenAdapterFromLuid = modGdi32.NewProc("D3DKMTOpenAdapterFromLuid")
|
||||||
|
procD3DKMTQueryAdapterInfo = modGdi32.NewProc("D3DKMTQueryAdapterInfo")
|
||||||
|
procD3DKMTCloseAdapter = modGdi32.NewProc("D3DKMTCloseAdapter")
|
||||||
|
procD3DKMTEnumAdapters2 = modGdi32.NewProc("D3DKMTEnumAdapters2")
|
||||||
|
)
|
||||||
|
|
||||||
|
func D3DKMTOpenAdapterFromLuid(ptr *D3DKMT_OPENADAPTERFROMLUID) error {
|
||||||
|
ret, _, _ := procD3DKMTOpenAdapterFromLuid.Call(
|
||||||
|
uintptr(unsafe.Pointer(ptr)),
|
||||||
|
)
|
||||||
|
if ret != 0 {
|
||||||
|
return fmt.Errorf("D3DKMTOpenAdapterFromLuid failed: 0x%X: %w", ret, ntdll.RtlNtStatusToDosError(ret))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func D3DKMTEnumAdapters2(ptr *D3DKMT_ENUMADAPTERS2) error {
|
||||||
|
ret, _, _ := procD3DKMTEnumAdapters2.Call(
|
||||||
|
uintptr(unsafe.Pointer(ptr)),
|
||||||
|
)
|
||||||
|
if ret != 0 {
|
||||||
|
return fmt.Errorf("D3DKMTEnumAdapters2 failed: 0x%X: %w", ret, ntdll.RtlNtStatusToDosError(ret))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func D3DKMTQueryAdapterInfo(query *D3DKMT_QUERYADAPTERINFO) error {
|
||||||
|
ret, _, _ := procD3DKMTQueryAdapterInfo.Call(
|
||||||
|
uintptr(unsafe.Pointer(query)),
|
||||||
|
)
|
||||||
|
if ret != 0 {
|
||||||
|
return fmt.Errorf("D3DKMTQueryAdapterInfo failed: 0x%X: %w", ret, ntdll.RtlNtStatusToDosError(ret))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func D3DKMTCloseAdapter(ptr *D3DKMT_CLOSEADAPTER) error {
|
||||||
|
ret, _, _ := procD3DKMTCloseAdapter.Call(
|
||||||
|
uintptr(unsafe.Pointer(ptr)),
|
||||||
|
)
|
||||||
|
if ret != 0 {
|
||||||
|
return fmt.Errorf("D3DKMTCloseAdapter failed: 0x%X: %w", ret, ntdll.RtlNtStatusToDosError(ret))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
85
internal/headers/gdi32/types.go
Normal file
85
internal/headers/gdi32/types.go
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// 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 gdi32
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/prometheus-community/windows_exporter/internal/headers/win32"
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
type D3DKMT_HANDLE = win32.UINT
|
||||||
|
|
||||||
|
type D3DKMT_OPENADAPTERFROMLUID struct {
|
||||||
|
AdapterLUID windows.LUID
|
||||||
|
HAdapter D3DKMT_HANDLE
|
||||||
|
}
|
||||||
|
|
||||||
|
type D3DKMT_CLOSEADAPTER struct {
|
||||||
|
HAdapter D3DKMT_HANDLE
|
||||||
|
}
|
||||||
|
|
||||||
|
type D3DKMT_QUERYADAPTERINFO struct {
|
||||||
|
hAdapter D3DKMT_HANDLE
|
||||||
|
queryType int32
|
||||||
|
pPrivateDriverData unsafe.Pointer
|
||||||
|
privateDriverDataSize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
type D3DKMT_ENUMADAPTERS2 struct {
|
||||||
|
NumAdapters uint32
|
||||||
|
PAdapters *D3DKMT_ADAPTERINFO
|
||||||
|
}
|
||||||
|
|
||||||
|
type D3DKMT_ADAPTERINFO struct {
|
||||||
|
HAdapter D3DKMT_HANDLE
|
||||||
|
AdapterLUID windows.LUID
|
||||||
|
NumOfSources win32.ULONG
|
||||||
|
Present win32.BOOL
|
||||||
|
}
|
||||||
|
|
||||||
|
type D3DKMT_ADAPTERREGISTRYINFO struct {
|
||||||
|
AdapterString [win32.MAX_PATH]uint16
|
||||||
|
BiosString [win32.MAX_PATH]uint16
|
||||||
|
DacType [win32.MAX_PATH]uint16
|
||||||
|
ChipType [win32.MAX_PATH]uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
type D3DKMT_SEGMENTSIZEINFO struct {
|
||||||
|
DedicatedVideoMemorySize uint64
|
||||||
|
DedicatedSystemMemorySize uint64
|
||||||
|
SharedSystemMemorySize uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type D3DKMT_ADAPTERADDRESS struct {
|
||||||
|
BusNumber win32.UINT
|
||||||
|
DeviceNumber win32.UINT
|
||||||
|
FunctionNumber win32.UINT
|
||||||
|
}
|
||||||
|
|
||||||
|
type GPUDevice struct {
|
||||||
|
AdapterString string
|
||||||
|
LUID windows.LUID
|
||||||
|
DedicatedVideoMemorySize uint64
|
||||||
|
DedicatedSystemMemorySize uint64
|
||||||
|
SharedSystemMemorySize uint64
|
||||||
|
BusNumber win32.UINT
|
||||||
|
DeviceNumber win32.UINT
|
||||||
|
FunctionNumber win32.UINT
|
||||||
|
}
|
||||||
@@ -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:])
|
|
||||||
}
|
|
||||||
@@ -18,30 +18,88 @@
|
|||||||
package hcn
|
package hcn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
"github.com/prometheus-community/windows_exporter/internal/headers/hcs"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
//nolint:gochecknoglobals
|
||||||
var (
|
var (
|
||||||
defaultQuery = utils.Must(windows.UTF16PtrFromString(`{"SchemaVersion":{"Major": 2,"Minor": 0},"Flags":"None"}`))
|
modvmcompute = windows.NewLazySystemDLL("vmcompute.dll")
|
||||||
|
procHNSCall = modvmcompute.NewProc("HNSCall")
|
||||||
|
|
||||||
|
hcnBodyEmpty = utils.Must(windows.UTF16PtrFromString(""))
|
||||||
|
hcnMethodGet = utils.Must(windows.UTF16PtrFromString("GET"))
|
||||||
|
hcnPathEndpoints = utils.Must(windows.UTF16PtrFromString("/endpoints/"))
|
||||||
|
hcnPathEndpointStats = utils.Must(windows.UTF16FromString("/endpointstats/"))
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetEndpointProperties(endpointID guid.GUID) (EndpointProperties, error) {
|
func ListEndpoints() ([]EndpointProperties, error) {
|
||||||
endpoint, err := OpenEndpoint(endpointID)
|
result, err := hnsCall(hcnMethodGet, hcnPathEndpoints, hcnBodyEmpty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return EndpointProperties{}, fmt.Errorf("failed to open endpoint: %w", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer CloseEndpoint(endpoint)
|
var endpoints struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
result, err := QueryEndpointProperties(endpoint, defaultQuery)
|
Error string `json:"error"`
|
||||||
if err != nil {
|
Output []EndpointProperties `json:"output"`
|
||||||
return EndpointProperties{}, fmt.Errorf("failed to query endpoint properties: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
if err := json.Unmarshal([]byte(result), &endpoints); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to unmarshal JSON %s: %w", result, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !endpoints.Success {
|
||||||
|
return nil, fmt.Errorf("HNSCall failed: %s", endpoints.Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return endpoints.Output, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetHNSEndpointStats(endpointID string) (EndpointStats, error) {
|
||||||
|
endpointIDUTF16, err := windows.UTF16FromString(endpointID)
|
||||||
|
if err != nil {
|
||||||
|
return EndpointStats{}, fmt.Errorf("failed to convert endpoint ID to UTF16: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
path := hcnPathEndpointStats[:len(hcnPathEndpointStats)-1]
|
||||||
|
path = append(path, endpointIDUTF16...)
|
||||||
|
|
||||||
|
result, err := hnsCall(hcnMethodGet, &path[0], hcnBodyEmpty)
|
||||||
|
if err != nil {
|
||||||
|
return EndpointStats{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var stats EndpointStats
|
||||||
|
|
||||||
|
if err := json.Unmarshal([]byte(result), &stats); err != nil {
|
||||||
|
return EndpointStats{}, fmt.Errorf("failed to unmarshal JSON %s: %w", result, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return stats, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func hnsCall(method, path, body *uint16) (string, error) {
|
||||||
|
var responseJSON *uint16
|
||||||
|
|
||||||
|
r1, _, _ := procHNSCall.Call(
|
||||||
|
uintptr(unsafe.Pointer(method)),
|
||||||
|
uintptr(unsafe.Pointer(path)),
|
||||||
|
uintptr(unsafe.Pointer(body)),
|
||||||
|
uintptr(unsafe.Pointer(&responseJSON)),
|
||||||
|
)
|
||||||
|
|
||||||
|
response := windows.UTF16PtrToString(responseJSON)
|
||||||
|
windows.CoTaskMemFree(unsafe.Pointer(responseJSON))
|
||||||
|
|
||||||
|
if r1 != 0 {
|
||||||
|
return "", fmt.Errorf("HNSCall failed: HRESULT 0x%X: %w", r1, hcs.Win32FromHResult(r1))
|
||||||
|
}
|
||||||
|
|
||||||
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +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 hcn_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/hcn"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestEnumerateEndpoints(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
endpoints, err := hcn.EnumerateEndpoints()
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, endpoints)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestQueryEndpointProperties(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
endpoints, err := hcn.EnumerateEndpoints()
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
if len(endpoints) == 0 {
|
|
||||||
t.Skip("No endpoints found")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = hcn.GetEndpointProperties(endpoints[0])
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
|
||||||
@@ -1,134 +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 hcn
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/hcs"
|
|
||||||
"golang.org/x/sys/windows"
|
|
||||||
)
|
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
|
||||||
var (
|
|
||||||
modComputeNetwork = windows.NewLazySystemDLL("computenetwork.dll")
|
|
||||||
|
|
||||||
procHcnEnumerateEndpoints = modComputeNetwork.NewProc("HcnEnumerateEndpoints")
|
|
||||||
procHcnOpenEndpoint = modComputeNetwork.NewProc("HcnOpenEndpoint")
|
|
||||||
procHcnQueryEndpointProperties = modComputeNetwork.NewProc("HcnQueryEndpointProperties")
|
|
||||||
procHcnCloseEndpoint = modComputeNetwork.NewProc("HcnCloseEndpoint")
|
|
||||||
)
|
|
||||||
|
|
||||||
// EnumerateEndpoints enumerates the endpoints.
|
|
||||||
//
|
|
||||||
// https://learn.microsoft.com/en-us/virtualization/api/hcn/reference/hcnenumerateendpoints
|
|
||||||
func EnumerateEndpoints() ([]guid.GUID, error) {
|
|
||||||
var (
|
|
||||||
endpointsJSON *uint16
|
|
||||||
errorRecord *uint16
|
|
||||||
)
|
|
||||||
|
|
||||||
r1, _, _ := procHcnEnumerateEndpoints.Call(
|
|
||||||
0,
|
|
||||||
uintptr(unsafe.Pointer(&endpointsJSON)),
|
|
||||||
uintptr(unsafe.Pointer(&errorRecord)),
|
|
||||||
)
|
|
||||||
|
|
||||||
windows.CoTaskMemFree(unsafe.Pointer(errorRecord))
|
|
||||||
result := windows.UTF16PtrToString(endpointsJSON)
|
|
||||||
|
|
||||||
if r1 != 0 {
|
|
||||||
return nil, fmt.Errorf("HcnEnumerateEndpoints failed: HRESULT 0x%X: %w", r1, hcs.Win32FromHResult(r1))
|
|
||||||
}
|
|
||||||
|
|
||||||
var endpoints []guid.GUID
|
|
||||||
|
|
||||||
if err := json.Unmarshal([]byte(result), &endpoints); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return endpoints, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenEndpoint opens an endpoint.
|
|
||||||
//
|
|
||||||
// https://learn.microsoft.com/en-us/virtualization/api/hcn/reference/hcnopenendpoint
|
|
||||||
func OpenEndpoint(id guid.GUID) (Endpoint, error) {
|
|
||||||
var (
|
|
||||||
endpoint Endpoint
|
|
||||||
errorRecord *uint16
|
|
||||||
)
|
|
||||||
|
|
||||||
r1, _, _ := procHcnOpenEndpoint.Call(
|
|
||||||
uintptr(unsafe.Pointer(&id)),
|
|
||||||
uintptr(unsafe.Pointer(&endpoint)),
|
|
||||||
uintptr(unsafe.Pointer(&errorRecord)),
|
|
||||||
)
|
|
||||||
|
|
||||||
windows.CoTaskMemFree(unsafe.Pointer(errorRecord))
|
|
||||||
|
|
||||||
if r1 != 0 {
|
|
||||||
return 0, fmt.Errorf("HcnOpenEndpoint failed: HRESULT 0x%X: %w", r1, hcs.Win32FromHResult(r1))
|
|
||||||
}
|
|
||||||
|
|
||||||
return endpoint, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryEndpointProperties queries the properties of an endpoint.
|
|
||||||
//
|
|
||||||
// https://learn.microsoft.com/en-us/virtualization/api/hcn/reference/hcnqueryendpointproperties
|
|
||||||
func QueryEndpointProperties(endpoint Endpoint, propertyQuery *uint16) (EndpointProperties, error) {
|
|
||||||
var (
|
|
||||||
resultDocument *uint16
|
|
||||||
errorRecord *uint16
|
|
||||||
)
|
|
||||||
|
|
||||||
r1, _, _ := procHcnQueryEndpointProperties.Call(
|
|
||||||
uintptr(endpoint),
|
|
||||||
uintptr(unsafe.Pointer(&propertyQuery)),
|
|
||||||
uintptr(unsafe.Pointer(&resultDocument)),
|
|
||||||
uintptr(unsafe.Pointer(&errorRecord)),
|
|
||||||
)
|
|
||||||
|
|
||||||
windows.CoTaskMemFree(unsafe.Pointer(errorRecord))
|
|
||||||
|
|
||||||
result := windows.UTF16PtrToString(resultDocument)
|
|
||||||
windows.CoTaskMemFree(unsafe.Pointer(resultDocument))
|
|
||||||
|
|
||||||
if r1 != 0 {
|
|
||||||
return EndpointProperties{}, fmt.Errorf("HcsGetComputeSystemProperties failed: HRESULT 0x%X: %w", r1, hcs.Win32FromHResult(r1))
|
|
||||||
}
|
|
||||||
|
|
||||||
var properties EndpointProperties
|
|
||||||
|
|
||||||
if err := json.Unmarshal([]byte(result), &properties); err != nil {
|
|
||||||
return EndpointProperties{}, fmt.Errorf("failed to unmarshal JSON: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return properties, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloseEndpoint close a handle to an Endpoint.
|
|
||||||
//
|
|
||||||
// https://learn.microsoft.com/en-us/virtualization/api/hcn/reference/hcncloseendpoint
|
|
||||||
func CloseEndpoint(endpoint Endpoint) {
|
|
||||||
_, _, _ = procHcnCloseEndpoint.Call(uintptr(endpoint))
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
package hcn
|
package hcn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,17 +27,9 @@ type Endpoint = windows.Handle
|
|||||||
//
|
//
|
||||||
// https://learn.microsoft.com/en-us/virtualization/api/hcn/hns_schema#HostComputeEndpoint
|
// https://learn.microsoft.com/en-us/virtualization/api/hcn/hns_schema#HostComputeEndpoint
|
||||||
type EndpointProperties struct {
|
type EndpointProperties struct {
|
||||||
ID string `json:"ID"`
|
ID string `json:"ID"`
|
||||||
State int `json:"State"`
|
State int `json:"State"`
|
||||||
SharedContainers []string `json:"SharedContainers"`
|
SharedContainers []string `json:"SharedContainers"`
|
||||||
Resources EndpointPropertiesResources `json:"Resources"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type EndpointPropertiesResources struct {
|
|
||||||
Allocators []EndpointPropertiesAllocators `json:"Allocators"`
|
|
||||||
}
|
|
||||||
type EndpointPropertiesAllocators struct {
|
|
||||||
AdapterNetCfgInstanceId *guid.GUID `json:"AdapterNetCfgInstanceId"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type EndpointStats struct {
|
type EndpointStats struct {
|
||||||
|
|||||||
@@ -22,16 +22,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/guid"
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
//nolint:gochecknoglobals
|
||||||
var (
|
var (
|
||||||
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
|
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
|
||||||
procGetExtendedTcpTable = modiphlpapi.NewProc("GetExtendedTcpTable")
|
procGetExtendedTcpTable = modiphlpapi.NewProc("GetExtendedTcpTable")
|
||||||
procGetIfEntry2Ex = modiphlpapi.NewProc("GetIfEntry2Ex")
|
|
||||||
procConvertInterfaceGuidToLuid = modiphlpapi.NewProc("ConvertInterfaceGuidToLuid")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetTCPConnectionStates(family uint32) (map[MIB_TCP_STATE]uint32, error) {
|
func GetTCPConnectionStates(family uint32) (map[MIB_TCP_STATE]uint32, error) {
|
||||||
@@ -131,37 +128,3 @@ func getExtendedTcpTable[T any](ulAf uint32, tableClass uint32) ([]T, error) {
|
|||||||
|
|
||||||
return unsafe.Slice((*T)(unsafe.Pointer(&buf[4])), binary.LittleEndian.Uint32(buf)), nil
|
return unsafe.Slice((*T)(unsafe.Pointer(&buf[4])), binary.LittleEndian.Uint32(buf)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIfEntry2Ex function retrieves the specified level of information for the specified interface on the local computer.
|
|
||||||
//
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getifentry2ex
|
|
||||||
func GetIfEntry2Ex(row *MIB_IF_ROW2) error {
|
|
||||||
ret, _, _ := procGetIfEntry2Ex.Call(
|
|
||||||
uintptr(0),
|
|
||||||
uintptr(unsafe.Pointer(row)),
|
|
||||||
)
|
|
||||||
|
|
||||||
if ret != 0 {
|
|
||||||
return fmt.Errorf("GetIfEntry2Ex failed with code %d: %w", ret, windows.Errno(ret))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConvertInterfaceGUIDToLUID function converts a globally unique identifier (GUID) for a network interface to the
|
|
||||||
// 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) {
|
|
||||||
var luid uint64
|
|
||||||
ret, _, _ := procConvertInterfaceGuidToLuid.Call(
|
|
||||||
uintptr(unsafe.Pointer(&guid)),
|
|
||||||
uintptr(unsafe.Pointer(&luid)),
|
|
||||||
)
|
|
||||||
|
|
||||||
if ret != 0 {
|
|
||||||
return 0, fmt.Errorf("ConvertInterfaceGUIDToLUID failed with code %d: %w", ret, windows.Errno(ret))
|
|
||||||
}
|
|
||||||
|
|
||||||
return luid, nil
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user