File add_device_error_label.patch of Package golang-github-prometheus-node_exporter.35077
Index: node_exporter-1.7.0/collector/filesystem_common.go
===================================================================
--- node_exporter-1.7.0.orig/collector/filesystem_common.go
+++ node_exporter-1.7.0/collector/filesystem_common.go
@@ -60,7 +60,7 @@ var (
"Regexp of filesystem types to ignore for filesystem collector.",
).Hidden().String()
- filesystemLabelNames = []string{"device", "mountpoint", "fstype"}
+ filesystemLabelNames = []string{"device", "mountpoint", "fstype", "device_error"}
)
type filesystemCollector struct {
@@ -73,7 +73,7 @@ type filesystemCollector struct {
}
type filesystemLabels struct {
- device, mountPoint, fsType, options string
+ device, mountPoint, fsType, options, deviceError string
}
type filesystemStats struct {
@@ -184,11 +184,11 @@ func (c *filesystemCollector) Update(ch
ch <- prometheus.MustNewConstMetric(
c.deviceErrorDesc, prometheus.GaugeValue,
- s.deviceError, s.labels.device, s.labels.mountPoint, s.labels.fsType,
+ s.deviceError, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
)
ch <- prometheus.MustNewConstMetric(
c.roDesc, prometheus.GaugeValue,
- s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType,
+ s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
)
if s.deviceError > 0 {
@@ -197,23 +197,23 @@ func (c *filesystemCollector) Update(ch
ch <- prometheus.MustNewConstMetric(
c.sizeDesc, prometheus.GaugeValue,
- s.size, s.labels.device, s.labels.mountPoint, s.labels.fsType,
+ s.size, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
)
ch <- prometheus.MustNewConstMetric(
c.freeDesc, prometheus.GaugeValue,
- s.free, s.labels.device, s.labels.mountPoint, s.labels.fsType,
+ s.free, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
)
ch <- prometheus.MustNewConstMetric(
c.availDesc, prometheus.GaugeValue,
- s.avail, s.labels.device, s.labels.mountPoint, s.labels.fsType,
+ s.avail, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
)
ch <- prometheus.MustNewConstMetric(
c.filesDesc, prometheus.GaugeValue,
- s.files, s.labels.device, s.labels.mountPoint, s.labels.fsType,
+ s.files, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
)
ch <- prometheus.MustNewConstMetric(
c.filesFreeDesc, prometheus.GaugeValue,
- s.filesFree, s.labels.device, s.labels.mountPoint, s.labels.fsType,
+ s.filesFree, s.labels.device, s.labels.mountPoint, s.labels.fsType, s.labels.deviceError,
)
}
return nil
Index: node_exporter-1.7.0/collector/filesystem_linux.go
===================================================================
--- node_exporter-1.7.0.orig/collector/filesystem_linux.go
+++ node_exporter-1.7.0/collector/filesystem_linux.go
@@ -85,6 +85,7 @@ func (c *filesystemCollector) GetStats()
stuckMountsMtx.Lock()
if _, ok := stuckMounts[labels.mountPoint]; ok {
+ labels.deviceError = "mountpoint timeout"
stats = append(stats, filesystemStats{
labels: labels,
deviceError: 1,
@@ -133,6 +134,7 @@ func (c *filesystemCollector) processSta
stuckMountsMtx.Unlock()
if err != nil {
+ labels.deviceError = err.Error()
level.Debug(c.logger).Log("msg", "Error on statfs() system call", "rootfs", rootfsFilePath(labels.mountPoint), "err", err)
return filesystemStats{
labels: labels,
@@ -207,10 +209,11 @@ func parseFilesystemLabels(r io.Reader)
parts[1] = strings.Replace(parts[1], "\\011", "\t", -1)
filesystems = append(filesystems, filesystemLabels{
- device: parts[0],
- mountPoint: rootfsStripPrefix(parts[1]),
- fsType: parts[2],
- options: parts[3],
+ device: parts[0],
+ mountPoint: rootfsStripPrefix(parts[1]),
+ fsType: parts[2],
+ options: parts[3],
+ deviceError: "",
})
}