blob: ea9960a12de1c4bbb99c3e12244af9cec27e4704 [file] [log] [blame]
J. Richard Barnette556038b2014-07-08 14:33:00 -07001#!/bin/bash
2
Troy Kensinger1e311142014-09-19 15:41:18 -07003CSV=FALSE
4
5while getopts "c" name
6do
7 case $name in
8 c) CSV=TRUE;;
9 esac
10done
11shift $(( OPTIND - 1 ))
12
13if [ $# -gt 1 ]
J. Richard Barnette556038b2014-07-08 14:33:00 -070014then
Troy Kensinger1e311142014-09-19 15:41:18 -070015 echo "usage: $(basename $0) [ <options> ] [ <filename> ]" >&2
16 echo "options: -c for CSV format" >&2
17 exit 1
J. Richard Barnette556038b2014-07-08 14:33:00 -070018fi
19
Troy Kensinger1e311142014-09-19 15:41:18 -070020# If the -c option is called, the option index is shifted over once and the
21# value of the option is stored in $FILE. The default behavior is that the sed
22# transform will read from standard input if no argument is provided and $FILE
23# will be empty.
J. Richard Barnette556038b2014-07-08 14:33:00 -070024FILE=$1
Troy Kensinger1e311142014-09-19 15:41:18 -070025
26SED_SCRIPT="
J. Richard Barnette3d333e62014-07-14 14:34:23 -070027 s/ CHROMEOS_RELEASE_VERSION=[^ ]*//
28 s/ BOARD=[^ ]*//
Troy Kensinger1e311142014-09-19 15:41:18 -070029 "
30
31if [ $CSV = "TRUE" ]
32then
33 echo "Location,Status,Fixed,Comments"
34 SED_SCRIPT="
35 s/ ...[A-Z]*//
36 $SED_SCRIPT
37 s/ /,/
38 s/$/,,/
39 "
40 sed "$SED_SCRIPT" $FILE
41
42else
43 SED_SCRIPT="
44 s/^[^ ]* ...[A-Z]* //
45 $SED_SCRIPT
46 s/is up/servod &/
47 s/.*pwr_button:press.*/power button is stuck down/
48 s/^\(not running servod\) \(not running brillo\)$/\1, \2/
49 s/^not running servod$/up but not running servod, reason unknown/
50 s/^servod not configured$/running brillo, BOARD for &/
51 s/^servod failed$/servod running, but not working/
52 s/^is down/no answer to ping/
53 s/^\(not running servod\) \(ssh is down\)$/\1, ping is up, \2/
54 "
55 sed "$SED_SCRIPT" $FILE | sort | uniq -c |
J. Richard Barnette3d333e62014-07-14 14:34:23 -070056 awk '{ print ; sum += $1 } END { printf "%7d total\n", sum }' |
57 sort | cut -c -72
Troy Kensinger1e311142014-09-19 15:41:18 -070058fi