{"record":{"id":"65013d71dd7c47cb","repo":"prometheus/node_exporter","slug":"getifaddrs-failed-65013d","errorCode":null,"errorMessage":"getifaddrs() failed","messagePattern":"getifaddrs\\(\\) failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/netdev_openbsd.go","lineNumber":36,"sourceCode":"import (\n\t\"errors\"\n\t\"log/slog\"\n)\n\n/*\n#include <sys/types.h>\n#include <sys/socket.h>\n#include <ifaddrs.h>\n#include <net/if.h>\n*/\nimport \"C\"\n\nfunc getNetDevStats(filter *deviceFilter, logger *slog.Logger) (netDevStats, error) {\n\tnetDev := netDevStats{}\n\n\tvar ifap, ifa *C.struct_ifaddrs\n\tif C.getifaddrs(&ifap) == -1 {\n\t\treturn nil, errors.New(\"getifaddrs() failed\")\n\t}\n\tdefer C.freeifaddrs(ifap)\n\n\tfor ifa = ifap; ifa != nil; ifa = ifa.ifa_next {\n\t\tif ifa.ifa_addr.sa_family != C.AF_LINK {\n\t\t\tcontinue\n\t\t}\n\n\t\tdev := C.GoString(ifa.ifa_name)\n\t\tif filter.ignored(dev) {\n\t\t\tlogger.Debug(\"Ignoring device\", \"device\", dev)\n\t\t\tcontinue\n\t\t}\n\n\t\tdata := (*C.struct_if_data)(ifa.ifa_data)\n\n\t\t// https://github.com/openbsd/src/blob/master/sys/net/if.h#L101-L126\n\t\tnetDev[dev] = map[string]uint64{","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/netdev_openbsd.go#L18-L54","documentation":"On OpenBSD, getNetDevStats calls the C getifaddrs() via cgo; if it returns -1 the collector cannot enumerate network interfaces and returns this error. It wraps the underlying errno case in a plain error without the errno detail.","triggerScenarios":"getNetDevStats on OpenBSD when C.getifaddrs(&ifap) == -1 — typically memory exhaustion (ENOMEM) or a kernel/network stack issue at the moment of the call.","commonSituations":"Low-memory OpenBSD hosts or restricted environments (e.g., seccomp/pledge-like restrictions or chroot lacking access to kernel interface tables) where getifaddrs cannot allocate the interface list.","solutions":["Retry collection; getifaddrs failures are often transient (ENOMEM under load).","Check host memory availability and raise limits if ENOMEM is the cause.","Ensure the exporter runs with sufficient privileges/sandbox allowances to query the kernel interface list.","Upgrade node_exporter in case a newer release reports errno for better diagnosis."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"stats, err := getNetDevStats(filter, logger)\nif err != nil {\n    logger.Warn(\"interface enumeration failed, retrying\", \"err\", err)\n    time.Sleep(time.Second)\n    stats, err = getNetDevStats(filter, logger)\n}","preventionTips":["Monitor host memory; ENOMEM is the usual getifaddrs cause.","Avoid over-restrictive sandboxes around the exporter.","Retry scrape failures before alerting."],"tags":["go","openbsd","cgo","network"],"backgroundTag":"network-request-failed","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}