container: fix collector (#2057)

This commit is contained in:
Jan-Otto Kröpke
2025-05-24 11:29:52 +02:00
committed by GitHub
parent 6dd21a8e00
commit 5e1a802237
4 changed files with 129 additions and 66 deletions

View File

@@ -31,7 +31,13 @@ const (
)
func OpenJobObject(name string) (windows.Handle, error) {
handle, _, err := procOpenJobObject.Call(JobObjectQuery, 0, uintptr(unsafe.Pointer(&name)))
ptr, _ := windows.UTF16PtrFromString(name)
handle, _, err := procOpenJobObject.Call(
JobObjectQuery,
0,
uintptr(unsafe.Pointer(ptr)),
)
if handle == 0 {
return 0, err
}

View File

@@ -17,7 +17,11 @@
package kernel32
import "unsafe"
import (
"unsafe"
"golang.org/x/sys/windows"
)
type JobObjectBasicAccountingInformation struct {
TotalUserTime uint64
@@ -30,22 +34,18 @@ type JobObjectBasicAccountingInformation struct {
TotalTerminatedProcesses uint32
}
type IOCounters struct {
ReadOperationCount uint64
WriteOperationCount uint64
OtherOperationCount uint64
ReadTransferCount uint64
WriteTransferCount uint64
OtherTransferCount uint64
// JobObjectBasicAndIOAccountingInformation is a structure that contains
// both basic accounting information and I/O accounting information
// for a job object. It is used with the QueryInformationJobObject function.
// The structure is defined in the Windows API documentation.
// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-jobobject_basic_and_io_accounting_information
type JobObjectBasicAndIOAccountingInformation struct {
BasicInfo JobObjectBasicAccountingInformation
IoInfo windows.IO_COUNTERS
}
type JobObjectExtendedLimitInformation struct {
BasicInfo JobObjectBasicAccountingInformation
IoInfo IOCounters
ProcessMemoryLimit uint64
JobMemoryLimit uint64
PeakProcessMemoryUsed uint64
PeakJobMemoryUsed uint64
type JobObjectMemoryUsageInformation struct {
JobMemory uint64
PeakJobMemoryUsed uint64
}
type JobObjectBasicProcessIDList struct {