Skip to content

Commit e2db34a

Browse files
authored
Merge pull request #2 from galexrt/feature/add_pdisk_collector
Feature/add pdisk collector
2 parents 2fbf0e8 + 1823932 commit e2db34a

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ps | Overall status of power supplies.
3030
storage_battery | Status of storage controller backup batteries.
3131
storage_controller | Overall status of storage controllers.
3232
storage_enclosure | Overall status of storage enclosures.
33+
storage_pdisk | Overall status of physical disks.
3334
storage_vdisk | Overall status of virtual disks.
3435
system | Overall status of system components.
3536
temps | Overall temperatures and status of system temperature readings.

cmd/dellhw_exporter/dellhw_exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
const (
25-
defaultCollectors = "chassis,fans,memory,processors,ps,ps_amps_sysboard_pwr,storage_battery,storage_enclosure,storage_controller,storage_vdisk,system,temps,volts"
25+
defaultCollectors = "chassis,fans,memory,processors,ps,ps_amps_sysboard_pwr,storage_battery,storage_enclosure,storage_controller,storage_pdisk,storage_vdisk,system,temps,volts"
2626
)
2727

2828
var (

collector/storage_pdisk.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package collector
2+
3+
import (
4+
"strconv"
5+
6+
"github.com/prometheus/client_golang/prometheus"
7+
)
8+
9+
type storagePdiskCollector struct {
10+
current []*prometheus.Desc
11+
}
12+
13+
func init() {
14+
Factories["storage_pdisk"] = NewStoragePdiskCollector
15+
}
16+
17+
func NewStoragePdiskCollector() (Collector, error) {
18+
return &storagePdiskCollector{}, nil
19+
}
20+
21+
func (c *storagePdiskCollector) Update(ch chan<- prometheus.Metric) error {
22+
controllers, err := or.StorageController()
23+
if err != nil {
24+
return err
25+
}
26+
for cid := range controllers {
27+
storagePdisk, err := or.StoragePdisk(strconv.Itoa(cid))
28+
if err != nil {
29+
return err
30+
}
31+
for _, value := range storagePdisk {
32+
float, err := strconv.ParseFloat(value.Value, 64)
33+
if err != nil {
34+
return err
35+
}
36+
current := prometheus.NewDesc(
37+
prometheus.BuildFQName(Namespace, "", value.Name),
38+
"Overall status of physical disks.",
39+
nil, value.Labels)
40+
ch <- prometheus.MustNewConstMetric(
41+
current, prometheus.GaugeValue, float)
42+
}
43+
}
44+
45+
return nil
46+
}

0 commit comments

Comments
 (0)