blob: 299a7cbe30465a4d57901ff20a9d9ee17477bd53 [file] [log] [blame]
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Report smart metrics once per boot"
author "chromium-os-dev@chromium.org"
start on started system-services
script
# Report disk health from SMART (S.M.A.R.T.) parameters.
# usage:
# report_smart_metrics <uncorrectable-errors> <transfer-errors>
report_smart_metrics() {
metrics_client Platform.SmartUncorrectableErrors $1 1 1000000 20
metrics_client Platform.SmartTransferErrors $2 1 1000000 20
}
GET_SMART_ERRORS='
BEGIN { uncorr = 0; txfer = 0 }
$2 == "Reported_Uncorrect" { uncorr = $10 }
$2 == "UDMA_CRC_Error_Count" { txfer = $10 }
END { print uncorr, txfer }
'
report_smart_metrics $(
smartctl -A $(rootdev -s -d) | awk "$GET_SMART_ERRORS")
end script