Updated code to add label to size and partition

Signed-off-by: sixfears7 <57415489+6fears7@users.noreply.github.com>
Signed-off-by: pgibbs1 <pgibbs1@liberty.edu>
This commit is contained in:
sixfears7
2022-11-18 14:57:21 -05:00
committed by pgibbs1
parent 9a2ef3fca8
commit 586152a4ad

View File

@@ -56,14 +56,14 @@ func newDiskDriveInfoCollector() (Collector, error) {
Size: prometheus.NewDesc( Size: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "size"), 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.", "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, nil,
), ),
Partitions: prometheus.NewDesc( Partitions: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, subsystem, "partitions"), prometheus.BuildFQName(Namespace, subsystem, "partitions"),
"Number of partitions", "Number of partitions",
nil, []string{"name"},
nil, nil,
), ),
@@ -178,13 +178,15 @@ func (c *DiskDriveInfoCollector) collect(ch chan<- prometheus.Metric) (*promethe
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.Size, c.Size,
prometheus.CounterValue, prometheus.CounterValue,
float64(dst[0].Size), float64(processor.Size),
strings.Trim(processor.Name, "\\.\\"),
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.Partitions, c.Partitions,
prometheus.CounterValue, prometheus.CounterValue,
float64(dst[0].Partitions), float64(processor.Partitions),
strings.Trim(processor.Name, "\\.\\"),
) )
for availNum, val := range availMap { for availNum, val := range availMap {