From 586152a4adc229220f00e66af5e49b1e7ce92190 Mon Sep 17 00:00:00 2001 From: sixfears7 <57415489+6fears7@users.noreply.github.com> Date: Fri, 18 Nov 2022 14:57:21 -0500 Subject: [PATCH] Updated code to add label to size and partition Signed-off-by: sixfears7 <57415489+6fears7@users.noreply.github.com> Signed-off-by: pgibbs1 --- collector/diskdrive.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/collector/diskdrive.go b/collector/diskdrive.go index 10f1f9dc..3498fa38 100644 --- a/collector/diskdrive.go +++ b/collector/diskdrive.go @@ -56,14 +56,14 @@ func newDiskDriveInfoCollector() (Collector, error) { Size: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "size"), "Size of the disk drive. It is calculated by multiplying the total number of cylinders, tracks in each cylinder, sectors in each track, and bytes in each sector.", - nil, + []string{"name"}, nil, ), Partitions: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "partitions"), "Number of partitions", - nil, + []string{"name"}, nil, ), @@ -178,13 +178,15 @@ func (c *DiskDriveInfoCollector) collect(ch chan<- prometheus.Metric) (*promethe ch <- prometheus.MustNewConstMetric( c.Size, prometheus.CounterValue, - float64(dst[0].Size), + float64(processor.Size), + strings.Trim(processor.Name, "\\.\\"), ) ch <- prometheus.MustNewConstMetric( c.Partitions, prometheus.CounterValue, - float64(dst[0].Partitions), + float64(processor.Partitions), + strings.Trim(processor.Name, "\\.\\"), ) for availNum, val := range availMap {