Skip to content

Commit

Permalink
feat: Better SCSI/SAS support, and removing confused metrics
Browse files Browse the repository at this point in the history
Implement better SCSI/SAS support, including less confused metrics.

The exporter, prior to this PR, exports a value of "0" for some metrics
that were specific to certain types of drives; these metrics will no
longer be exported for types where that metric is not valid. Future work
may include parsing the corresponding metrics for SATA/SAS SSDs.

Metrics no longer exported for the wrong type of drive:
- smartctl_device_nvme_capacity_bytes (NVME-specific)
- smartctl_device_available_spare (NVME-specific, ATA possible)
- smartctl_device_available_spare_threshold (NVME-specific, ATA
  possible)
- smartctl_device_critical_warning (NVME-specific, ATA possible)
- smartctl_device_interface_speed (ATA-specific)
- smartctl_device_media_errors (NVME-specific, ATA possible)
- smartctl_device_num_err_log_entries (NVME-specific, SCSI uses distinct
  metrics, ATA possible)
- smartctl_device_nvme_capacity_bytes (NVME-specific)
- smartctl_device_percentage_used (NVME-specific, ATA possible)

Fix the following metrics that were exported as zero because the
exporter did not know how to read them for SCSI devices:
- smartctl_device_bytes_read
- smartctl_device_bytes_written
- smartctl_device_power_cycle_count

New metrics:
- smartctl_read_errors_corrected_by_eccdelayed
- smartctl_read_errors_corrected_by_eccfast
- smartctl_write_errors_corrected_by_eccdelayed
- smartctl_write_errors_corrected_by_eccfast

Fix labels:
- smartctl_device{model_name} is now populated for SCSI/SAS, based on
  scsi_model_name.

New labels:
- smartctl_device{} gains:
  scsi_product,scsi_revision,scsi_vendor,scsi_version

Signed-off-by: Robin H. Johnson <[email protected]>
  • Loading branch information
robbat2 committed Oct 16, 2023
1 parent 558a760 commit e32ad2a
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 49 deletions.
37 changes: 37 additions & 0 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ var (
"ata_version",
"sata_version",
"form_factor",
// scsi_model_name is mapped into model_name
"scsi_vendor",
"scsi_product",
"scsi_revision",
"scsi_version",
},
nil,
)
Expand Down Expand Up @@ -293,6 +298,22 @@ var (
},
nil,
)
metricReadErrorsCorrectedByEccFast = prometheus.NewDesc(
"smartctl_read_errors_corrected_by_eccfast",
"Read Errors Corrected by ECC Fast",
[]string{
"device",
},
nil,
)
metricReadErrorsCorrectedByEccDelayed = prometheus.NewDesc(
"smartctl_read_errors_corrected_by_eccdelayed",
"Read Errors Corrected by ECC Delayed",
[]string{
"device",
},
nil,
)
metricReadTotalUncorrectedErrors = prometheus.NewDesc(
"smartctl_read_total_uncorrected_errors",
"Read Total Uncorrected Errors",
Expand All @@ -309,6 +330,22 @@ var (
},
nil,
)
metricWriteErrorsCorrectedByEccFast = prometheus.NewDesc(
"smartctl_write_errors_corrected_by_eccfast",
"Write Errors Corrected by ECC Fast",
[]string{
"device",
},
nil,
)
metricWriteErrorsCorrectedByEccDelayed = prometheus.NewDesc(
"smartctl_write_errors_corrected_by_eccdelayed",
"Write Errors Corrected by ECC Delayed",
[]string{
"device",
},
nil,
)
metricWriteTotalUncorrectedErrors = prometheus.NewDesc(
"smartctl_write_total_uncorrected_errors",
"Write Total Uncorrected Errors",
Expand Down
Loading

0 comments on commit e32ad2a

Please sign in to comment.