blob: 8166fe82cda1759c4d4999a47acbb92c29459289 [file] [log] [blame]
# Copyright (c) 2012 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 once-per-boot UMA statistics"
author "chromium-os-dev@chromium.org"
start on started system-services
script
GET_FIRMWARE_TIME='
/Initial usec timer/ {
sub(".*Initial usec timer ", "")
initial_usec = $0
exit
}
END {
printf "%.2f\n", initial_usec / 1000000
}
'
# TODO(jrbarnette): This is a concession to existing chrome code
# that uses the value for reporting metrics to UMA. We'd like to
# move that reporting here, to reduce coupling with chrome. Once
# we've moved the metrics reporting here, the code to create this
# file can be removed.
dmesg | awk "$GET_FIRMWARE_TIME" >/tmp/firmware-boot-time
# usage:
# report_disk_metrics <read-sectors> <write-sectors>
report_disk_metrics() {
metrics_client Platform.BootSectorsRead $1 1 1000000 50
metrics_client Platform.BootSectorsWritten $2 1 10000 50
}
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.
# 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")
POWERWASH_COMPLETE="/mnt/stateful_partition/unencrypted/.powerwash_completed"
POWERWASH_COUNT="/mnt/stateful_partition/unencrypted/preserve/powerwash_count"
# Report powerwash stats if a powerwash recently occurred.
if [ -f $POWERWASH_COMPLETE -a -f /home/chronos/.oobe_completed ]; then
# Upload the fact powerwash occurred and the number of times this device
# has been powerwashed.
COUNT=$(head -1 $POWERWASH_COUNT | cut -c1-4)
if [ $(expr "$COUNT" : "^[0-9][0-9]*$") -ne 0 ]; then
metrics_client Installer.PowerwashCount $COUNT 1 1000 20
fi
rm -f $POWERWASH_COMPLETE
fi
end script