OLD | NEW |
1 #!/bin/sh | 1 #!/bin/sh |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 set -e | 7 set -e |
8 | 8 |
9 # Product ID in crash report | 9 # Product ID in crash report |
10 CHROMEOS_PRODUCT=ChromeOS | 10 CHROMEOS_PRODUCT=ChromeOS |
11 | 11 |
12 # File whose existence implies crash reports may be sent, and whose | 12 # File whose existence implies crash reports may be sent, and whose |
13 # contents includes our machine's anonymized guid. | 13 # contents includes our machine's anonymized guid. |
14 CONSENT_ID="/home/chronos/Consent To Send Stats" | 14 CONSENT_ID="/home/chronos/Consent To Send Stats" |
15 | 15 |
| 16 # Path to find which is required for computing the crash rate. |
| 17 FIND="/usr/bin/find" |
| 18 |
16 # Send up to 8 crashes per day. | 19 # Send up to 8 crashes per day. |
17 MAX_CRASH_RATE=8 | 20 MAX_CRASH_RATE=8 |
18 | 21 |
19 # URL to send non-official build crashes to. | 22 # URL to send non-official build crashes to. |
20 MINIDUMP_UPLOAD_STAGING_URL="http://clients2.google.com/cr/staging_report" | 23 MINIDUMP_UPLOAD_STAGING_URL="http://clients2.google.com/cr/staging_report" |
21 | 24 |
22 # URL to send official build crashes to. | 25 # URL to send official build crashes to. |
23 MINIDUMP_UPLOAD_PROD_URL="http://clients2.google.com/cr/report" | 26 MINIDUMP_UPLOAD_PROD_URL="http://clients2.google.com/cr/report" |
24 | 27 |
25 # File whose existence mocks crash sending. If empty we pretend the | 28 # File whose existence mocks crash sending. If empty we pretend the |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 is_on_3g() { | 97 is_on_3g() { |
95 # See crosbug.com/3304. | 98 # See crosbug.com/3304. |
96 return 1 | 99 return 1 |
97 } | 100 } |
98 | 101 |
99 # Check if sending a crash now does not exceed the maximum 24hr rate and | 102 # Check if sending a crash now does not exceed the maximum 24hr rate and |
100 # commit to doing so, if not. | 103 # commit to doing so, if not. |
101 check_rate() { | 104 check_rate() { |
102 mkdir -p ${TIMESTAMPS_DIR} | 105 mkdir -p ${TIMESTAMPS_DIR} |
103 # Only consider minidumps written in the past 24 hours by removing all older. | 106 # Only consider minidumps written in the past 24 hours by removing all older. |
104 find "${TIMESTAMPS_DIR}" -mindepth 1 -mmin +$((24 * 60)) -exec rm '{}' ';' | 107 ${FIND} "${TIMESTAMPS_DIR}" -mindepth 1 -mmin +$((24 * 60)) -exec rm '{}' ';' |
105 local sends_in_24hrs=$(echo "${TIMESTAMPS_DIR}"/* | wc -w) | 108 local sends_in_24hrs=$(echo "${TIMESTAMPS_DIR}"/* | wc -w) |
106 lecho "Current send rate: ${sends_in_24hrs}sends/24hrs" | 109 lecho "Current send rate: ${sends_in_24hrs}sends/24hrs" |
107 if [ ${sends_in_24hrs} -ge ${MAX_CRASH_RATE} ]; then | 110 if [ ${sends_in_24hrs} -ge ${MAX_CRASH_RATE} ]; then |
108 lecho "Cannot send more crashes:" | 111 lecho "Cannot send more crashes:" |
109 lecho " current ${sends_in_24hrs}send/24hrs >= " \ | 112 lecho " current ${sends_in_24hrs}send/24hrs >= " \ |
110 "max ${MAX_CRASH_RATE}send/24hrs" | 113 "max ${MAX_CRASH_RATE}send/24hrs" |
111 return 1 | 114 return 1 |
112 fi | 115 fi |
113 mktemp "${TIMESTAMPS_DIR}"/XXXX > /dev/null | 116 mktemp "${TIMESTAMPS_DIR}"/XXXX > /dev/null |
114 return 0 | 117 return 0 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 221 } |
219 | 222 |
220 main() { | 223 main() { |
221 if [ -e "${PAUSE_CRASH_SENDING}" ]; then | 224 if [ -e "${PAUSE_CRASH_SENDING}" ]; then |
222 lecho "Exiting early due to ${PAUSE_CRASH_SENDING}" | 225 lecho "Exiting early due to ${PAUSE_CRASH_SENDING}" |
223 exit 1 | 226 exit 1 |
224 fi | 227 fi |
225 | 228 |
226 check_not_already_running | 229 check_not_already_running |
227 | 230 |
| 231 if [ ! -x "${FIND}" ]; then |
| 232 lecho "Fatal: Crash sending disabled: ${FIND} not found." |
| 233 exit 1 |
| 234 fi |
| 235 |
228 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)" | 236 TMP_DIR="$(mktemp -d /tmp/crash_sender.XXXX)" |
229 trap cleanup_tmp_dir EXIT INT | 237 trap cleanup_tmp_dir EXIT INT |
230 | 238 |
231 # Send system-wide crashes | 239 # Send system-wide crashes |
232 send_crashes "/var/spool/crash" | 240 send_crashes "/var/spool/crash" |
233 | 241 |
234 # Send user-specific crashes | 242 # Send user-specific crashes |
235 send_crashes "/home/chronos/user/crash" | 243 send_crashes "/home/chronos/user/crash" |
236 } | 244 } |
237 | 245 |
238 main | 246 main |
OLD | NEW |