mirror of
https://github.com/prometheus-community/smartctl_exporter.git
synced 2024-11-16 01:33:07 +01:00
Add counter for the number of devices configured or dynamically discovered
Signed-off-by: Niklas Schwarz <schwarz.niklas@hotmail.de>
This commit is contained in:
parent
895bf1eeb3
commit
d26c3a82ea
2 changed files with 12 additions and 5 deletions
11
main.go
11
main.go
|
@ -56,6 +56,11 @@ func (i SMARTctlManagerCollector) Collect(ch chan<- prometheus.Metric) {
|
||||||
smart.Collect()
|
smart.Collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
metricDeviceCount,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(len(i.Devices)),
|
||||||
|
)
|
||||||
info.Collect()
|
info.Collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,11 +128,7 @@ func main() {
|
||||||
} else {
|
} else {
|
||||||
level.Info(logger).Log("msg", "No devices specified, trying to load them automatically")
|
level.Info(logger).Log("msg", "No devices specified, trying to load them automatically")
|
||||||
devices = scanDevices(logger)
|
devices = scanDevices(logger)
|
||||||
}
|
level.Info(logger).Log("msg", "Number of devices found", "count", len(devices))
|
||||||
|
|
||||||
if len(devices) == 0 {
|
|
||||||
level.Error(logger).Log("msg", "No devices found")
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
collector := SMARTctlManagerCollector{
|
collector := SMARTctlManagerCollector{
|
||||||
|
|
|
@ -47,6 +47,12 @@ var (
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
metricDeviceCount = prometheus.NewDesc(
|
||||||
|
"smartctl_device_count",
|
||||||
|
"Number of devices configured or dynamically discovered",
|
||||||
|
[]string{},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
metricDeviceCapacityBlocks = prometheus.NewDesc(
|
metricDeviceCapacityBlocks = prometheus.NewDesc(
|
||||||
"smartctl_device_capacity_blocks",
|
"smartctl_device_capacity_blocks",
|
||||||
"Device capacity in blocks",
|
"Device capacity in blocks",
|
||||||
|
|
Loading…
Reference in a new issue