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
*.swp
*.un~
output/

View File

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

6
Gopkg.lock generated
View File

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

View File

@@ -1,5 +1,19 @@
fmt:
gofmt -l -w -s .
export GOOS=windows
build:
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
---------|-------------|--------------------
[ad](docs/collector.ad.md) | [Win32_PerfRawData_DirectoryServices_DirectoryServices](https://msdn.microsoft.com/en-us/library/ms803980.aspx) Active Directory |
[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;
[cs](docs/collector.cs.md) | [Win32_ComputerSystem](https://msdn.microsoft.com/en-us/library/aa394102) 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) |
[hyperv](docs/collector.hyperv.md) | Performance counters for Hyper-V hosts |
[iis](docs/collector.iis.md) | [Win32_PerfRawData_W3SVC_WebService](https://msdn.microsoft.com/en-us/library/aa394345) IIS metrics |
[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;
[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;
[ad](docs/collector.ad.md) | Active Directory Domain Services |
[cpu](docs/collector.cpu.md) | CPU usage | &#10003;
[cs](docs/collector.cs.md) | "Computer System" metrics (system properties, num cpus/total memory) | &#10003;
[dns](docs/collector.dns.md) | DNS Server |
[hyperv](docs/collector.hyperv.md) | Hyper-V hosts |
[iis](docs/collector.iis.md) | IIS sites and applications |
[logical_disk](docs/collector.logical_disk.md) | Logical disks, disk I/O | &#10003;
[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) |
[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 |
[os](docs/collector.os.md) | [Win32_OperatingSystem](https://msdn.microsoft.com/en-us/library/aa394239) metrics (memory, processes, users) | &#10003;
[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) |
[msmq](docs/collector.msmq.md) | MSMQ queues |
[mssql](docs/collector.mssql.md) | [SQL Server Performance Objects](https://docs.microsoft.com/en-us/sql/relational-databases/performance-monitor/use-sql-server-objects#SQLServerPOs) metrics |
[netframework_clrexceptions](docs/collector.netframework_clrexceptions.md) | .NET Framework CLR Exceptions |
[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;
[system](docs/collector.system.md) | Win32_PerfRawData_PerfOS_System metrics (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) |
[system](docs/collector.system.md) | System calls | &#10003;
[tcp](docs/collector.tcp.md) | TCP connections |
[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 |
@@ -44,13 +52,19 @@ Name | Description
`LISTEN_PORT` | The port to bind to. Defaults to 9182.
`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
`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
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
See [open issues](https://github.com/martinlindhe/wmi_exporter/issues)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,4 @@
// returns data points from Win32_PerfRawData_PerfDisk_LogicalDisk
// 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
// +build windows
package collector
@@ -144,6 +142,9 @@ func (c *LogicalDiskCollector) Collect(ch chan<- prometheus.Metric) error {
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 {
Name string
CurrentDiskQueueLength uint32

View File

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

View File

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

View File

@@ -1,22 +1,4 @@
// returns data points from the following 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
// +build windows
package collector
@@ -62,7 +44,12 @@ func getMSSQLInstances() mssqlInstancesType {
log.Warn("Couldn't open registry to determine SQL instances:", err)
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)
if err != nil {
@@ -381,7 +368,7 @@ func NewMSSQLCollector() (Collector, error) {
const subsystem = "mssql"
MSSQLCollector := MSSQLCollector{
mssqlCollector := MSSQLCollector{
// meta
mssqlScrapeDurationDesc: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "collector_duration_seconds"),
@@ -1653,17 +1640,17 @@ func NewMSSQLCollector() (Collector, error) {
mssqlInstances: getMSSQLInstances(),
}
MSSQLCollector.mssqlCollectors = MSSQLCollector.getMSSQLCollectors()
mssqlCollector.mssqlCollectors = mssqlCollector.getMSSQLCollectors()
if *mssqlPrintCollectors {
fmt.Printf("Available SQLServer Classes:\n")
for name := range MSSQLCollector.mssqlCollectors {
for name := range mssqlCollector.mssqlCollectors {
fmt.Printf(" - %s\n", name)
}
os.Exit(0)
}
return &MSSQLCollector, nil
return &mssqlCollector, nil
}
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
}
// 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 {
AUcleanupbatchesPersec uint64
AUcleanupsPersec uint64
@@ -2085,6 +2075,8 @@ func (c *MSSQLCollector) collectAccessMethods(ch chan<- prometheus.Metric, sqlIn
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 {
Name string
BytesReceivedfromReplicaPersec uint64
@@ -2177,6 +2169,8 @@ func (c *MSSQLCollector) collectAvailabilityReplica(ch chan<- prometheus.Metric,
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 {
BackgroundwriterpagesPersec uint64
Buffercachehitratio uint64
@@ -2374,6 +2368,8 @@ func (c *MSSQLCollector) collectBufferManager(ch chan<- prometheus.Metric, sqlIn
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 {
Name string
DatabaseFlowControlDelay uint64
@@ -2586,6 +2582,8 @@ func (c *MSSQLCollector) collectDatabaseReplica(ch chan<- prometheus.Metric, sql
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 {
Name string
ActiveTransactions uint64
@@ -2974,6 +2972,8 @@ func (c *MSSQLCollector) collectDatabases(ch chan<- prometheus.Metric, sqlInstan
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 {
ActiveTempTables uint64
ConnectionResetPersec uint64
@@ -3186,6 +3186,8 @@ func (c *MSSQLCollector) collectGeneralStatistics(ch chan<- prometheus.Metric, s
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 {
Name string
AverageWaitTimems uint64
@@ -3262,6 +3264,8 @@ func (c *MSSQLCollector) collectLocks(ch chan<- prometheus.Metric, sqlInstance s
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 {
ConnectionMemoryKB uint64
DatabaseCacheMemoryKB uint64
@@ -3443,6 +3447,8 @@ func (c *MSSQLCollector) collectMemoryManager(ch chan<- prometheus.Metric, sqlIn
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 {
AutoParamAttemptsPersec uint64
BatchRequestsPersec uint64

View File

@@ -1,8 +1,4 @@
// returns data points from Win32_PerfRawData_Tcpip_NetworkInterface
// 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)
// +build windows
package collector
@@ -150,6 +146,8 @@ func mangleNetworkName(name string) string {
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 {
BytesReceivedPerSec uint64
BytesSentPerSec uint64

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
// returns data points from Win32_PerfRawData_PerfProc_Process
// https://msdn.microsoft.com/en-us/library/aa394323(v=vs.85).aspx - Win32_PerfRawData_PerfProc_Process class
// +build windows
package collector
import (
@@ -143,6 +143,8 @@ func (c *ProcessCollector) Collect(ch chan<- prometheus.Metric) error {
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 {
Name string
CreatingProcessID uint32
@@ -191,7 +193,9 @@ func (c *ProcessCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des
var dst_wp []WorkerProcess
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 {

View File

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

View File

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

View File

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

View File

@@ -237,9 +237,17 @@ fileLoop:
continue
}
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)
file.Close()
closeErr := file.Close()
if closeErr != nil {
log.Warnf("Error closing file: %v", err)
}
if err != nil {
log.Errorf("Error parsing %q: %v", path, err)
error = 1.0
@@ -281,3 +289,11 @@ fileLoop:
)
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
import (
"testing"
"strings"
"github.com/dimchansky/utfbom"
"io/ioutil"
"strings"
"testing"
)
func TestCRFilter(t *testing.T) {
sr := strings.NewReader("line 1\r\nline 2")
cr := carriageReturnFilteringReader{ r: sr }
cr := carriageReturnFilteringReader{r: sr}
b, err := ioutil.ReadAll(cr)
if err != nil {
t.Error(err)
@@ -17,4 +18,30 @@ func TestCRFilter(t *testing.T) {
if string(b) != "line 1\nline 2" {
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
import (
@@ -37,6 +38,7 @@ type VmwareCollector struct {
HostProcessorSpeedMHz *prometheus.Desc
}
// NewVmwareCollector constructs a new VmwareCollector
func NewVmwareCollector() (Collector, error) {
const subsystem = "vmware"
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)
- [`iis`](collector.iis.md)
- [`logical_disk`](collector.logical_disk.md)
- [`memory`](collector.memory.md)
- [`msmq`](collector.msmq.md)
- [`mssql`](collector.mssql.md)
- [`netframework_clrexceptions`](collector.netframework_clrexceptions.md)
@@ -26,4 +27,4 @@ This directory contains documentation of the collectors in the WMI exporter, wit
- [`system`](collector.system.md)
- [`tcp`](collector.tcp.md)
- [`textfile`](collector.textfile.md)
- [`vmware`](collector.vmware.md)
- [`vmware`](collector.vmware.md)

View File

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

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | No

View File

@@ -2,8 +2,10 @@
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
## Flags

View File

@@ -2,8 +2,10 @@
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
## Flags

View File

@@ -2,7 +2,9 @@
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))
Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
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`
Enabled by default? | No

View File

@@ -2,8 +2,10 @@
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
## Flags

View File

@@ -2,7 +2,9 @@
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))
Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
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`
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.
Metric name prefix | `netframework_clrinterop`
|||
-|-
Metric name prefix | `netframework_clrinterop`
Classes | `Win32_PerfRawData_NETFramework_NETCLRInterop`
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
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`
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
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`
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
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`
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
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`
Enabled by default? | No

View File

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

View File

@@ -2,7 +2,9 @@
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`
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | Yes

View File

@@ -2,7 +2,9 @@
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)
Enabled by default? | No

View File

@@ -2,7 +2,9 @@
The textfile collector exposes metrics from files written by other processes.
Metric name prefix | `textfile`
|||
-|-
Metric name prefix | `textfile`
Classes | None
Enabled by default? | Yes
@@ -10,7 +12,7 @@ Enabled by default? | Yes
### `--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`
@@ -34,3 +36,21 @@ _This collector does not yet have any useful queries added, we would appreciate
## Alerting examples
_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
Metric name prefix | `vmware`
|||
-|-
Metric name prefix | `vmware`
Classes | `Win32_PerfRawData_vmGuestLib_VMem`, `Win32_PerfRawData_vmGuestLib_VCPU`
Enabled by default? | No

View File

@@ -1,8 +1,9 @@
// +build windows
package main
import (
"fmt"
"io"
"net/http"
"sort"
"strings"
@@ -220,7 +221,12 @@ func main() {
stopCh := make(chan bool)
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)
@@ -257,7 +263,10 @@ func main() {
func healthCheck(w http.ResponseWriter, r *http.Request) {
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 {

View File

@@ -1,3 +1,5 @@
// +build windows
package main
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"/>
<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_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>
@@ -42,10 +45,11 @@
<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" />
</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" />
</ServiceInstall>
<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 Id="CreateTextfileDirectory" Directory="textfile_inputs" Guid="d03ef58a-9cbf-4165-ad39-d143e9b27e14">
<CreateFolder />

View File

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

View File

@@ -25,7 +25,7 @@ func main() {
panic(err)
}
var data TemplateData
if err := json.Unmarshal(bytes, &data); err != nil {
if err = json.Unmarshal(bytes, &data); err != nil {
panic(err)
}
@@ -33,11 +33,11 @@ func main() {
"toLower": strings.ToLower,
"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 {
panic(err)
}
err = template.ExecuteTemplate(os.Stdout, "collector.template", data)
err = tmpl.ExecuteTemplate(os.Stdout, "collector.template", data)
if err != nil {
panic(err)
}

View File

@@ -32,6 +32,24 @@ const (
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
// Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary.