@@ -2,13 +2,14 @@ package measurements
22
33import (
44 "fmt"
5- "github.com/analogj/scrutiny/webapp/backend/pkg"
6- "github.com/analogj/scrutiny/webapp/backend/pkg/models/collector"
7- "github.com/analogj/scrutiny/webapp/backend/pkg/thresholds"
85 "log"
96 "strconv"
107 "strings"
118 "time"
9+
10+ "github.com/analogj/scrutiny/webapp/backend/pkg"
11+ "github.com/analogj/scrutiny/webapp/backend/pkg/models/collector"
12+ "github.com/analogj/scrutiny/webapp/backend/pkg/thresholds"
1213)
1314
1415type Smart struct {
@@ -100,7 +101,7 @@ func NewSmartFromInfluxDB(attrs map[string]interface{}) (*Smart, error) {
100101 return & sm , nil
101102}
102103
103- //Parse Collector SMART data results and create Smart object (and associated SmartAtaAttribute entries)
104+ // Parse Collector SMART data results and create Smart object (and associated SmartAtaAttribute entries)
104105func (sm * Smart ) FromCollectorSmartInfo (wwn string , info collector.SmartInfo ) error {
105106 sm .DeviceWWN = wwn
106107 sm .Date = time .Unix (info .LocalTime .TimeT , 0 )
@@ -121,13 +122,13 @@ func (sm *Smart) FromCollectorSmartInfo(wwn string, info collector.SmartInfo) er
121122 } else if sm .DeviceProtocol == pkg .DeviceProtocolNvme {
122123 sm .ProcessNvmeSmartInfo (info .NvmeSmartHealthInformationLog )
123124 } else if sm .DeviceProtocol == pkg .DeviceProtocolScsi {
124- sm .ProcessScsiSmartInfo (info .ScsiGrownDefectList , info .ScsiErrorCounterLog )
125+ sm .ProcessScsiSmartInfo (info .ScsiGrownDefectList , info .ScsiErrorCounterLog , info . ScsiEnvironmentalReports )
125126 }
126127
127128 return nil
128129}
129130
130- //generate SmartAtaAttribute entries from Scrutiny Collector Smart data.
131+ // generate SmartAtaAttribute entries from Scrutiny Collector Smart data.
131132func (sm * Smart ) ProcessAtaSmartInfo (tableItems []collector.AtaSmartAttributesTableItem ) {
132133 for _ , collectorAttr := range tableItems {
133134 attrModel := SmartAtaAttribute {
@@ -155,7 +156,7 @@ func (sm *Smart) ProcessAtaSmartInfo(tableItems []collector.AtaSmartAttributesTa
155156 }
156157}
157158
158- //generate SmartNvmeAttribute entries from Scrutiny Collector Smart data.
159+ // generate SmartNvmeAttribute entries from Scrutiny Collector Smart data.
159160func (sm * Smart ) ProcessNvmeSmartInfo (nvmeSmartHealthInformationLog collector.NvmeSmartHealthInformationLog ) {
160161
161162 sm .Attributes = map [string ]SmartAttribute {
@@ -185,9 +186,11 @@ func (sm *Smart) ProcessNvmeSmartInfo(nvmeSmartHealthInformationLog collector.Nv
185186 }
186187}
187188
188- //generate SmartScsiAttribute entries from Scrutiny Collector Smart data.
189- func (sm * Smart ) ProcessScsiSmartInfo (defectGrownList int64 , scsiErrorCounterLog collector.ScsiErrorCounterLog ) {
189+ // generate SmartScsiAttribute entries from Scrutiny Collector Smart data.
190+ func (sm * Smart ) ProcessScsiSmartInfo (defectGrownList int64 , scsiErrorCounterLog collector.ScsiErrorCounterLog , temperature map [ string ]collector. ScsiTemperatureData ) {
190191 sm .Attributes = map [string ]SmartAttribute {
192+ "temperature" : (& SmartNvmeAttribute {AttributeId : "temperature" , Value : getScsiTemperature (temperature ), Threshold : - 1 }).PopulateAttributeStatus (),
193+
191194 "scsi_grown_defect_list" : (& SmartScsiAttribute {AttributeId : "scsi_grown_defect_list" , Value : defectGrownList , Threshold : 0 }).PopulateAttributeStatus (),
192195 "read_errors_corrected_by_eccfast" : (& SmartScsiAttribute {AttributeId : "read_errors_corrected_by_eccfast" , Value : scsiErrorCounterLog .Read .ErrorsCorrectedByEccfast , Threshold : - 1 }).PopulateAttributeStatus (),
193196 "read_errors_corrected_by_eccdelayed" : (& SmartScsiAttribute {AttributeId : "read_errors_corrected_by_eccdelayed" , Value : scsiErrorCounterLog .Read .ErrorsCorrectedByEccdelayed , Threshold : - 1 }).PopulateAttributeStatus (),
@@ -210,3 +213,12 @@ func (sm *Smart) ProcessScsiSmartInfo(defectGrownList int64, scsiErrorCounterLog
210213 }
211214 }
212215}
216+
217+ func getScsiTemperature (s map [string ]collector.ScsiTemperatureData ) int64 {
218+ temp , ok := s ["temperature_1" ]
219+ if ! ok {
220+ return 0
221+ }
222+
223+ return temp .Current
224+ }
0 commit comments