| #!/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. |
| |
| AWK_PROG=' |
| /Initial usec timer/ { |
| sub(".*Initial usec timer ", "") |
| initial_usec = $0 |
| exit |
| } |
| END { |
| printf "%.2f", initial_usec / 1000000 |
| } |
| ' |
| 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 |