added load average calculations and moved the testing from main to their own cli commands
This commit is contained in:
1 parent
8c931aa3d8
commit
b1d4f3565d
7 files changed
+271
-26
No files matched your search
@@ -13,6 +13,10 @@ type WindowsSystemCheckTools struct {
|
||||
* Win32 API
|
||||
*/
|
||||
Kernel32 *windows.LazyDLL
|
||||
/*
|
||||
* Performance Data Helper
|
||||
*/
|
||||
PDH *windows.LazyDLL
|
||||
/*
|
||||
* Windows memory information
|
||||
*/
|
||||
@@ -25,18 +29,53 @@ type WindowsSystemCheckTools struct {
|
||||
* Windows uptime metrics
|
||||
*/
|
||||
Uptime *windows.LazyProc
|
||||
/*
|
||||
* Opening PDH queries
|
||||
*/
|
||||
ProcPdhOpenQuery *windows.LazyProc
|
||||
/*
|
||||
* Adding counters to open queries
|
||||
*/
|
||||
ProcPdhAddCounter *windows.LazyProc
|
||||
/*
|
||||
* Collecting query data
|
||||
*/
|
||||
ProcPdhCollectQueryData *windows.LazyProc
|
||||
/*
|
||||
* Extracting formatted query value from data
|
||||
*/
|
||||
ProcPdhGetFormattedCounterValue *windows.LazyProc
|
||||
/*
|
||||
* Closing PDH queries
|
||||
*/
|
||||
ProcPdhCloseQuery *windows.LazyProc
|
||||
}
|
||||
|
||||
func GetWindowsTools() WindowsSystemCheckTools {
|
||||
kernel32 := sync.OnceValue(func() *windows.LazyDLL { return windows.NewLazySystemDLL("kernel32.dll") })
|
||||
pdh := sync.OnceValue(func() *windows.LazyDLL { return windows.NewLazySystemDLL("pdh.dll") })
|
||||
|
||||
procGlobalMemoryStatusEx := sync.OnceValue(func() *windows.LazyProc { return kernel32().NewProc("GlobalMemoryStatusEx") })
|
||||
systemTimes := sync.OnceValue(func() *windows.LazyProc { return kernel32().NewProc("GetSystemTimes") })
|
||||
uptime := sync.OnceValue(func() *windows.LazyProc { return kernel32().NewProc("GetTickCount64") })
|
||||
|
||||
// PDH functions
|
||||
procPdhOpenQuery := sync.OnceValue(func() *windows.LazyProc { return pdh().NewProc("PdhOpenQueryW") })
|
||||
procPdhAddCounter := sync.OnceValue(func() *windows.LazyProc { return pdh().NewProc("PdhAddEnglishCounterW") })
|
||||
procPdhCollectQueryData := sync.OnceValue(func() *windows.LazyProc { return pdh().NewProc("PdhCollectQueryData") })
|
||||
procPdhGetFormattedCounterValue := sync.OnceValue(func() *windows.LazyProc { return pdh().NewProc("PdhGetFormattedCounterValue") })
|
||||
procPdhCloseQuery := sync.OnceValue(func() *windows.LazyProc { return pdh().NewProc("PdhCloseQuery") })
|
||||
|
||||
return WindowsSystemCheckTools{
|
||||
Kernel32: kernel32(),
|
||||
ProcGlobalMemoryStatusEx: procGlobalMemoryStatusEx(),
|
||||
SystemTimes: systemTimes(),
|
||||
Uptime: uptime(),
|
||||
Kernel32: kernel32(),
|
||||
PDH: pdh(),
|
||||
ProcGlobalMemoryStatusEx: procGlobalMemoryStatusEx(),
|
||||
SystemTimes: systemTimes(),
|
||||
Uptime: uptime(),
|
||||
ProcPdhOpenQuery: procPdhOpenQuery(),
|
||||
ProcPdhAddCounter: procPdhAddCounter(),
|
||||
ProcPdhCollectQueryData: procPdhCollectQueryData(),
|
||||
ProcPdhGetFormattedCounterValue: procPdhGetFormattedCounterValue(),
|
||||
ProcPdhCloseQuery: procPdhCloseQuery(),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user