Skip to content

Commit f954cc8

Browse files
committed
feat: support SAS temperature (upstream PR AnalogJ#816)
2 parents e0f2781 + c6c8142 commit f954cc8

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

webapp/backend/pkg/models/collector/smart.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ type SmartInfo struct {
235235
ScsiVersion string `json:"scsi_version"`
236236
ScsiGrownDefectList int64 `json:"scsi_grown_defect_list"`
237237
ScsiErrorCounterLog ScsiErrorCounterLog `json:"scsi_error_counter_log"`
238+
239+
ScsiEnvironmentalReports map[string]ScsiTemperatureData `json:"scsi_environmental_reports"`
240+
}
241+
242+
type ScsiTemperatureData struct {
243+
ParameterCode int `json:"parameter_code"`
244+
Current int64 `json:"current"`
245+
LifetimeMaximum int64 `json:"lifetime_maximum"`
246+
LifetimeMinimum int64 `json:"lifetime_minimum"`
247+
MaximumSincePowerOn int64 `json:"maximum_since_power_on"`
248+
MinimumSincePowerOn int64 `json:"minimum_since_power_on"`
238249
}
239250

240251
// Capacity finds the total capacity of the device in bytes, or 0 if unknown.

webapp/backend/pkg/models/measurements/smart.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (sm *Smart) FromCollectorSmartInfo(cfg config.Interface, wwn string, info c
123123
} else if sm.DeviceProtocol == pkg.DeviceProtocolNvme {
124124
sm.ProcessNvmeSmartInfo(info.NvmeSmartHealthInformationLog)
125125
} else if sm.DeviceProtocol == pkg.DeviceProtocolScsi {
126-
sm.ProcessScsiSmartInfo(info.ScsiGrownDefectList, info.ScsiErrorCounterLog)
126+
sm.ProcessScsiSmartInfo(info.ScsiGrownDefectList, info.ScsiErrorCounterLog, info.ScsiEnvironmentalReports)
127127
}
128128

129129
return nil
@@ -200,8 +200,10 @@ func (sm *Smart) ProcessNvmeSmartInfo(nvmeSmartHealthInformationLog collector.Nv
200200
}
201201

202202
// generate SmartScsiAttribute entries from Scrutiny Collector Smart data.
203-
func (sm *Smart) ProcessScsiSmartInfo(defectGrownList int64, scsiErrorCounterLog collector.ScsiErrorCounterLog) {
203+
func (sm *Smart) ProcessScsiSmartInfo(defectGrownList int64, scsiErrorCounterLog collector.ScsiErrorCounterLog, temperature map[string]collector.ScsiTemperatureData) {
204204
sm.Attributes = map[string]SmartAttribute{
205+
"temperature": (&SmartNvmeAttribute{AttributeId: "temperature", Value: getScsiTemperature(temperature), Threshold: -1}).PopulateAttributeStatus(),
206+
205207
"scsi_grown_defect_list": (&SmartScsiAttribute{AttributeId: "scsi_grown_defect_list", Value: defectGrownList, Threshold: 0}).PopulateAttributeStatus(),
206208
"read_errors_corrected_by_eccfast": (&SmartScsiAttribute{AttributeId: "read_errors_corrected_by_eccfast", Value: scsiErrorCounterLog.Read.ErrorsCorrectedByEccfast, Threshold: -1}).PopulateAttributeStatus(),
207209
"read_errors_corrected_by_eccdelayed": (&SmartScsiAttribute{AttributeId: "read_errors_corrected_by_eccdelayed", Value: scsiErrorCounterLog.Read.ErrorsCorrectedByEccdelayed, Threshold: -1}).PopulateAttributeStatus(),
@@ -224,3 +226,12 @@ func (sm *Smart) ProcessScsiSmartInfo(defectGrownList int64, scsiErrorCounterLog
224226
}
225227
}
226228
}
229+
230+
func getScsiTemperature(s map[string]collector.ScsiTemperatureData) int64 {
231+
temp, ok := s["temperature_1"]
232+
if !ok {
233+
return 0
234+
}
235+
236+
return temp.Current
237+
}

0 commit comments

Comments
 (0)