megacli: prevent crash when drive temperature is N/A
Intel SSD do not report their temperature in MegaCLI output Drive Temperature : N/A
This commit is contained in:
parent
aca4688dc3
commit
0028abc077
4 changed files with 41 additions and 9 deletions
|
|
@ -196,17 +196,18 @@ func (c *megaCliCollector) updateDisks() error {
|
|||
|
||||
for enc, encStats := range stats {
|
||||
for slot, slotStats := range encStats {
|
||||
tStr := slotStats["Drive Temperature"]
|
||||
tStr = tStr[:strings.Index(tStr, "C")]
|
||||
t, err := strconv.ParseFloat(tStr, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
encStr := strconv.Itoa(enc)
|
||||
slotStr := strconv.Itoa(slot)
|
||||
|
||||
c.driveTemperature.WithLabelValues(encStr, slotStr).Set(t)
|
||||
tStr := slotStats["Drive Temperature"]
|
||||
if strings.Index(tStr, "C") > 0 {
|
||||
tStr = tStr[:strings.Index(tStr, "C")]
|
||||
t, err := strconv.ParseFloat(tStr, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.driveTemperature.WithLabelValues(encStr, slotStr).Set(t)
|
||||
}
|
||||
|
||||
for _, i := range counters {
|
||||
counter, err := strconv.ParseFloat(slotStats[i], 64)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue