mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
9
Makefile
9
Makefile
@@ -1,14 +1,17 @@
|
||||
export GOOS=windows
|
||||
|
||||
fmt:
|
||||
gofmt -l -w -s .
|
||||
|
||||
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
|
||||
|
||||
@@ -12,11 +12,15 @@ 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"
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -465,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
|
||||
|
||||
@@ -488,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -25,6 +22,7 @@ type CPUCollector struct {
|
||||
DPCsTotal *prometheus.Desc
|
||||
}
|
||||
|
||||
// NewCPUCollector constructs a new CPUCollector
|
||||
func NewCPUCollector() (Collector, error) {
|
||||
const subsystem = "cpu"
|
||||
return &CPUCollector{
|
||||
@@ -66,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
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// returns data points from Win32_ComputerSystem
|
||||
// https://msdn.microsoft.com/en-us/library/aa394102 - Win32_ComputerSystem class
|
||||
|
||||
// +build windows
|
||||
|
||||
package collector
|
||||
@@ -53,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -193,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -36,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 {
|
||||
@@ -808,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()
|
||||
@@ -986,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",
|
||||
@@ -1267,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -146,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
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// returns data points from Win32_PerfRawData_MSMQ_MSMQQueue
|
||||
// <add link to documentation here> - Win32_PerfRawData_MSMQ_MSMQQueue class
|
||||
|
||||
// +build windows
|
||||
|
||||
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
|
||||
|
||||
package collector
|
||||
@@ -64,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 {
|
||||
@@ -383,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"),
|
||||
@@ -1655,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)
|
||||
@@ -1723,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
|
||||
@@ -2087,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
|
||||
@@ -2179,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
|
||||
@@ -2376,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
|
||||
@@ -2588,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
|
||||
@@ -2976,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
|
||||
@@ -3188,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
|
||||
@@ -3264,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
|
||||
@@ -3445,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -152,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
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// returns data points from Win32_PerfRawData_NETFramework_NETCLRExceptions
|
||||
// <add link to documentation here> - Win32_PerfRawData_NETFramework_NETCLRExceptions class
|
||||
|
||||
// +build windows
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
package collector
|
||||
@@ -124,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -146,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
|
||||
@@ -195,7 +194,7 @@ func (c *ProcessCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Des
|
||||
var dst_wp []WorkerProcess
|
||||
q_wp := queryAll(&dst_wp)
|
||||
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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -75,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -80,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
|
||||
|
||||
@@ -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
|
||||
|
||||
package collector
|
||||
@@ -102,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
|
||||
|
||||
@@ -238,13 +238,16 @@ fileLoop:
|
||||
}
|
||||
var parser expfmt.TextParser
|
||||
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())
|
||||
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
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// returns data points from Win32_PerfRawData_vmGuestLib_VMem and Win32_PerfRawData_vmGuestLib_VCPU
|
||||
|
||||
// +build windows
|
||||
|
||||
package collector
|
||||
@@ -40,6 +38,7 @@ type VmwareCollector struct {
|
||||
HostProcessorSpeedMHz *prometheus.Desc
|
||||
}
|
||||
|
||||
// NewVmwareCollector constructs a new VmwareCollector
|
||||
func NewVmwareCollector() (Collector, error) {
|
||||
const subsystem = "vmware"
|
||||
return &VmwareCollector{
|
||||
|
||||
13
exporter.go
13
exporter.go
@@ -4,7 +4,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -222,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)
|
||||
@@ -259,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 {
|
||||
|
||||
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
|
||||
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 }}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user