Compare commits

...

35 Commits

Author SHA1 Message Date
Calle Pettersson
517cd3b04b Merge pull request #263 from martinlindhe/linting
Add linting
2019-01-27 21:28:50 +01:00
Calle Pettersson
9daa8c8775 Don't shadow err 2019-01-23 10:02:13 +01:00
Calle Pettersson
e04d3f414d Explicitly set which linters are enabled 2019-01-23 10:01:31 +01:00
Calle Pettersson
4c69ed1610 Lint-fix: errcheck not found on local run(?) 2019-01-23 10:01:31 +01:00
Calle Pettersson
a171401f57 Lint-fix: errcheck. Partial fix to #261 2019-01-23 10:00:52 +01:00
Calle Pettersson
e24e0dc9f5 Lint-fix: Ignore goconst 2019-01-23 09:57:08 +01:00
Calle Pettersson
0eab86c731 Lint-fix: vet. Fixes potential overflow in AD collector 2019-01-23 09:56:24 +01:00
Calle Pettersson
13c68634ce Lint-fix: varcheck 2019-01-23 09:56:24 +01:00
Calle Pettersson
73ad1ba960 Lint-fix: vetshadow 2019-01-23 09:56:24 +01:00
Calle Pettersson
0121fd6471 Lint-fix: Final golint, ignore capitalisation rules 2019-01-23 09:56:24 +01:00
Calle Pettersson
93904954f4 Lint-fix: Dead code. Fixes bug with IIS app white/blacklisting 2019-01-23 09:56:24 +01:00
Calle Pettersson
f2462b26c8 Lint-fix: Package comments 2019-01-23 09:56:24 +01:00
Calle Pettersson
7e05621b26 Move to makefile, do initial excludes 2019-01-23 09:56:24 +01:00
Calle Pettersson
76ddad34b8 Add linting 2019-01-23 09:55:26 +01:00
Calle Pettersson
2053dea3ac Fix log message source (#312) 2019-01-23 02:25:23 +01:00
Calle Pettersson
35b81dcdd0 Change AppVeyor build to cross-compile instead of having two runs (#311) 2019-01-23 02:24:59 +01:00
Calle Pettersson
39b0000514 Merge pull request #303 from monitoring-tools/failed_querying_wp
There was added the checking and logging of query worker processes.
2019-01-20 21:24:14 +01:00
Calle Pettersson
76ec763c42 Merge pull request #307 from giuliov/master
Added an example for textfile collector
2019-01-18 09:10:33 +01:00
Giulio Vian
7ccc47cc51 Added an example for textfile collector
Added a practical example for textfile collector using a Powershell snippet that generates a valid file.
2019-01-16 13:15:57 +00:00
vlamug
ad29ac0792 There was added the checking and logging of query worker processes 2018-12-21 15:16:08 +04:00
Calle Pettersson
d58ce114d9 Merge pull request #299 from hairyhenderson/update-utfbom-dep
textfile collector: updating utfbom dependency and simplifying code
2018-12-12 20:05:44 +01:00
Dave Henderson
5f9dfcc378 textfile collector: updating utfbom dependency and simplifying code
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2018-12-12 12:30:25 -05:00
Calle Pettersson
f4e5bc3d29 Merge pull request #296 from amitsaha/update_readmelinks
Update main README and docs/README
2018-12-05 07:10:31 +01:00
Amit Saha
f4362c5987 Update README 2018-12-05 11:48:23 +11:00
Amit Saha
f691b48304 Update README 2018-12-05 11:42:30 +11:00
Calle Pettersson
d12d31a17f Merge pull request #294 from hairyhenderson/windows-build-constraints
Adding windows build constraints
2018-11-30 18:57:56 +01:00
Calle Pettersson
48d23cfb12 Merge pull request #295 from h3po/patch-1
Update collector.textfile.md
2018-11-30 18:55:42 +01:00
Daniel
17039b8206 Update collector.textfile.md
Had to read the code to find out why my `.txt` textfiles weren't being read
2018-11-30 13:48:34 +01:00
Calle Pettersson
2993552e19 Merge pull request #293 from hairyhenderson/ensure-utf8-textfiles
textfile collector: Ensure that only UTF8 textfiles are parsed
2018-11-30 07:44:32 +01:00
Dave Henderson
5d4cafc0a1 Adding windows build constraints
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2018-11-29 19:51:12 -05:00
Dave Henderson
a70c57ffd1 textfile collector: Ensure that only UTF8 textfiles are parsed
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
2018-11-29 16:41:24 -05:00
Kevin Pettijohn
b2cb04834a MSI parameter - EXTRA_FLAGS (#291)
Added the parameter called EXTRA_FLAGS to handle additional unspecified flags within the MSI installer.
2018-11-29 20:14:37 +01:00
Calle Pettersson
f27fdbbbf5 Merge pull request #287 from coalfire/add-console_template
add wmi-overview console template
2018-11-20 09:51:41 +01:00
Noah Birnel
7dda8eba03 add wmi-overview console template 2018-11-19 15:12:22 -08:00
Calle Pettersson
080f80eb26 Fix broken summary table in collector docs (#286) 2018-11-18 22:26:38 +01:00
69 changed files with 593 additions and 201 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
VERSION VERSION
*.swp *.swp
*.un~ *.un~
output/

View File

@@ -12,3 +12,7 @@ build:
tarball: tarball:
files: files:
- LICENSE - LICENSE
crossbuild:
platforms:
- windows/amd64
- windows/386

6
Gopkg.lock generated
View File

@@ -37,12 +37,12 @@
revision = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9" revision = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9"
[[projects]] [[projects]]
digest = "1:ec6271918b59b872a2d25e374569a4f75f1839d91e4191470c297b7eaaaf7641" digest = "1:f9adc21a937e5da643ea14a3488cb7506788876737a5e205394e508627a6eec8"
name = "github.com/dimchansky/utfbom" name = "github.com/dimchansky/utfbom"
packages = ["."] packages = ["."]
pruneopts = "NUT" pruneopts = "NUT"
revision = "5448fe645cb1964ba70ac8f9f2ffe975e61a536c" revision = "d2133a1ce379ef6fa992b0514a77146c60db9d1c"
version = "v1.0.0" version = "v1.1.0"
[[projects]] [[projects]]
digest = "1:cb4e216bd9f58866f42dc65893455b24f879b026fdaa1ecc3aafff625fdb5a66" digest = "1:cb4e216bd9f58866f42dc65893455b24f879b026fdaa1ecc3aafff625fdb5a66"

View File

@@ -1,5 +1,19 @@
fmt: export GOOS=windows
gofmt -l -w -s .
build: build:
promu build -v promu build -v
test:
go test -v ./...
lint:
gometalinter --vendor --config gometalinter.config ./...
fmt:
gofmt -l -w -s .
crossbuild:
# The prometheus/golang-builder image for promu crossbuild doesn't exist
# on Windows, so for now, we'll just build twice
GOARCH=amd64 promu build --prefix=output/amd64
GOARCH=386 promu build --prefix=output/386

View File

@@ -9,22 +9,30 @@ Prometheus exporter for Windows machines, using the WMI (Windows Management Inst
Name | Description | Enabled by default Name | Description | Enabled by default
---------|-------------|-------------------- ---------|-------------|--------------------
[ad](docs/collector.ad.md) | [Win32_PerfRawData_DirectoryServices_DirectoryServices](https://msdn.microsoft.com/en-us/library/ms803980.aspx) Active Directory | [ad](docs/collector.ad.md) | Active Directory Domain Services |
[cpu](docs/collector.cpu.md) | [Win32_PerfRawData_PerfOS_Processor](https://msdn.microsoft.com/en-us/library/aa394317(v=vs.90).aspx) metrics (cpu usage) | &#10003; [cpu](docs/collector.cpu.md) | CPU usage | &#10003;
[cs](docs/collector.cs.md) | [Win32_ComputerSystem](https://msdn.microsoft.com/en-us/library/aa394102) metrics (system properties, num cpus/total memory) | &#10003; [cs](docs/collector.cs.md) | "Computer System" metrics (system properties, num cpus/total memory) | &#10003;
[dns](docs/collector.dns.md) | [Win32_PerfRawData_DNS_DNS](https://technet.microsoft.com/en-us/library/cc977686.aspx) metrics (DNS Server) | [dns](docs/collector.dns.md) | DNS Server |
[hyperv](docs/collector.hyperv.md) | Performance counters for Hyper-V hosts | [hyperv](docs/collector.hyperv.md) | Hyper-V hosts |
[iis](docs/collector.iis.md) | [Win32_PerfRawData_W3SVC_WebService](https://msdn.microsoft.com/en-us/library/aa394345) IIS metrics | [iis](docs/collector.iis.md) | IIS sites and applications |
[logical_disk](docs/collector.logical_disk.md) | [Win32_PerfRawData_PerfDisk_LogicalDisk](https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71)) metrics (disk I/O) | &#10003; [logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | &#10003;
[net](docs/collector.net.md) | [Win32_PerfRawData_Tcpip_NetworkInterface](https://technet.microsoft.com/en-us/security/aa394340(v=vs.80)) metrics (network interface I/O) | &#10003;
[memory](docs/collector.memory.md) | Memory usage metrics | [memory](docs/collector.memory.md) | Memory usage metrics |
[msmq](docs/collector.msmq.md) | [Win32_PerfRawData_MSMQ_MSMQQueue](http://wutils.com/wmi/root/cimv2/win32_perfrawdata_msmq_msmqqueue/) metrics (MSMQ/journal count) | [msmq](docs/collector.msmq.md) | MSMQ queues |
[mssql](docs/collector.mssql.md) | various [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 |
[os](docs/collector.os.md) | [Win32_OperatingSystem](https://msdn.microsoft.com/en-us/library/aa394239) metrics (memory, processes, users) | &#10003; [netframework_clrexceptions](docs/collector.netframework_clrexceptions.md) | .NET Framework CLR Exceptions |
[process](docs/collector.process.md) | [Win32_PerfRawData_PerfProc_Process](https://msdn.microsoft.com/en-us/library/aa394323(v=vs.85).aspx) metrics (per-process stats) | [netframework_clrinterop](docs/collector.netframework_clrinterop.md) | .NET Framework Interop Metrics |
[netframework_clrjit](docs/collector.netframework_clrjit.md) | .NET Framework JIT metrics |
[netframework_clrloading](docs/collector.netframework_clrloading.md) | .NET Framework CLR Loading metrics |
[netframework_clrlocksandthreads](docs/collector.netframework_clrlocksandthreads.md) | .NET Framework locks and metrics threads |
[netframework_clrmemory](docs/collector.netframework_clrmemory.md) | .NET Framework Memory metrics |
[netframework_clrremoting](docs/collector.netframework_clrremoting.md) | .NET Framework Remoting metrics |
[netframework_clrsecurity](docs/collector.netframework_clrsecurity.md) | .NET Framework Security Check metrics |
[net](docs/collector.net.md) | Network interface I/O | &#10003;
[os](docs/collector.os.md) | OS metrics (memory, processes, users) | &#10003;
[process](docs/collector.process.md) | Per-process metrics |
[service](docs/collector.service.md) | Service state metrics | &#10003; [service](docs/collector.service.md) | Service state metrics | &#10003;
[system](docs/collector.system.md) | Win32_PerfRawData_PerfOS_System metrics (system calls) | &#10003; [system](docs/collector.system.md) | System calls | &#10003;
[tcp](docs/collector.tcp.md) | [Win32_PerfRawData_Tcpip_TCPv4](https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx) metrics (tcp connections) | [tcp](docs/collector.tcp.md) | TCP connections |
[textfile](docs/collector.textfile.md) | Read prometheus metrics from a text file | &#10003; [textfile](docs/collector.textfile.md) | Read prometheus metrics from a text file | &#10003;
[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 |
@@ -44,13 +52,19 @@ Name | Description
`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_DIR` | As the `--collector.textfile.directory` flag, provide a directory to read text files with metrics from `TEXTFILE_DIR` | As the `--collector.textfile.directory` flag, provide a directory to read text files with metrics from
`EXTRA_FLAGS` | Allows passing full CLI flags. Defaults to an empty string.
Parameters are sent to the installer via `msiexec`. Example invocation: Parameters are sent to the installer via `msiexec`. Example invocations:
```powershell ```powershell
msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,iis LISTEN_PORT=5000 msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,iis LISTEN_PORT=5000
``` ```
Example service collector with a custom query.
```powershell
msiexec /i <path-to-msi-file> ENABLED_COLLECTORS=os,service --% EXTRA_FLAGS="--collector.service.services-where ""Name LIKE 'sql%'"""
```
## Roadmap ## Roadmap
See [open issues](https://github.com/martinlindhe/wmi_exporter/issues) See [open issues](https://github.com/martinlindhe/wmi_exporter/issues)

View File

@@ -1,48 +1,61 @@
version: "{build}" version: "{build}"
os: Windows Server 2012 R2 os: Visual Studio 2017
build: off
stack: go 1.10
environment: environment:
GOPATH: c:\gopath GOPATH: c:\gopath
matrix:
- MSI_ARCH: amd64
GOARCH: amd64
- MSI_ARCH: 386
GOARCH: 386
clone_folder: c:\gopath\src\github.com\martinlindhe\wmi_exporter clone_folder: c:\gopath\src\github.com\martinlindhe\wmi_exporter
install: install:
- go version - set PATH=%GOPATH%\bin;%PATH%
- set PATH=%GOPATH%\bin;c:\go\bin;%GOPATH%\bin\windows_%GOARCH%;%PATH%
- go get -u github.com/prometheus/promu - go get -u github.com/prometheus/promu
- choco install gitversion.portable -y - go get -u github.com/alecthomas/gometalinter && gometalinter --install
- choco install gitversion.portable make -y
test_script:
- make test
after_test:
- make lint
build_script: build_script:
- ps: gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
- go test -v ./...
- promu build -v
- ps: | - ps: |
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
if($env:APPVEYOR_REPO_TAG -eq "True") { gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
# The MSI version is not semver compliant, so just take the numerical parts $Version = Get-Content VERSION
$Version = $env:APPVEYOR_REPO_TAG_NAME -replace '^v?([0-9\.]+).*$','$1' make crossbuild
Write-Verbose "Setting msi version to $Version" # GH requires all files to have different names, so add version/arch to differentiate
.\installer\build.ps1 -PathToExecutable .\wmi_exporter.exe -Version $Version -Arch "$env:MSI_ARCH" foreach($Arch in "amd64","386") {
Push-AppveyorArtifact installer\Output\wmi_exporter-$Version-$env:MSI_ARCH.msi -DeploymentName Installer Rename-Item output\$Arch\wmi_exporter.exe -NewName wmi_exporter-$Version-$Arch.exe
} }
after_build: after_build:
- 7z a wmi_exporter-%MSI_ARCH%.zip wmi_exporter.exe - ps: |
# Build installer packages only on tagged releases
if($env:APPVEYOR_REPO_TAG -ne "True") {
return
}
$ErrorActionPreference = "Stop"
# The MSI version is not semver compliant, so just take the numerical parts
$Version = $env:APPVEYOR_REPO_TAG_NAME -replace '^v?([0-9\.]+).*$','$1'
foreach($Arch in "amd64","386") {
Write-Verbose "Building wmi_exporter $Version msi for $Arch"
.\installer\build.ps1 -PathToExecutable .\output\$Arch\wmi_exporter-$Version-$Arch.exe -Version $Version -Arch "$Arch"
Move-Item installer\Output\wmi_exporter-$Version-$Arch.msi output\$Arch\
}
- promu checksum output\
artifacts: artifacts:
- name: Executable - name: Artifacts
path: 'wmi_exporter-*.zip' path: output\**\*
deploy: deploy:
- provider: GitHub - provider: GitHub
description: WMI Exporter version $(appveyor_build_version) description: WMI Exporter version $(appveyor_build_version)
artifact: Executable,Installer artifact: Artifacts
auth_token: auth_token:
secure: 'CrXWeTf7qONUOEki5olFfGEUPMLDeHj61koDXV3OVEaLgtACmnVHsKUub9POflda' secure: 'CrXWeTf7qONUOEki5olFfGEUPMLDeHj61koDXV3OVEaLgtACmnVHsKUub9POflda'
draft: false draft: false

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_DirectoryServices_DirectoryServices // +build windows
// Partial docs: https://msdn.microsoft.com/en-us/library/ms803980.aspx
package collector package collector
import ( import (
@@ -462,6 +462,8 @@ func (c *ADCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_PerfRawData_DirectoryServices_DirectoryServices docs:
// - https://msdn.microsoft.com/en-us/library/ms803980.aspx
type Win32_PerfRawData_DirectoryServices_DirectoryServices struct { type Win32_PerfRawData_DirectoryServices_DirectoryServices struct {
Name string Name string
@@ -485,8 +487,8 @@ type Win32_PerfRawData_DirectoryServices_DirectoryServices struct {
DatabasemodifysPersec uint32 DatabasemodifysPersec uint32
DatabaserecyclesPersec uint32 DatabaserecyclesPersec uint32
DigestBindsPersec uint32 DigestBindsPersec uint32
DRAHighestUSNCommittedHighpart uint32 DRAHighestUSNCommittedHighpart uint64
DRAHighestUSNCommittedLowpart uint32 DRAHighestUSNCommittedLowpart uint64
DRAHighestUSNIssuedHighpart uint64 DRAHighestUSNIssuedHighpart uint64
DRAHighestUSNIssuedLowpart uint64 DRAHighestUSNIssuedLowpart uint64
DRAInboundBytesCompressedBetweenSitesAfterCompressionPersec uint32 DRAInboundBytesCompressedBetweenSitesAfterCompressionPersec uint32

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_PerfOS_Processor // +build windows
// https://msdn.microsoft.com/en-us/library/aa394317(v=vs.90).aspx - Win32_PerfRawData_PerfOS_Processor class
package collector package collector
import ( import (
@@ -22,6 +22,7 @@ type CPUCollector struct {
DPCsTotal *prometheus.Desc DPCsTotal *prometheus.Desc
} }
// NewCPUCollector constructs a new CPUCollector
func NewCPUCollector() (Collector, error) { func NewCPUCollector() (Collector, error) {
const subsystem = "cpu" const subsystem = "cpu"
return &CPUCollector{ return &CPUCollector{
@@ -63,6 +64,8 @@ func (c *CPUCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_PerfRawData_PerfOS_Processor docs:
// - https://msdn.microsoft.com/en-us/library/aa394317(v=vs.90).aspx
type Win32_PerfRawData_PerfOS_Processor struct { type Win32_PerfRawData_PerfOS_Processor struct {
Name string Name string
C1TransitionsPersec uint64 C1TransitionsPersec uint64

View File

@@ -1,5 +1,4 @@
// returns data points from Win32_ComputerSystem // +build windows
// https://msdn.microsoft.com/en-us/library/aa394102 - Win32_ComputerSystem class
package collector package collector
@@ -51,6 +50,8 @@ func (c *CSCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_ComputerSystem docs:
// - https://msdn.microsoft.com/en-us/library/aa394102
type Win32_ComputerSystem struct { type Win32_ComputerSystem struct {
NumberOfLogicalProcessors uint32 NumberOfLogicalProcessors uint32
TotalPhysicalMemory uint64 TotalPhysicalMemory uint64

View File

@@ -1,6 +1,5 @@
// returns data points from Win32_PerfRawData_DNS_DNS // +build windows
// https://msdn.microsoft.com/en-us/library/ms803992.aspx?f=255&MSPPError=-2147217396
// https://technet.microsoft.com/en-us/library/cc977686.aspx
package collector package collector
import ( import (
@@ -190,6 +189,9 @@ func (c *DNSCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_PerfRawData_DNS_DNS docs:
// - https://msdn.microsoft.com/en-us/library/ms803992.aspx?f=255&MSPPError=-2147217396
// - https://technet.microsoft.com/en-us/library/cc977686.aspx
type Win32_PerfRawData_DNS_DNS struct { type Win32_PerfRawData_DNS_DNS struct {
AXFRRequestReceived uint32 AXFRRequestReceived uint32
AXFRRequestSent uint32 AXFRRequestSent uint32

View File

@@ -1,3 +1,5 @@
// +build windows
package collector package collector
import ( import (

View File

@@ -1,8 +1,4 @@
// returns data points from the following classes: // +build windows
// - Win32_PerfRawData_W3SVC_WebService
// - Win32_PerfRawData_APPPOOLCountersProvider_APPPOOLWAS
// - Win32_PerfRawData_W3SVCW3WPCounterProvider_W3SVCW3WP
// - Win32_PerfRawData_W3SVC_WebServiceCache
package collector package collector
@@ -34,7 +30,12 @@ func getIISVersion() simple_version {
log.Warn("Couldn't open registry to determine IIS version:", err) log.Warn("Couldn't open registry to determine IIS version:", err)
return simple_version{} return simple_version{}
} }
defer k.Close() defer func() {
err = k.Close()
if err != nil {
log.Warnf("Failed to close registry key: %v", err)
}
}()
major, _, err := k.GetIntegerValue("MajorVersion") major, _, err := k.GetIntegerValue("MajorVersion")
if err != nil { if err != nil {
@@ -806,8 +807,8 @@ func NewIISCollector() (Collector, error) {
nil, nil,
), ),
appWhitelistPattern: regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *siteWhitelist)), appWhitelistPattern: regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *appWhitelist)),
appBlacklistPattern: regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *siteBlacklist)), appBlacklistPattern: regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *appBlacklist)),
} }
buildIIS.iis_version = getIISVersion() buildIIS.iis_version = getIISVersion()
@@ -984,7 +985,7 @@ type Win32_PerfRawData_W3SVC_WebServiceCache struct {
URICacheMisses uint32 URICacheMisses uint32
} }
var ApplicationStates = map[uint32]string{ var applicationStates = map[uint32]string{
1: "Uninitialized", 1: "Uninitialized",
2: "Initialized", 2: "Initialized",
3: "Running", 3: "Running",
@@ -1265,7 +1266,7 @@ func (c *IISCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, e
} }
// Guages // Guages
for key, label := range ApplicationStates { for key, label := range applicationStates {
isCurrentState := 0.0 isCurrentState := 0.0
if key == app.CurrentApplicationPoolState { if key == app.CurrentApplicationPoolState {
isCurrentState = 1.0 isCurrentState = 1.0

View File

@@ -1,6 +1,4 @@
// returns data points from Win32_PerfRawData_PerfDisk_LogicalDisk // +build windows
// https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71) - Win32_PerfRawData_PerfDisk_LogicalDisk class
// https://msdn.microsoft.com/en-us/library/ms803973.aspx - LogicalDisk object reference
package collector package collector
@@ -144,6 +142,9 @@ func (c *LogicalDiskCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_PerfRawData_PerfDisk_LogicalDisk docs:
// - https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71) - Win32_PerfRawData_PerfDisk_LogicalDisk class
// - https://msdn.microsoft.com/en-us/library/ms803973.aspx - LogicalDisk object reference
type Win32_PerfRawData_PerfDisk_LogicalDisk struct { type Win32_PerfRawData_PerfDisk_LogicalDisk struct {
Name string Name string
CurrentDiskQueueLength uint32 CurrentDiskQueueLength uint32

View File

@@ -1,5 +1,8 @@
// returns data points from Win32_PerfRawData_PerfOS_Memory // returns data points from Win32_PerfRawData_PerfOS_Memory
// <add link to documentation here> - Win32_PerfRawData_PerfOS_Memory class // <add link to documentation here> - Win32_PerfRawData_PerfOS_Memory class
// +build windows
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_MSMQ_MSMQQueue // +build windows
// <add link to documentation here> - Win32_PerfRawData_MSMQ_MSMQQueue class
package collector package collector
import ( import (

View File

@@ -1,22 +1,4 @@
// returns data points from the following classes: // +build windows
// - Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-access-methods-object
// - Win32_PerfRawData_MSSQLSERVER_SQLServerAvailabilityReplica
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-availability-replica
// - Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object
// - Win32_PerfRawData_MSSQLSERVER_SQLServerDatabaseReplica
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-database-replica
// - Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-databases-object?view=sql-server-2017
// - Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-general-statistics-object
// - Win32_PerfRawData_MSSQLSERVER_SQLServerLocks
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-locks-object
// - Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-memory-manager-object
// - Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-statistics-object
package collector package collector
@@ -62,7 +44,12 @@ func getMSSQLInstances() mssqlInstancesType {
log.Warn("Couldn't open registry to determine SQL instances:", err) log.Warn("Couldn't open registry to determine SQL instances:", err)
return sqlDefaultInstance return sqlDefaultInstance
} }
defer k.Close() defer func() {
err = k.Close()
if err != nil {
log.Warnf("Failed to close registry key: %v", err)
}
}()
instanceNames, err := k.ReadValueNames(0) instanceNames, err := k.ReadValueNames(0)
if err != nil { if err != nil {
@@ -381,7 +368,7 @@ func NewMSSQLCollector() (Collector, error) {
const subsystem = "mssql" const subsystem = "mssql"
MSSQLCollector := MSSQLCollector{ mssqlCollector := MSSQLCollector{
// meta // meta
mssqlScrapeDurationDesc: prometheus.NewDesc( mssqlScrapeDurationDesc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "collector_duration_seconds"), prometheus.BuildFQName(Namespace, subsystem, "collector_duration_seconds"),
@@ -1653,17 +1640,17 @@ func NewMSSQLCollector() (Collector, error) {
mssqlInstances: getMSSQLInstances(), mssqlInstances: getMSSQLInstances(),
} }
MSSQLCollector.mssqlCollectors = MSSQLCollector.getMSSQLCollectors() mssqlCollector.mssqlCollectors = mssqlCollector.getMSSQLCollectors()
if *mssqlPrintCollectors { if *mssqlPrintCollectors {
fmt.Printf("Available SQLServer Classes:\n") fmt.Printf("Available SQLServer Classes:\n")
for name := range MSSQLCollector.mssqlCollectors { for name := range mssqlCollector.mssqlCollectors {
fmt.Printf(" - %s\n", name) fmt.Printf(" - %s\n", name)
} }
os.Exit(0) os.Exit(0)
} }
return &MSSQLCollector, nil return &mssqlCollector, nil
} }
type mssqlCollectorFunc func(ch chan<- prometheus.Metric, sqlInstance string) (*prometheus.Desc, error) type mssqlCollectorFunc func(ch chan<- prometheus.Metric, sqlInstance string) (*prometheus.Desc, error)
@@ -1721,6 +1708,9 @@ func (c *MSSQLCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// win32PerfRawDataSQLServerAccessMethods docs:
// - Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-access-methods-object
type win32PerfRawDataSQLServerAccessMethods struct { type win32PerfRawDataSQLServerAccessMethods struct {
AUcleanupbatchesPersec uint64 AUcleanupbatchesPersec uint64
AUcleanupsPersec uint64 AUcleanupsPersec uint64
@@ -2085,6 +2075,8 @@ func (c *MSSQLCollector) collectAccessMethods(ch chan<- prometheus.Metric, sqlIn
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerAvailabilityReplica docs:
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-availability-replica
type win32PerfRawDataSQLServerAvailabilityReplica struct { type win32PerfRawDataSQLServerAvailabilityReplica struct {
Name string Name string
BytesReceivedfromReplicaPersec uint64 BytesReceivedfromReplicaPersec uint64
@@ -2177,6 +2169,8 @@ func (c *MSSQLCollector) collectAvailabilityReplica(ch chan<- prometheus.Metric,
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager docs:
// https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object
type win32PerfRawDataSQLServerBufferManager struct { type win32PerfRawDataSQLServerBufferManager struct {
BackgroundwriterpagesPersec uint64 BackgroundwriterpagesPersec uint64
Buffercachehitratio uint64 Buffercachehitratio uint64
@@ -2374,6 +2368,8 @@ func (c *MSSQLCollector) collectBufferManager(ch chan<- prometheus.Metric, sqlIn
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerDatabaseReplica docs:
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-database-replica
type win32PerfRawDataSQLServerDatabaseReplica struct { type win32PerfRawDataSQLServerDatabaseReplica struct {
Name string Name string
DatabaseFlowControlDelay uint64 DatabaseFlowControlDelay uint64
@@ -2586,6 +2582,8 @@ func (c *MSSQLCollector) collectDatabaseReplica(ch chan<- prometheus.Metric, sql
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases docs:
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-databases-object?view=sql-server-2017
type win32PerfRawDataSQLServerDatabases struct { type win32PerfRawDataSQLServerDatabases struct {
Name string Name string
ActiveTransactions uint64 ActiveTransactions uint64
@@ -2974,6 +2972,8 @@ func (c *MSSQLCollector) collectDatabases(ch chan<- prometheus.Metric, sqlInstan
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics docs:
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-general-statistics-object
type win32PerfRawDataSQLServerGeneralStatistics struct { type win32PerfRawDataSQLServerGeneralStatistics struct {
ActiveTempTables uint64 ActiveTempTables uint64
ConnectionResetPersec uint64 ConnectionResetPersec uint64
@@ -3186,6 +3186,8 @@ func (c *MSSQLCollector) collectGeneralStatistics(ch chan<- prometheus.Metric, s
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerLocks docs:
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-locks-object
type win32PerfRawDataSQLServerLocks struct { type win32PerfRawDataSQLServerLocks struct {
Name string Name string
AverageWaitTimems uint64 AverageWaitTimems uint64
@@ -3262,6 +3264,8 @@ func (c *MSSQLCollector) collectLocks(ch chan<- prometheus.Metric, sqlInstance s
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager docs:
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-memory-manager-object
type win32PerfRawDataSQLServerMemoryManager struct { type win32PerfRawDataSQLServerMemoryManager struct {
ConnectionMemoryKB uint64 ConnectionMemoryKB uint64
DatabaseCacheMemoryKB uint64 DatabaseCacheMemoryKB uint64
@@ -3443,6 +3447,8 @@ func (c *MSSQLCollector) collectMemoryManager(ch chan<- prometheus.Metric, sqlIn
return nil, nil return nil, nil
} }
// Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics docs:
// - https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-statistics-object
type win32PerfRawDataSQLServerSQLStatistics struct { type win32PerfRawDataSQLServerSQLStatistics struct {
AutoParamAttemptsPersec uint64 AutoParamAttemptsPersec uint64
BatchRequestsPersec uint64 BatchRequestsPersec uint64

View File

@@ -1,8 +1,4 @@
// returns data points from Win32_PerfRawData_Tcpip_NetworkInterface // +build windows
// https://technet.microsoft.com/en-us/security/aa394340(v=vs.80) (Win32_PerfRawData_Tcpip_NetworkInterface class)
// https://msdn.microsoft.com/en-us/library/aa394216 (Win32_NetworkAdapter class)
// https://msdn.microsoft.com/en-us/library/aa394353 (Win32_PnPEntity class)
package collector package collector
@@ -150,6 +146,8 @@ func mangleNetworkName(name string) string {
return nicNameToUnderscore.ReplaceAllString(name, "_") return nicNameToUnderscore.ReplaceAllString(name, "_")
} }
// Win32_PerfRawData_Tcpip_NetworkInterface docs:
// - https://technet.microsoft.com/en-us/security/aa394340(v=vs.80)
type Win32_PerfRawData_Tcpip_NetworkInterface struct { type Win32_PerfRawData_Tcpip_NetworkInterface struct {
BytesReceivedPerSec uint64 BytesReceivedPerSec uint64
BytesSentPerSec uint64 BytesSentPerSec uint64

View File

@@ -1,3 +1,5 @@
// +build windows
package collector package collector
import "testing" import "testing"

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRExceptions // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRExceptions class
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRInterop // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRInterop class
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRJit // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRJit class
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRLoading // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRLoading class
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads class
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRMemory // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRMemory class
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRRemoting // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRRemoting class
package collector package collector
import ( import (

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_NETFramework_NETCLRSecurity // +build windows
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRSecurity class
package collector package collector
import ( import (

View File

@@ -1,5 +1,4 @@
// returns data points from Win32_OperatingSystem // +build windows
// https://msdn.microsoft.com/en-us/library/aa394239 - Win32_OperatingSystem class
package collector package collector
@@ -122,6 +121,8 @@ func (c *OSCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_OperatingSystem docs:
// - https://msdn.microsoft.com/en-us/library/aa394239 - Win32_OperatingSystem class
type Win32_OperatingSystem struct { type Win32_OperatingSystem struct {
FreePhysicalMemory uint64 FreePhysicalMemory uint64
FreeSpaceInPagingFiles uint64 FreeSpaceInPagingFiles uint64

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_PerfProc_Process // +build windows
// https://msdn.microsoft.com/en-us/library/aa394323(v=vs.85).aspx - Win32_PerfRawData_PerfProc_Process class
package collector package collector
import ( import (
@@ -143,6 +143,8 @@ func (c *ProcessCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_PerfRawData_PerfProc_Process docs:
// - https://msdn.microsoft.com/en-us/library/aa394323(v=vs.85).aspx
type Win32_PerfRawData_PerfProc_Process struct { type Win32_PerfRawData_PerfProc_Process struct {
Name string Name string
CreatingProcessID uint32 CreatingProcessID uint32
@@ -191,7 +193,9 @@ func (c *ProcessCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des
var dst_wp []WorkerProcess var dst_wp []WorkerProcess
q_wp := queryAll(&dst_wp) q_wp := queryAll(&dst_wp)
wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration") if err := wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration"); err != nil {
log.Debugf("Could not query WebAdministration namespace for IIS worker processes: %v. Skipping", err)
}
for _, process := range dst { for _, process := range dst {

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_Service // +build windows
// https://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspx - Win32_Service class
package collector package collector
import ( import (
@@ -72,6 +72,8 @@ func (c *serviceCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_Service docs:
// - https://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspx
type Win32_Service struct { type Win32_Service struct {
Name string Name string
State string State string

View File

@@ -1,5 +1,4 @@
// returns data points from Win32_PerfRawData_PerfOS_System class // +build windows
// https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp
package collector package collector
@@ -78,6 +77,8 @@ func (c *SystemCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_PerfRawData_PerfOS_System docs:
// - https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp
type Win32_PerfRawData_PerfOS_System struct { type Win32_PerfRawData_PerfOS_System struct {
ContextSwitchesPersec uint32 ContextSwitchesPersec uint32
ExceptionDispatchesPersec uint32 ExceptionDispatchesPersec uint32

View File

@@ -1,6 +1,4 @@
// returns data points from Win32_PerfRawData_Tcpip_TCPv4 // +build windows
// https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx (Win32_PerfRawData_Tcpip_TCPv4 class)
package collector package collector
@@ -100,6 +98,8 @@ func (c *TCPCollector) Collect(ch chan<- prometheus.Metric) error {
return nil return nil
} }
// Win32_PerfRawData_Tcpip_TCPv4 docs
// - https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx
type Win32_PerfRawData_Tcpip_TCPv4 struct { type Win32_PerfRawData_Tcpip_TCPv4 struct {
ConnectionFailures uint64 ConnectionFailures uint64
ConnectionsActive uint64 ConnectionsActive uint64

View File

@@ -237,9 +237,17 @@ fileLoop:
continue continue
} }
var parser expfmt.TextParser var parser expfmt.TextParser
r := utfbom.SkipOnly(carriageReturnFilteringReader{r: file}) r, encoding := utfbom.Skip(carriageReturnFilteringReader{r: file})
if err = checkBOM(encoding); err != nil {
log.Errorf("Invalid file encoding detected in %s: %s - file must be UTF8", path, err.Error())
error = 1.0
continue
}
parsedFamilies, err := parser.TextToMetricFamilies(r) parsedFamilies, err := parser.TextToMetricFamilies(r)
file.Close() closeErr := file.Close()
if closeErr != nil {
log.Warnf("Error closing file: %v", err)
}
if err != nil { if err != nil {
log.Errorf("Error parsing %q: %v", path, err) log.Errorf("Error parsing %q: %v", path, err)
error = 1.0 error = 1.0
@@ -281,3 +289,11 @@ fileLoop:
) )
return nil return nil
} }
func checkBOM(encoding utfbom.Encoding) error {
if encoding == utfbom.Unknown || encoding == utfbom.UTF8 {
return nil
}
return fmt.Errorf(encoding.String())
}

View File

@@ -1,14 +1,15 @@
package collector package collector
import ( import (
"testing" "github.com/dimchansky/utfbom"
"strings"
"io/ioutil" "io/ioutil"
"strings"
"testing"
) )
func TestCRFilter(t *testing.T) { func TestCRFilter(t *testing.T) {
sr := strings.NewReader("line 1\r\nline 2") sr := strings.NewReader("line 1\r\nline 2")
cr := carriageReturnFilteringReader{ r: sr } cr := carriageReturnFilteringReader{r: sr}
b, err := ioutil.ReadAll(cr) b, err := ioutil.ReadAll(cr)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@@ -18,3 +19,29 @@ func TestCRFilter(t *testing.T) {
t.Errorf("Unexpected output %q", b) t.Errorf("Unexpected output %q", b)
} }
} }
func TestCheckBOM(t *testing.T) {
testdata := []struct {
encoding utfbom.Encoding
err string
}{
{utfbom.Unknown, ""},
{utfbom.UTF8, ""},
{utfbom.UTF16BigEndian, "UTF16BigEndian"},
{utfbom.UTF16LittleEndian, "UTF16LittleEndian"},
{utfbom.UTF32BigEndian, "UTF32BigEndian"},
{utfbom.UTF32LittleEndian, "UTF32LittleEndian"},
}
for _, d := range testdata {
err := checkBOM(d.encoding)
if d.err == "" && err != nil {
t.Error(err)
}
if d.err != "" && err == nil {
t.Errorf("Missing expected error %s", d.err)
}
if err != nil && !strings.Contains(err.Error(), d.err) {
t.Error(err)
}
}
}

View File

@@ -1,4 +1,5 @@
// returns data points from Win32_PerfRawData_vmGuestLib_VMem and Win32_PerfRawData_vmGuestLib_VCPU // +build windows
package collector package collector
import ( import (
@@ -37,6 +38,7 @@ type VmwareCollector struct {
HostProcessorSpeedMHz *prometheus.Desc HostProcessorSpeedMHz *prometheus.Desc
} }
// NewVmwareCollector constructs a new VmwareCollector
func NewVmwareCollector() (Collector, error) { func NewVmwareCollector() (Collector, error) {
const subsystem = "vmware" const subsystem = "vmware"
return &VmwareCollector{ return &VmwareCollector{

View File

@@ -0,0 +1,140 @@
{{ template "head" . }}
{{ template "prom_content_head" . }}
<h1>Node Overview - {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}</h1>
<h3>CPU Usage</h3>
<div id="cpuGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#cpuGraph"),
expr: "sum by (mode)(irate(wmi_cpu_time_total{job='node',instance='{{ .Params.instance }}',mode!='idle'}[5m]))",
renderer: 'area',
max: {{ with printf "count(count by (cpu)(wmi_cpu_time_total{job='node',instance='%s'}))" .Params.instance | query }}{{ . | first | value }}{{ else}}undefined{{end}},
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yTitle: 'Cores'
})
</script>
<h3>Network Utilization</h3>
<div id="networkioGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#networkioGraph"),
expr: [
"irate(wmi_net_bytes_sent_total{job='node',instance='{{ .Params.instance }}',nic!~'^isatap_ec2_internal'}[5m])",
"irate(wmi_net_bytes_received_total{job='node',instance='{{ .Params.instance }}',nic!~'^isatap_ec2_internal'}[5m])",
],
min: 0,
name: [ 'sent', 'received' ],
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yUnits: "B",
yTitle: 'Network IO'
})
</script>
<h3>Disk I/O Utilization</h3>
<div id="diskioGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#diskioGraph"),
expr: [
"100 - irate(wmi_logical_disk_idle_seconds_total{job='node',instance='{{ .Params.instance }}',volume!~'^HarddiskVolume.*$'}[5m]) * 100",
],
min: 0,
name: '[[ volume ]]',
yAxisFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yHoverFormatter: PromConsole.NumberFormatter.humanizeNoSmallPrefix,
yUnits: "%",
yTitle: 'Disk I/O Utilization'
})
</script>
<h3>Memory</h3>
<div id="memoryGraph"></div>
<script>
new PromConsole.Graph({
node: document.querySelector("#memoryGraph"),
renderer: 'area',
expr: [
"wmi_cs_physical_memory_bytes{job='node',instance='{{ .Params.instance }}'}",
"wmi_os_physical_memory_free_bytes{job='node',instance='{{ .Params.instance }}'}",
"wmi_cs_physical_memory__bytes{job='node',instance='{{ .Params.instance }}'} - wmi_os_physical_memory_free_bytes{job='node',instance='{{.Params.instance}}'}",
"wmi_os_virtual_memory_bytes{job='node',instance='{{ .Params.instance }}'}",
],
name: ["Physical", "Free", "Used", "Virtual"],
min: 0,
yUnits: "B",
yAxisFormatter: PromConsole.NumberFormatter.humanize1024,
yHoverFormatter: PromConsole.NumberFormatter.humanize1024,
yTitle: 'Memory'
})
</script>
{{ template "prom_right_table_head" }}
<tr><th colspan="2">Overview</th></tr>
<tr>
<td>User CPU</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(irate(wmi_cpu_time_total{job='node',instance='%s',mode='user'}[5m])) * 100 / count(count by (cpu)(wmi_cpu_time_total{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.1f") }}</td>
</tr>
<tr>
<td>Privileged CPU</td>
<td>{{ template "prom_query_drilldown" (args (printf "sum(irate(wmi_cpu_time_total{job='node',instance='%s',mode='privileged'}[5m])) * 100 / count(count by (cpu)(wmi_cpu_time_total{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.1f") }}</td>
</tr>
<tr>
<td>Memory Total</td>
<td>{{ template "prom_query_drilldown" (args (printf "wmi_cs_physical_memory_bytes{job='node',instance='%s'}" .Params.instance) "B" "humanize1024") }}</td>
</tr>
<tr>
<td>Memory Free</td>
<td>{{ template "prom_query_drilldown" (args (printf "wmi_os_physical_memory_free_bytes{job='node',instance='%s'}" .Params.instance) "B" "humanize1024") }}</td>
</tr>
<tr>
<th colspan="2">Network</th>
</tr>
{{ range printf "wmi_net_bytes_received_total{job='node',instance='%s',nic!='isatap_ec2_internal'}" .Params.instance | query | sortByLabel "nic" }}
<tr>
<td>{{ .Labels.nic }} Received</td>
<td>{{ template "prom_query_drilldown" (args (printf "irate(wmi_net_bytes_received_total{job='node',instance='%s',nic='%s'}[5m])" .Labels.instance .Labels.nic) "B/s" "humanize") }}</td>
</tr>
<tr>
<td>{{ .Labels.nic }} Transmitted</td>
<td>{{ template "prom_query_drilldown" (args (printf "irate(wmi_net_bytes_sent_total{job='node',instance='%s',nic='%s'}[5m])" .Labels.instance .Labels.nic) "B/s" "humanize") }}</td>
</tr>
{{ end }}
</tr>
<tr>
<th colspan="2">Disks</th>
</tr>
{{ range printf "wmi_logical_disk_size_bytes{job='node',instance='%s',volume!~'^HarddiskVolume.*$'}" .Params.instance | query | sortByLabel "volume" }}
<tr>
<td>{{ .Labels.volume }} Utilization</td>
<td>{{ template "prom_query_drilldown" (args (printf "100 - irate(wmi_logical_disk_idle_seconds_total{job='node',instance='%s',volume='%s'}[5m]) * 100" .Labels.instance .Labels.volume) "%" "printf.1f") }}</td>
</tr>
{{ end }}
{{ range printf "wmi_logical_disk_size_bytes{job='node',instance='%s',volume!~'^HarddiskVolume.*$'}" .Params.instance | query | sortByLabel "volume" }}
<tr>
<td>{{ .Labels.volume }} Throughput</td>
<td>{{ template "prom_query_drilldown" (args (printf "irate(wmi_logical_disk_read_bytes_total{job='node',instance='%s',volume='%s'}[5m]) + irate(wmi_logical_disk_write_bytes_total{job='node',instance='%s',volume='%s'}[5m])" .Labels.instance .Labels.volume .Labels.instance .Labels.volume) "B/s" "humanize") }}</td>
</tr>
{{ end }}
<tr>
<th colspan="2">Filesystem Fullness</th>
</tr>
{{ define "roughlyNearZero" }}
{{ if gt .1 . }}~0{{ else }}{{ printf "%.1f" . }}{{ end }}
{{ end }}
{{ range printf "wmi_logical_disk_size_bytes{job='node',instance='%s',volume!~'^HarddiskVolume.*$'}" .Params.instance | query | sortByLabel "volume" }}
<tr>
<td>{{ .Labels.volume }}</td>
<td>{{ template "prom_query_drilldown" (args (printf "100 - wmi_logical_disk_free_bytes{job='node',instance='%s',volume='%s'} / wmi_logical_disk_size_bytes{job='node'} * 100" .Labels.instance .Labels.volume) "%" "roughlyNearZero") }}</td>
</tr>
{{ end }}
</tr>
{{ template "prom_right_table_tail" }}
{{ template "prom_content_tail" . }}
{{ template "tail" }}

View File

@@ -9,6 +9,7 @@ This directory contains documentation of the collectors in the WMI exporter, wit
- [`hyperv`](collector.hyperv.md) - [`hyperv`](collector.hyperv.md)
- [`iis`](collector.iis.md) - [`iis`](collector.iis.md)
- [`logical_disk`](collector.logical_disk.md) - [`logical_disk`](collector.logical_disk.md)
- [`memory`](collector.memory.md)
- [`msmq`](collector.msmq.md) - [`msmq`](collector.msmq.md)
- [`mssql`](collector.mssql.md) - [`mssql`](collector.mssql.md)
- [`netframework_clrexceptions`](collector.netframework_clrexceptions.md) - [`netframework_clrexceptions`](collector.netframework_clrexceptions.md)

View File

@@ -2,7 +2,9 @@
The %name% collector exposes metrics about ... The %name% collector exposes metrics about ...
Metric name prefix | `%name%` |||
-|-
Metric name prefix | `%name%`
Classes | [`...`](https://msdn.microsoft.com/en-us/library/...) Classes | [`...`](https://msdn.microsoft.com/en-us/library/...)
Enabled by default? | Yes/No Enabled by default? | Yes/No

View File

@@ -2,7 +2,9 @@
The ad collector exposes metrics about a Active Directory Domain Services domain controller The ad collector exposes metrics about a Active Directory Domain Services domain controller
Metric name prefix | `ad` |||
-|-
Metric name prefix | `ad`
Classes | [`Win32_PerfRawData_DirectoryServices_DirectoryServices`](https://msdn.microsoft.com/en-us/library/ms803980.aspx) Classes | [`Win32_PerfRawData_DirectoryServices_DirectoryServices`](https://msdn.microsoft.com/en-us/library/ms803980.aspx)
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The cpu collector exposes metrics about CPU usage The cpu collector exposes metrics about CPU usage
Metric name prefix | `cpu` |||
-|-
Metric name prefix | `cpu`
Classes | [`Win32_PerfRawData_PerfOS_Processor`](https://msdn.microsoft.com/en-us/library/aa394317(v=vs.90).aspx) Classes | [`Win32_PerfRawData_PerfOS_Processor`](https://msdn.microsoft.com/en-us/library/aa394317(v=vs.90).aspx)
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
The cs collector exposes metrics detailing the hardware of the computer system The cs collector exposes metrics detailing the hardware of the computer system
Metric name prefix | `cs` |||
-|-
Metric name prefix | `cs`
Classes | [`Win32_ComputerSystem`](https://msdn.microsoft.com/en-us/library/aa394102) Classes | [`Win32_ComputerSystem`](https://msdn.microsoft.com/en-us/library/aa394102)
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
The dns collector exposes metrics about the DNS server The dns collector exposes metrics about the DNS server
Metric name prefix | `dns` |||
-|-
Metric name prefix | `dns`
Classes | [`Win32_PerfRawData_DNS_DNS`](https://technet.microsoft.com/en-us/library/cc977686.aspx) Classes | [`Win32_PerfRawData_DNS_DNS`](https://technet.microsoft.com/en-us/library/cc977686.aspx)
Enabled by default? | No Enabled by default? | No

View File

@@ -2,8 +2,10 @@
The hyperv collector exposes metrics about the Hyper-V hypervisor The hyperv collector exposes metrics about the Hyper-V hypervisor
Metric name prefix | `hyperv` |||
Classes | `Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary`, `Win32_PerfRawData_VidPerfProvider_HyperVVMVidPartition`, `Win32_PerfRawData_HvStats_HyperVHypervisorRootPartition`, `Win32_PerfRawData_HvStats_HyperVHypervisor`, `Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor`, `Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor`, `Win32_PerfRawData_NvspSwitchStats_HyperVVirtualSwitch`, `Win32_PerfRawData_EthernetPerfProvider_HyperVLegacyNetworkAdapter`, `Win32_PerfRawData_Counters_HyperVVirtualStorageDevice`, `Win32_PerfRawData_NvspNicStats_HyperVVirtualNetworkAdapter` -|-
Metric name prefix | `hyperv`
Classes | `Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary`<br/>`Win32_PerfRawData_VidPerfProvider_HyperVVMVidPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor`<br/>`Win32_PerfRawData_NvspSwitchStats_HyperVVirtualSwitch`<br/>`Win32_PerfRawData_EthernetPerfProvider_HyperVLegacyNetworkAdapter`<br/>`Win32_PerfRawData_Counters_HyperVVirtualStorageDevice`<br/>`Win32_PerfRawData_NvspNicStats_HyperVVirtualNetworkAdapter`
Enabled by default? | No Enabled by default? | No
## Flags ## Flags

View File

@@ -2,8 +2,10 @@
The iis collector exposes metrics about the IIS server The iis collector exposes metrics about the IIS server
Metric name prefix | `iis` |||
Classes | `Win32_PerfRawData_W3SVC_WebService`, `Win32_PerfRawData_APPPOOLCountersProvider_APPPOOLWAS`, `Win32_PerfRawData_W3SVCW3WPCounterProvider_W3SVCW3WP`, `Win32_PerfRawData_W3SVC_WebServiceCache` -|-
Metric name prefix | `iis`
Classes | `Win32_PerfRawData_W3SVC_WebService`<br/>`Win32_PerfRawData_APPPOOLCountersProvider_APPPOOLWAS`<br/>`Win32_PerfRawData_W3SVCW3WPCounterProvider_W3SVCW3WP`<br/>`Win32_PerfRawData_W3SVC_WebServiceCache`
Enabled by default? | No Enabled by default? | No
## Flags ## Flags

View File

@@ -2,7 +2,9 @@
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`
Classes | [`Win32_PerfRawData_PerfDisk_LogicalDisk`](https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71)) Classes | [`Win32_PerfRawData_PerfDisk_LogicalDisk`](https://msdn.microsoft.com/en-us/windows/hardware/aa394307(v=vs.71))
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
The msmq collector exposes metrics about the queues on a MSMQ server The msmq collector exposes metrics about the queues on a MSMQ server
Metric name prefix | `msmq` |||
-|-
Metric name prefix | `msmq`
Classes | `Win32_PerfRawData_MSMQ_MSMQQueue` Classes | `Win32_PerfRawData_MSMQ_MSMQQueue`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,8 +2,10 @@
The mssql collector exposes metrics about the MSSQL server The mssql collector exposes metrics about the MSSQL server
Metric name prefix | `mssql` |||
Classes | [`Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-access-methods-object), [`Win32_PerfRawData_MSSQLSERVER_SQLServerAvailabilityReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-availability-replica), [`Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object), [`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabaseReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-database-replica), [`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-databases-object?view=sql-server-2017), [`Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-general-statistics-object), [`Win32_PerfRawData_MSSQLSERVER_SQLServerLocks`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-locks-object), [`Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-memory-manager-object), [`Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-statistics-object) -|-
Metric name prefix | `mssql`
Classes | [`Win32_PerfRawData_MSSQLSERVER_SQLServerAccessMethods`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-access-methods-object)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerAvailabilityReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-availability-replica)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-buffer-manager-object)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabaseReplica`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-database-replica)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-databases-object?view=sql-server-2017)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-general-statistics-object)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerLocks`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-locks-object)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerMemoryManager`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-memory-manager-object)<br/>[`Win32_PerfRawData_MSSQLSERVER_SQLServerSQLStatistics`](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/sql-server-sql-statistics-object)
Enabled by default? | No Enabled by default? | No
## Flags ## Flags

View File

@@ -2,7 +2,9 @@
The net collector exposes metrics about network interfaces The net collector exposes metrics about network interfaces
Metric name prefix | `net` |||
-|-
Metric name prefix | `net`
Classes | [`Win32_PerfRawData_Tcpip_NetworkInterface`](https://technet.microsoft.com/en-us/security/aa394340(v=vs.80)) Classes | [`Win32_PerfRawData_Tcpip_NetworkInterface`](https://technet.microsoft.com/en-us/security/aa394340(v=vs.80))
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
The netframework_clrexceptions collector exposes metrics about CLR exceptions in the dotnet framework. The netframework_clrexceptions collector exposes metrics about CLR exceptions in the dotnet framework.
Metric name prefix | `netframework_clrexceptions` |||
-|-
Metric name prefix | `netframework_clrexceptions`
Classes | `Win32_PerfRawData_NETFramework_NETCLRExceptions` Classes | `Win32_PerfRawData_NETFramework_NETCLRExceptions`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The netframework_clrinterop collector exposes metrics about interop between the dotnet framework and outside components. The netframework_clrinterop collector exposes metrics about interop between the dotnet framework and outside components.
Metric name prefix | `netframework_clrinterop` |||
-|-
Metric name prefix | `netframework_clrinterop`
Classes | `Win32_PerfRawData_NETFramework_NETCLRInterop` Classes | `Win32_PerfRawData_NETFramework_NETCLRInterop`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The netframework_clrjit collector exposes metrics about the dotnet Just-in-Time compiler. The netframework_clrjit collector exposes metrics about the dotnet Just-in-Time compiler.
Metric name prefix | `netframework_clrjit` |||
-|-
Metric name prefix | `netframework_clrjit`
Classes | `Win32_PerfRawData_NETFramework_NETCLRJit` Classes | `Win32_PerfRawData_NETFramework_NETCLRJit`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The netframework_clrloading collector exposes metrics about the dotnet loader. The netframework_clrloading collector exposes metrics about the dotnet loader.
Metric name prefix | `netframework_clrloading` |||
-|-
Metric name prefix | `netframework_clrloading`
Classes | `Win32_PerfRawData_NETFramework_NETCLRLoading` Classes | `Win32_PerfRawData_NETFramework_NETCLRLoading`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The netframework_clrlocksandthreads collector exposes metrics about locks and threads in dotnet applications. The netframework_clrlocksandthreads collector exposes metrics about locks and threads in dotnet applications.
Metric name prefix | `netframework_clrlocksandthreads` |||
-|-
Metric name prefix | `netframework_clrlocksandthreads`
Classes | `Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads` Classes | `Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The netframework_clrmemory collector exposes metrics about memory in dotnet applications. The netframework_clrmemory collector exposes metrics about memory in dotnet applications.
Metric name prefix | `netframework_clrmemory` |||
-|-
Metric name prefix | `netframework_clrmemory`
Classes | `Win32_PerfRawData_NETFramework_NETCLRMemory` Classes | `Win32_PerfRawData_NETFramework_NETCLRMemory`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The netframework_clrremoting collector exposes metrics about dotnet remoting. The netframework_clrremoting collector exposes metrics about dotnet remoting.
Metric name prefix | `netframework_clrremoting` |||
-|-
Metric name prefix | `netframework_clrremoting`
Classes | `Win32_PerfRawData_NETFramework_NETCLRRemoting` Classes | `Win32_PerfRawData_NETFramework_NETCLRRemoting`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The netframework_clrsecurity collector exposes metrics about security checks in dotnet applications The netframework_clrsecurity collector exposes metrics about security checks in dotnet applications
Metric name prefix | `netframework_clrsecurity` |||
-|-
Metric name prefix | `netframework_clrsecurity`
Classes | `Win32_PerfRawData_NETFramework_NETCLRSecurity` Classes | `Win32_PerfRawData_NETFramework_NETCLRSecurity`
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The os collector exposes metrics about the operating system The os collector exposes metrics about the operating system
Metric name prefix | `os` |||
-|-
Metric name prefix | `os`
Classes | [`Win32_OperatingSystem`](https://msdn.microsoft.com/en-us/library/aa394239) Classes | [`Win32_OperatingSystem`](https://msdn.microsoft.com/en-us/library/aa394239)
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
The process collector exposes metrics about processes The process collector exposes metrics about processes
Metric name prefix | `process` |||
-|-
Metric name prefix | `process`
Classes | [`Win32_PerfRawData_PerfProc_Process`](https://msdn.microsoft.com/en-us/library/aa394323(v=vs.85).aspx) Classes | [`Win32_PerfRawData_PerfProc_Process`](https://msdn.microsoft.com/en-us/library/aa394323(v=vs.85).aspx)
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The service collector exposes metrics about Windows Services The service collector exposes metrics about Windows Services
Metric name prefix | `service` |||
-|-
Metric name prefix | `service`
Classes | [`Win32_Service`](https://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspx) Classes | [`Win32_Service`](https://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspx)
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
The system collector exposes metrics about ... The system collector exposes metrics about ...
Metric name prefix | `system` |||
-|-
Metric name prefix | `system`
Classes | [`Win32_PerfRawData_PerfOS_System`](https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp) Classes | [`Win32_PerfRawData_PerfOS_System`](https://web.archive.org/web/20050830140516/http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_perfrawdata_perfos_system.asp)
Enabled by default? | Yes Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
The tcp collector exposes metrics about the TCP/IPv4 network stack. The tcp collector exposes metrics about the TCP/IPv4 network stack.
Metric name prefix | `tcp` |||
-|-
Metric name prefix | `tcp`
Classes | [`Win32_PerfRawData_Tcpip_TCPv4`](https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx) Classes | [`Win32_PerfRawData_Tcpip_TCPv4`](https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx)
Enabled by default? | No Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The textfile collector exposes metrics from files written by other processes. The textfile collector exposes metrics from files written by other processes.
Metric name prefix | `textfile` |||
-|-
Metric name prefix | `textfile`
Classes | None Classes | None
Enabled by default? | Yes Enabled by default? | Yes
@@ -10,7 +12,7 @@ Enabled by default? | Yes
### `--collector.textfile.directory` ### `--collector.textfile.directory`
The directory containing the files to be ingested. The directory containing the files to be ingested. Only files with the extension `.prom` are read.
Default value: `C:\Program Files\wmi_exporter\textfile_inputs` Default value: `C:\Program Files\wmi_exporter\textfile_inputs`
@@ -34,3 +36,21 @@ _This collector does not yet have any useful queries added, we would appreciate
## 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!_
# Example use
This Powershell script, when run in the `collector.textfile.directory` (default `C:\Program Files\wmi_exporter\textfile_inputs`), generates a valid `.prom` file that should successfully ingested by wmi_exporter.
```Powershell
$alpha = 42
$beta = @{ left=3.1415; right=2.718281828; }
Set-Content -Path test1.prom -Encoding Ascii -NoNewline -Value ""
Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# HELP test_alpha_total Some random metric.`n"
Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# TYPE test_alpha_total counter`n"
Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "test_alpha_total ${alpha}`n"
Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# HELP test_beta_bytes Some other metric.`n"
Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "# TYPE test_beta_bytes gauge`n"
foreach ($k in $beta.Keys) {
Add-Content -Path test1.prom -Encoding Ascii -NoNewline -Value "test_beta_bytes{spin=""${k}""} $( $beta[$k] )`n"
}
```

View File

@@ -2,7 +2,9 @@
The vmware collector exposes metrics about a VMware guest VM The vmware collector exposes metrics about a VMware guest VM
Metric name prefix | `vmware` |||
-|-
Metric name prefix | `vmware`
Classes | `Win32_PerfRawData_vmGuestLib_VMem`, `Win32_PerfRawData_vmGuestLib_VCPU` Classes | `Win32_PerfRawData_vmGuestLib_VMem`, `Win32_PerfRawData_vmGuestLib_VCPU`
Enabled by default? | No Enabled by default? | No

View File

@@ -1,8 +1,9 @@
// +build windows
package main package main
import ( import (
"fmt" "fmt"
"io"
"net/http" "net/http"
"sort" "sort"
"strings" "strings"
@@ -220,7 +221,12 @@ func main() {
stopCh := make(chan bool) stopCh := make(chan bool)
if !isInteractive { if !isInteractive {
go svc.Run(serviceName, &wmiExporterService{stopCh: stopCh}) go func() {
err = svc.Run(serviceName, &wmiExporterService{stopCh: stopCh})
if err != nil {
log.Errorf("Failed to start service: %v", err)
}
}()
} }
collectors, err := loadCollectors(*enabledCollectors) collectors, err := loadCollectors(*enabledCollectors)
@@ -257,7 +263,10 @@ func main() {
func healthCheck(w http.ResponseWriter, r *http.Request) { func healthCheck(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
io.WriteString(w, `{"status":"ok"}`) _, err := fmt.Fprintln(w, `{"status":"ok"}`)
if err != nil {
log.Debugf("Failed to write to stream: %v", err)
}
} }
func keys(m map[string]collector.Collector) []string { func keys(m map[string]collector.Collector) []string {

View File

@@ -1,3 +1,5 @@
// +build windows
package main package main
import ( import (

28
gometalinter.config Normal file
View File

@@ -0,0 +1,28 @@
{
"Disable": [
"goconst",
"gocyclo",
"gosec",
"maligned",
"megacheck"
],
"Enable": [
"deadcode",
"errcheck",
"golint",
"gotype",
"gotypex",
"ineffassign",
"interfacer",
"structcheck",
"unconvert",
"varcheck",
"vet",
"vetshadow"
],
"Exclude": [
"don't use underscores in Go names",
"exported type .+ should have comment or be unexported",
"should be"
]
}

View File

@@ -19,6 +19,9 @@
<Property Id="ENABLED_COLLECTORS" Secure="yes"/> <Property Id="ENABLED_COLLECTORS" Secure="yes"/>
<SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]">ENABLED_COLLECTORS</SetProperty> <SetProperty Id="CollectorsFlag" After="InstallFiles" Sequence="execute" Value="--collectors.enabled [ENABLED_COLLECTORS]">ENABLED_COLLECTORS</SetProperty>
<Property Id="EXTRA_FLAGS" Secure="yes"/>
<SetProperty Id="ExtraFlags" After="InstallFiles" Sequence="execute" Value="[EXTRA_FLAGS]">EXTRA_FLAGS</SetProperty>
<Property Id="LISTEN_ADDR" Secure="yes" /> <Property Id="LISTEN_ADDR" Secure="yes" />
<Property Id="LISTEN_PORT" Secure="yes" Value="9182" /> <Property Id="LISTEN_PORT" Secure="yes" Value="9182" />
<SetProperty Id="ListenFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.addr [LISTEN_ADDR]:[LISTEN_PORT]">LISTEN_ADDR OR LISTEN_PORT</SetProperty> <SetProperty Id="ListenFlag" After="InstallFiles" Sequence="execute" Value="--telemetry.addr [LISTEN_ADDR]:[LISTEN_PORT]">LISTEN_ADDR OR LISTEN_PORT</SetProperty>
@@ -42,10 +45,11 @@
<File Id="wmi_exporter.exe" Name="wmi_exporter.exe" Source="Work\wmi_exporter.exe" KeyPath="yes"> <File Id="wmi_exporter.exe" Name="wmi_exporter.exe" Source="Work\wmi_exporter.exe" KeyPath="yes">
<fw:FirewallException Id="MetricsEndpoint" Name="WMI Exporter (HTTP [LISTEN_PORT])" Description="WMI Exporter HTTP endpoint" Port="[LISTEN_PORT]" Protocol="tcp" Scope="any" IgnoreFailure="yes" /> <fw:FirewallException Id="MetricsEndpoint" Name="WMI Exporter (HTTP [LISTEN_PORT])" Description="WMI Exporter HTTP endpoint" Port="[LISTEN_PORT]" Protocol="tcp" Scope="any" IgnoreFailure="yes" />
</File> </File>
<ServiceInstall Id="InstallExporterService" Name="wmi_exporter" DisplayName="WMI exporter" Description="Exports Prometheus metrics from WMI queries" ErrorControl="normal" Start="auto" Type="ownProcess" Arguments="--log.format logger:eventlog?name=wmi_exporter [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirFlag]"> <ServiceInstall Id="InstallExporterService" Name="wmi_exporter" DisplayName="WMI exporter" Description="Exports Prometheus metrics from WMI queries" ErrorControl="normal" Start="auto" Type="ownProcess" Arguments="--log.format logger:eventlog?name=wmi_exporter [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirFlag] [ExtraFlags]">
<util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RestartServiceDelayInSeconds="5" /> <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RestartServiceDelayInSeconds="5" />
</ServiceInstall> </ServiceInstall>
<ServiceControl Id="ServiceStateControl" Name="wmi_exporter" Remove="uninstall" Start="install" Stop="both" /> <ServiceControl Id="ServiceStateControl" Name="wmi_exporter" Remove="uninstall" Start="install" Stop="both" />
<util:EventSource Log="Application" Name="wmi_exporter" EventMessageFile="%SystemRoot%\System32\EventCreate.exe" />
</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 />

View File

@@ -1,5 +1,3 @@
// returns data points from {{ .Class }}
// <add link to documentation here> - {{ .Class }} class
package collector package collector
import ( import (
"github.com/StackExchange/wmi" "github.com/StackExchange/wmi"
@@ -38,6 +36,8 @@ func (c *{{ .CollectorName }}Collector) Collect(ch chan<- prometheus.Metric) err
} }
return nil return nil
} }
// {{ .Class }} docs:
// - <add link to documentation here>
type {{ .Class }} struct { type {{ .Class }} struct {
Name string Name string
{{ range $m := .Members }} {{ range $m := .Members }}

View File

@@ -25,7 +25,7 @@ func main() {
panic(err) panic(err)
} }
var data TemplateData var data TemplateData
if err := json.Unmarshal(bytes, &data); err != nil { if err = json.Unmarshal(bytes, &data); err != nil {
panic(err) panic(err)
} }
@@ -33,11 +33,11 @@ func main() {
"toLower": strings.ToLower, "toLower": strings.ToLower,
"toSnakeCase": toSnakeCase, "toSnakeCase": toSnakeCase,
} }
template, err := template.New("template").Funcs(funcs).ParseFiles("collector.template") tmpl, err := template.New("template").Funcs(funcs).ParseFiles("collector.template")
if err != nil { if err != nil {
panic(err) panic(err)
} }
err = template.ExecuteTemplate(os.Stdout, "collector.template", data) err = tmpl.ExecuteTemplate(os.Stdout, "collector.template", data)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@@ -32,6 +32,24 @@ const (
UTF32LittleEndian UTF32LittleEndian
) )
// String returns a user-friendly string representation of the encoding. Satisfies fmt.Stringer interface.
func (e Encoding) String() string {
switch e {
case UTF8:
return "UTF8"
case UTF16BigEndian:
return "UTF16BigEndian"
case UTF16LittleEndian:
return "UTF16LittleEndian"
case UTF32BigEndian:
return "UTF32BigEndian"
case UTF32LittleEndian:
return "UTF32LittleEndian"
default:
return "Unknown"
}
}
const maxConsecutiveEmptyReads = 100 const maxConsecutiveEmptyReads = 100
// Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary. // Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary.