blob: bb626309b6fcf4eec6b6eddd5d58124271c8439c [file] [log] [blame]
#!/bin/sh
# Copyright (c) 2010 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.
FREQ=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
AWK_PROG='
/Initial TSC value:/ {
sub(".*Initial TSC value: ", "")
initial_tsc = $0
exit
}
END {
printf "%.2f", initial_tsc / ('$FREQ' * 1000.0)
}
'
FIRMWARE_TIME=$(dmesg | awk "$AWK_PROG")
# 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.
echo $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.
# 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