mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
tcp: relax metrics collectos on error (#2041)
This commit is contained in:
@@ -41,7 +41,7 @@ func GetTCPConnectionStates(family uint32) (map[MIB_TCP_STATE]uint32, error) {
|
||||
case windows.AF_INET:
|
||||
table, err := getExtendedTcpTable[MIB_TCPROW_OWNER_PID](family, TCPTableOwnerPIDAll)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed getExtendedTcpTable: %w", err)
|
||||
}
|
||||
|
||||
for _, row := range table {
|
||||
@@ -52,7 +52,7 @@ func GetTCPConnectionStates(family uint32) (map[MIB_TCP_STATE]uint32, error) {
|
||||
case windows.AF_INET6:
|
||||
table, err := getExtendedTcpTable[MIB_TCP6ROW_OWNER_PID](family, TCPTableOwnerPIDAll)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed getExtendedTcpTable: %w", err)
|
||||
}
|
||||
|
||||
for _, row := range table {
|
||||
@@ -102,12 +102,12 @@ func getExtendedTcpTable[T any](ulAf uint32, tableClass uint32) ([]T, error) {
|
||||
var size uint32
|
||||
|
||||
ret, _, _ := procGetExtendedTcpTable.Call(
|
||||
uintptr(0),
|
||||
0,
|
||||
uintptr(unsafe.Pointer(&size)),
|
||||
uintptr(0),
|
||||
0,
|
||||
uintptr(ulAf),
|
||||
uintptr(tableClass),
|
||||
uintptr(0),
|
||||
0,
|
||||
)
|
||||
|
||||
if ret != uintptr(windows.ERROR_INSUFFICIENT_BUFFER) {
|
||||
@@ -119,10 +119,10 @@ func getExtendedTcpTable[T any](ulAf uint32, tableClass uint32) ([]T, error) {
|
||||
ret, _, _ = procGetExtendedTcpTable.Call(
|
||||
uintptr(unsafe.Pointer(&buf[0])),
|
||||
uintptr(unsafe.Pointer(&size)),
|
||||
uintptr(0),
|
||||
0,
|
||||
uintptr(ulAf),
|
||||
uintptr(tableClass),
|
||||
uintptr(0),
|
||||
0,
|
||||
)
|
||||
|
||||
if ret != 0 {
|
||||
|
||||
Reference in New Issue
Block a user