Skip to content

Commit

Permalink
feat: Tolerate collector failures
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 25, 2024
1 parent 532568a commit f3cdb48
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/collector/diskdrive/diskdrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ type diskDrive struct {
Availability uint16 `mi:"Availability"`
}

//nolint:gochecknoglobals
var (
allDiskStatus = []string{
"OK",
Expand Down
1 change: 1 addition & 0 deletions internal/collector/iis/iis_app_pool_was.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const (
TotalWorkerProcessStartupFailures = "Total Worker Process Startup Failures"
)

//nolint:gochecknoglobals
var applicationStates = map[uint32]string{
1: "Uninitialized",
2: "Initialized",
Expand Down
2 changes: 2 additions & 0 deletions internal/collector/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
const Name = "printer"

// printerStatusMap source: https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-printer#:~:text=Power%20Save-,PrinterStatus,Offline%20(7),-PrintJobDataType
//
//nolint:gochecknoglobals
var printerStatusMap = map[uint16]string{
1: "Other",
2: "Unknown",
Expand Down
1 change: 1 addition & 0 deletions internal/collector/textfile/textfile_test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/stretchr/testify/require"
)

//nolint:gochecknoglobals
var baseDir = "../../../tools/textfile-test"

//nolint:paralleltest
Expand Down
1 change: 1 addition & 0 deletions internal/headers/iphlpapi/iphlpapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"golang.org/x/sys/windows"
)

//nolint:gochecknoglobals
var (
modiphlpapi = windows.NewLazySystemDLL("iphlpapi.dll")
procGetExtendedTcpTable = modiphlpapi.NewProc("GetExtendedTcpTable")
Expand Down
1 change: 1 addition & 0 deletions internal/headers/kernel32/kernel32.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"golang.org/x/sys/windows"
)

//nolint:gochecknoglobals
var (
kernel32 = windows.NewLazySystemDLL("kernel32.dll")

Expand Down
3 changes: 3 additions & 0 deletions internal/headers/netapi32/netapi32.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type WorkstationInfo struct {
LoggedOnUsers uint32
}

//nolint:gochecknoglobals
var (
netapi32 = windows.NewLazySystemDLL("netapi32")
procNetWkstaGetInfo = netapi32.NewProc("NetWkstaGetInfo")
Expand All @@ -53,6 +54,8 @@ var (

// NetApiStatus is a map of Network Management Error Codes.
// https://docs.microsoft.com/en-gb/windows/win32/netmgmt/network-management-error-codes?redirectedfrom=MSDN
//
//nolint:gochecknoglobals
var NetApiStatus = map[uint32]string{
// Success
0: "NERR_Success",
Expand Down
1 change: 1 addition & 0 deletions internal/headers/psapi/psapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type PerformanceInformation struct {
ThreadCount uint32
}

//nolint:gochecknoglobals
var (
psapi = windows.NewLazySystemDLL("psapi.dll")
procGetPerformanceInfo = psapi.NewProc("GetPerformanceInfo")
Expand Down
3 changes: 2 additions & 1 deletion internal/headers/secur32/secur32.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
)

// based on https://github.com/carlpett/winlsa/blob/master/winlsa.go

//
//nolint:gochecknoglobals
var (
secur32 = windows.NewLazySystemDLL("Secur32.dll")
advapi32 = windows.NewLazySystemDLL("advapi32.dll")
Expand Down
1 change: 1 addition & 0 deletions internal/headers/slc/slc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"golang.org/x/sys/windows"
)

//nolint:gochecknoglobals
var (
slc = windows.NewLazySystemDLL("slc.dll")
procSLIsWindowsGenuineLocal = slc.NewProc("SLIsWindowsGenuineLocal")
Expand Down
1 change: 1 addition & 0 deletions internal/headers/sysinfoapi/sysinfoapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const (
ComputerNameMax
)

//nolint:gochecknoglobals
var (
kernel32 = windows.NewLazySystemDLL("kernel32.dll")
procGetSystemInfo = kernel32.NewProc("GetSystemInfo")
Expand Down
1 change: 1 addition & 0 deletions internal/headers/wtsapi32/wtsapi32.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type WTSSession struct {
FarmName string
}

//nolint:gochecknoglobals
var (
wtsapi32 = windows.NewLazySystemDLL("wtsapi32.dll")

Expand Down
1 change: 1 addition & 0 deletions internal/mi/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
LocaleEnglish = "en-us"
)

//nolint:gochecknoglobals
var (
// DestinationOptionsTimeout is the key for the timeout option.
//
Expand Down
5 changes: 4 additions & 1 deletion internal/mi/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ import (
"golang.org/x/sys/windows"
)

// We have to registry a global callback function, since the amount of callbacks is limited.
// operationUnmarshalCallbacksInstanceResult registers a global callback function.
// The amount of system callbacks is limited to 2000.
//
//nolint:gochecknoglobals
var operationUnmarshalCallbacksInstanceResult = sync.OnceValue[uintptr](func() uintptr {
// Workaround for a deadlock issue in go.
// Ref: https://github.com/golang/go/issues/55015
Expand Down

0 comments on commit f3cdb48

Please sign in to comment.