aboutsummaryrefslogtreecommitdiff
path: root/kernel_log_collector.sh
diff options
context:
space:
mode:
authorYufeng Shen <miletus@chromium.org>2013-04-16 15:00:27 -0400
committerChromeBot <chrome-bot@google.com>2013-06-18 16:11:36 -0700
commit5a14515b8840d40ea7e8f0805e3018ee5c0d3a37 (patch)
tree6d39ec6d58c5d2dd34495a9f4bdf4f79226db302 /kernel_log_collector.sh
parent4582481ffa56db7f6350a217406f3aceb18e435e (diff)
downloadcrash_reporter-5a14515b8840d40ea7e8f0805e3018ee5c0d3a37.tar.gz
Add support for sending Atmel TP/TS error message
This adds the support that when Pixel touchscreen/trackpad driver atmel_mxt_ts is misbehaving, e.g. failed to update firmware, failed to read messages from the chip, trigger crash reporter to send system logging message for further debugging. We also follow the policy that, for atmel/cypress logs, we only fetch the last 30s of the logs. BUG=chromium:226186 TEST=1. On Pixel, replace the touchscreen firmware file /opt/google/touch/firmware/162.0_1.1.170.bin with an empty file with the same name 2. Force touchscreen firmware update /opt/google/touch/scripts/chromeos-touch-firmware-update.sh -d atmel_mxt_ts -f -n maxtouch-ts.fw 3. After the firmware update fails, check crash report exists at /var/spool/crash/change__i2c_atmel_mxt_ts.XXX 4. Check that the log contains only 30s of entries with "atmel" keyword. Change-Id: If46a575491378405e60ad1ccbd39026ae6bf2033 Reviewed-on: https://gerrit.chromium.org/gerrit/48239 Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Will Drewry <wad@chromium.org> Commit-Queue: Yufeng Shen <miletus@chromium.org> Tested-by: Yufeng Shen <miletus@chromium.org>
Diffstat (limited to 'kernel_log_collector.sh')
-rw-r--r--kernel_log_collector.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/kernel_log_collector.sh b/kernel_log_collector.sh
new file mode 100644
index 0000000..a9d4307
--- /dev/null
+++ b/kernel_log_collector.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# Copyright (c) 2013 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.
+
+# Usage example: "kernel_log_collector.sh XXX YYY"
+# This script searches logs in the /var/log/messages which have the keyword XXX.
+# And only those logs which are within the last YYY seconds of the latest log
+# that has the keyword XXX are printed.
+
+# Kernel log has the format
+# 2013-06-14T16:31:40.514513-07:00 localhost kernel: [ 2.682472] MSG MSG ...
+
+search_key=$1
+time_duration=$2
+msg_pattern="^[0-9-]*T[0-9:.-]* localhost kernel"
+
+die() {
+ echo "kernel_log_collector: $*" >&2
+ exit 1
+}
+
+get_timestamp() {
+ timestamp="$(echo $1 | cut -d " " -f 1)"
+ timestamp="$(date -d "${timestamp}" +%s)" || exit $?
+ echo "${timestamp}"
+}
+
+last_line=$(grep "${msg_pattern}" /var/log/messages | grep -- "${search_key}" | tail -n 1)
+
+if [ -n "${last_line}" ]; then
+ if ! allowed_timestamp=$(get_timestamp "${last_line}"); then
+ die "coule not get timestamp from: ${last_line}"
+ fi
+ : $(( allowed_timestamp -= ${time_duration} ))
+ grep "${msg_pattern}" /var/log/messages | grep -- "${search_key}" | while read line; do
+ if ! timestamp=$(get_timestamp "${line}"); then
+ die "could not get timestamp from: ${line}"
+ fi
+ if [ ${timestamp} -gt ${allowed_timestamp} ]; then
+ echo "${line}"
+ fi
+ done
+fi
+
+echo "END-OF-LOG"
+