mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-02 08:36:36 +00:00
9
Makefile
9
Makefile
@@ -1,14 +1,17 @@
|
|||||||
export GOOS=windows
|
export GOOS=windows
|
||||||
|
|
||||||
fmt:
|
|
||||||
gofmt -l -w -s .
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
promu build -v
|
promu build -v
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
|
||||||
|
lint:
|
||||||
|
gometalinter --vendor --config gometalinter.config ./...
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
gofmt -l -w -s .
|
||||||
|
|
||||||
crossbuild:
|
crossbuild:
|
||||||
# The prometheus/golang-builder image for promu crossbuild doesn't exist
|
# The prometheus/golang-builder image for promu crossbuild doesn't exist
|
||||||
# on Windows, so for now, we'll just build twice
|
# on Windows, so for now, we'll just build twice
|
||||||
|
|||||||
@@ -12,11 +12,15 @@ clone_folder: c:\gopath\src\github.com\martinlindhe\wmi_exporter
|
|||||||
install:
|
install:
|
||||||
- set PATH=%GOPATH%\bin;%PATH%
|
- set PATH=%GOPATH%\bin;%PATH%
|
||||||
- go get -u github.com/prometheus/promu
|
- go get -u github.com/prometheus/promu
|
||||||
|
- go get -u github.com/alecthomas/gometalinter && gometalinter --install
|
||||||
- choco install gitversion.portable make -y
|
- choco install gitversion.portable make -y
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- make test
|
- make test
|
||||||
|
|
||||||
|
after_test:
|
||||||
|
- make lint
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- ps: |
|
- ps: |
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_DirectoryServices_DirectoryServices
|
|
||||||
// Partial docs: https://msdn.microsoft.com/en-us/library/ms803980.aspx
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -465,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
|
||||||
|
|
||||||
@@ -488,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
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -25,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{
|
||||||
@@ -66,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
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_ComputerSystem
|
|
||||||
// https://msdn.microsoft.com/en-us/library/aa394102 - Win32_ComputerSystem class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -53,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
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -193,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
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -36,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 {
|
||||||
@@ -808,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()
|
||||||
@@ -986,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",
|
||||||
@@ -1267,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
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -146,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
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_MSMQ_MSMQQueue
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_MSMQ_MSMQQueue class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,23 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -64,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 {
|
||||||
@@ -383,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"),
|
||||||
@@ -1655,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)
|
||||||
@@ -1723,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
|
||||||
@@ -2087,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
|
||||||
@@ -2179,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
|
||||||
@@ -2376,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
|
||||||
@@ -2588,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
|
||||||
@@ -2976,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
|
||||||
@@ -3188,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
|
||||||
@@ -3264,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
|
||||||
@@ -3445,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
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -152,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
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRExceptions
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRExceptions class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRInterop
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRInterop class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRJit
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRJit class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRLoading
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRLoading class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRLocksAndThreads class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRMemory
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRMemory class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRRemoting
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRRemoting class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRSecurity
|
|
||||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRSecurity class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_OperatingSystem
|
|
||||||
// https://msdn.microsoft.com/en-us/library/aa394239 - Win32_OperatingSystem class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -124,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
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -146,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
|
||||||
@@ -195,7 +194,7 @@ 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)
|
||||||
if err := wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration"); err != nil {
|
if err := wmi.QueryNamespace(q_wp, &dst_wp, "root\\WebAdministration"); err != nil {
|
||||||
log.Warnf("failed querying worker processes: %s", err)
|
log.Debugf("Could not query WebAdministration namespace for IIS worker processes: %v. Skipping", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, process := range dst {
|
for _, process := range dst {
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// returns data points from Win32_Service
|
|
||||||
// https://msdn.microsoft.com/en-us/library/aa394418(v=vs.85).aspx - Win32_Service class
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -75,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
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -80,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
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
// 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
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -102,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
|
||||||
|
|||||||
@@ -238,13 +238,16 @@ fileLoop:
|
|||||||
}
|
}
|
||||||
var parser expfmt.TextParser
|
var parser expfmt.TextParser
|
||||||
r, encoding := utfbom.Skip(carriageReturnFilteringReader{r: file})
|
r, encoding := utfbom.Skip(carriageReturnFilteringReader{r: file})
|
||||||
if err := checkBOM(encoding); err != nil {
|
if err = checkBOM(encoding); err != nil {
|
||||||
log.Errorf("Invalid file encoding detected in %s: %s - file must be UTF8", path, err.Error())
|
log.Errorf("Invalid file encoding detected in %s: %s - file must be UTF8", path, err.Error())
|
||||||
error = 1.0
|
error = 1.0
|
||||||
continue
|
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
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// returns data points from Win32_PerfRawData_vmGuestLib_VMem and Win32_PerfRawData_vmGuestLib_VCPU
|
|
||||||
|
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package collector
|
package collector
|
||||||
@@ -40,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{
|
||||||
|
|||||||
13
exporter.go
13
exporter.go
@@ -4,7 +4,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -222,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)
|
||||||
@@ -259,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 {
|
||||||
|
|||||||
28
gometalinter.config
Normal file
28
gometalinter.config
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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 }}
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user