blob: a4c6c84686260df11a25a93a413f06e8f803f8d8 [file] [log] [blame]
J. Richard Barnette254e80d2015-04-20 15:07:51 -07001# By default, we're invoked without arguments. This is how the cron
2# job does it, and means we should generate output and mail it to
3# the default mail alias.
4#
5# Invoking with arguments is for testing: It allows running through
6# the full logic and output generation, without spamming the alert
7# aliases.
8
9OPTIONS=""
10if [ $# -eq 0 ]; then
11 # TODO(jrbarnette): Really, this feels like a hack. The cron job
12 # that invokes the inventory scripts is installed and enabled on
13 # both a primary and backup server, meaning the e-mail will be
14 # generated twice. We don't want that, so unless this is the
15 # primary server, quash this job.
16 if ! cli/atest server list $(hostname) 2>&1 |
Richard Barnette6869c932018-08-14 13:06:35 -070017 grep -q 'STATUS_PRIMARY'; then
J. Richard Barnette254e80d2015-04-20 15:07:51 -070018 exit 0
19 fi
20
21 POOL_INTEREST=(
Richard Barnette56589892018-06-06 12:02:22 -070022 chromeos-test-monitors@google.com
J. Richard Barnette254e80d2015-04-20 15:07:51 -070023 )
Richard Barnette5de01eb2017-12-15 09:53:42 -080024 MODEL_INTEREST=(
J. Richard Barnettee78a7002015-05-27 07:27:24 -070025 englab-sys-cros@google.com
Richard Barnette56589892018-06-06 12:02:22 -070026 chromeos-test-monitors@google.com
J. Richard Barnette254e80d2015-04-20 15:07:51 -070027 )
28else
Richard Barnette5de01eb2017-12-15 09:53:42 -080029 MODEL_INTEREST=( "$@" )
J. Richard Barnette254e80d2015-04-20 15:07:51 -070030 POOL_INTEREST=( "$@" )
Richard Barnette45ac0332017-12-18 16:27:13 -080031 OPTIONS=--debug
J. Richard Barnette254e80d2015-04-20 15:07:51 -070032fi
33
Richard Barnette45ac0332017-12-18 16:27:13 -080034# Options to be used for different script invocations. Inventory
35# runs are relatively expensive, so operations that happen rarely
36# also bundle operations that happen more frequently.
Richard Barnette1ca30e62018-04-09 16:45:58 -070037# + UNTESTABLE_DETECT happens with every run. It looks for
38# and reports DUTs that for never run tests even though their
39# status indicates that they should.
Richard Barnette5de01eb2017-12-15 09:53:42 -080040# + MODEL_NOTIFY happens less often. This adds a full model
Richard Barnette45ac0332017-12-18 16:27:13 -080041# inventory count to REPAIR_LOOP_DETECT.
42# + POOL_NOTIFY happens least often. It adds per-pool inventory
43# counts, as well as individual DUT repair recommendations to
Richard Barnette5de01eb2017-12-15 09:53:42 -080044# MODEL_NOTIFY.
Richard Barnette45ac0332017-12-18 16:27:13 -080045
Richard Barnette1ca30e62018-04-09 16:45:58 -070046UNTESTABLE_DETECT=( --report-untestable )
Richard Barnette45ac0332017-12-18 16:27:13 -080047
Richard Barnette5de01eb2017-12-15 09:53:42 -080048MODEL_NOTIFY=(
Richard Barnette1ca30e62018-04-09 16:45:58 -070049 "${UNTESTABLE_DETECT[@]}"
Richard Barnette5de01eb2017-12-15 09:53:42 -080050 --model-notify $(echo "${MODEL_INTEREST[@]}" | sed 's/ /,/g')
J. Richard Barnette254e80d2015-04-20 15:07:51 -070051)
Richard Barnette45ac0332017-12-18 16:27:13 -080052
J. Richard Barnette254e80d2015-04-20 15:07:51 -070053POOL_NOTIFY=(
Richard Barnette5de01eb2017-12-15 09:53:42 -080054 "${MODEL_NOTIFY[@]}"
Richard Barnette3d08dc82017-02-16 15:27:39 -080055 --recommend=40
Richard Barnette45ac0332017-12-18 16:27:13 -080056 --pool-notify $(echo "${POOL_INTEREST[@]}" | sed 's/ /,/g')
J. Richard Barnette254e80d2015-04-20 15:07:51 -070057)