Index: send_boot_metrics |
diff --git a/send_boot_metrics b/send_boot_metrics |
index cb209082ce75cb42b1bc5f83181ce55685b92a1e..bb626309b6fcf4eec6b6eddd5d58124271c8439c 100755 |
--- a/send_boot_metrics |
+++ b/send_boot_metrics |
@@ -35,3 +35,16 @@ report_disk_metrics $( |
bootstat_get_last boot-complete read-sectors write-sectors) |
send_metrics_on_resume -b |
+ |
+# Report disk health from SMART (S.M.A.R.T.) parameters. |
+# The first printf avoids a newline in $smart. |
+smart="$(/usr/sbin/smartctl -A $(/usr/bin/rootdev -d) | \ |
+ awk ' |
+/^187/ { printf "%d ", $10; } |
+/^199/ { print $10; } |
+')" |
+# smart now contains two numbers, for instance "10 20". Extract each number |
+# using prefix and suffix substitutions. This would less cryptic if dash had |
+# arrays. |
+metrics_client Platform.SmartUncorrectableErrors ${smart% *} 1 1000000 20 |
+metrics_client Platform.SmartTransferErrors ${smart#* } 1 1000000 20 |