{"record":{"id":"4248e9a26c2079dd","repo":"prometheus/node_exporter","slug":"devstat-getdevs-failed","errorCode":null,"errorMessage":"devstat_getdevs failed","messagePattern":"devstat_getdevs failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/devstat_freebsd.go","lineNumber":92,"sourceCode":"\t\t\t[]string{\"device\"}, nil,\n\t\t), prometheus.CounterValue},\n\t\tblocks: typedDesc{prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, devstatSubsystem, \"blocks_transferred_total\"),\n\t\t\t\"The total number of blocks transferred.\",\n\t\t\t[]string{\"device\"}, nil,\n\t\t), prometheus.CounterValue},\n\t\tlogger: logger,\n\t}, nil\n}\n\nfunc (c *devstatCollector) Update(ch chan<- prometheus.Metric) error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tvar stats *C.Stats\n\tn := C._get_stats(c.devinfo, &stats)\n\tif n == -1 {\n\t\treturn errors.New(\"devstat_getdevs failed\")\n\t}\n\n\tbase := unsafe.Pointer(stats)\n\tfor i := C.int(0); i < n; i++ {\n\t\toffset := i * C.int(C.sizeof_Stats)\n\t\tstat := (*C.Stats)(unsafe.Pointer(uintptr(base) + uintptr(offset)))\n\n\t\tdevice := fmt.Sprintf(\"%s%d\", C.GoString(&stat.device[0]), stat.unit)\n\t\tch <- c.bytes.mustNewConstMetric(float64(stat.bytes.read), device, \"read\")\n\t\tch <- c.bytes.mustNewConstMetric(float64(stat.bytes.write), device, \"write\")\n\t\tch <- c.transfers.mustNewConstMetric(float64(stat.transfers.other), device, \"other\")\n\t\tch <- c.transfers.mustNewConstMetric(float64(stat.transfers.read), device, \"read\")\n\t\tch <- c.transfers.mustNewConstMetric(float64(stat.transfers.write), device, \"write\")\n\t\tch <- c.duration.mustNewConstMetric(float64(stat.duration.other), device, \"other\")\n\t\tch <- c.duration.mustNewConstMetric(float64(stat.duration.read), device, \"read\")\n\t\tch <- c.duration.mustNewConstMetric(float64(stat.duration.write), device, \"write\")\n\t\tch <- c.busyTime.mustNewConstMetric(float64(stat.busyTime), device)\n\t\tch <- c.blocks.mustNewConstMetric(float64(stat.blocks), device)","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/devstat_freebsd.go#L74-L110","documentation":"In the FreeBSD devstat collector (devstat_freebsd.go), Update calls the cgo helper C._get_stats(c.devinfo, &stats), which wraps devstat_getdevs. A return of -1 means the kernel device-statistics query failed, so the collector cannot read any disk metrics and returns this error for the scrape.","triggerScenarios":"C._get_stats(c.devinfo, &stats) == -1 in devstatCollector.Update — devstat_getdevs failed, most commonly because /dev/devstat cannot be opened by the exporter process, or devinfo is stale after a device-list change.","commonSituations":"node_exporter lacking read permission on /dev/devstat; running inside a FreeBSD jail without devstat access; devstat state invalidated after hot-plug device changes.","solutions":["Grant the exporter's user permission to read /dev/devstat (devfs.rules or group membership)","Restart node_exporter to refresh its cached devinfo after device changes/hot-plug","Confirm devstat is available on the host (kern.devstat sysctl exists) and the process is not jailed without device access","Disable the diskstats collector on hosts where devstat is not usable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := c.Update(ch); err != nil {\n    if strings.Contains(err.Error(), \"devstat_getdevs failed\") {\n        c.logger.Warn(\"devstat query failed; refreshing state may help\", \"err\", err)\n    }\n    return err\n}","preventionTips":["Ensure /dev/devstat is readable by the exporter user (devfs.rules, group membership)","Restart the exporter after hot-plug device changes so cached devinfo stays valid","Confirm the host is not jailed without devstat visibility","Verify kern.devstat sysctl exists during provisioning"],"tags":["cgo","devstat","disk","freebsd","bsd"],"backgroundTag":"system-call-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"}