Merge pull request #138 from tekert/fix_data_written_ssd

Fix reported Data bytes Read/Written on SSDs
This commit is contained in:
David Randall 2023-08-10 11:58:18 -04:00 committed by GitHub
commit e5bf7aa1b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -301,21 +301,25 @@ func (smart *SMARTctl) mineNumErrLogEntries() {
} }
func (smart *SMARTctl) mineBytesRead() { func (smart *SMARTctl) mineBytesRead() {
blockSize := smart.json.Get("logical_block_size").Float() * 1024 blockSize := smart.json.Get("logical_block_size").Float()
smart.ch <- prometheus.MustNewConstMetric( smart.ch <- prometheus.MustNewConstMetric(
metricDeviceBytesRead, metricDeviceBytesRead,
prometheus.CounterValue, prometheus.CounterValue,
smart.json.Get("nvme_smart_health_information_log.data_units_read").Float()*blockSize, // This value is reported in thousands (i.e., a value of 1 corresponds to 1000 units of 512 bytes written) and is rounded up.
// When the LBA size is a value other than 512 bytes, the controller shall convert the amount of data written to 512 byte units.
smart.json.Get("nvme_smart_health_information_log.data_units_read").Float()*1000.0*blockSize,
smart.device.device, smart.device.device,
) )
} }
func (smart *SMARTctl) mineBytesWritten() { func (smart *SMARTctl) mineBytesWritten() {
blockSize := smart.json.Get("logical_block_size").Float() * 1024 blockSize := smart.json.Get("logical_block_size").Float()
smart.ch <- prometheus.MustNewConstMetric( smart.ch <- prometheus.MustNewConstMetric(
metricDeviceBytesWritten, metricDeviceBytesWritten,
prometheus.CounterValue, prometheus.CounterValue,
smart.json.Get("nvme_smart_health_information_log.data_units_written").Float()*blockSize, // This value is reported in thousands (i.e., a value of 1 corresponds to 1000 units of 512 bytes written) and is rounded up.
// When the LBA size is a value other than 512 bytes, the controller shall convert the amount of data written to 512 byte units.
smart.json.Get("nvme_smart_health_information_log.data_units_written").Float()*1000.0*blockSize,
smart.device.device, smart.device.device,
) )
} }