Ruchi Jahagirdar | 032ff21 | 2017-09-20 15:03:43 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # This script probes the readiness of chameleon boards in |
| 8 | # the audioboxes and atlantis labs. This script takes about 2 seconds per board. |
| 9 | # The total time for all hosts listed is 5-6 minutes. |
| 10 | |
| 11 | #TODO (rjahagir): Add command line for a status check on only a few hosts. |
| 12 | HOSTS="chromeos2-row10-rack10-host1 |
| 13 | chromeos2-row10-rack10-host11 |
| 14 | chromeos2-row10-rack10-host13 |
| 15 | chromeos2-row10-rack10-host15 |
| 16 | chromeos2-row10-rack10-host17 |
| 17 | chromeos2-row10-rack10-host19 |
| 18 | chromeos2-row10-rack10-host3 |
| 19 | chromeos2-row10-rack10-host5 |
| 20 | chromeos2-row10-rack10-host7 |
| 21 | chromeos2-row10-rack10-host9 |
| 22 | chromeos2-row10-rack5-host11 |
| 23 | chromeos2-row10-rack5-host13 |
| 24 | chromeos2-row10-rack5-host15 |
| 25 | chromeos2-row10-rack5-host17 |
| 26 | chromeos2-row10-rack5-host19 |
| 27 | chromeos2-row10-rack5-host21 |
| 28 | chromeos2-row10-rack6-host1 |
| 29 | chromeos2-row10-rack6-host11 |
| 30 | chromeos2-row10-rack6-host13 |
| 31 | chromeos2-row10-rack6-host15 |
| 32 | chromeos2-row10-rack6-host3 |
| 33 | chromeos2-row10-rack6-host5 |
| 34 | chromeos2-row10-rack6-host7 |
| 35 | chromeos2-row10-rack6-host9 |
| 36 | chromeos2-row10-rack7-host1 |
| 37 | chromeos2-row10-rack7-host11 |
| 38 | chromeos2-row10-rack7-host13 |
| 39 | chromeos2-row10-rack7-host15 |
| 40 | chromeos2-row10-rack7-host17 |
| 41 | chromeos2-row10-rack7-host3 |
| 42 | chromeos2-row10-rack7-host5 |
| 43 | chromeos2-row10-rack7-host7 |
| 44 | chromeos2-row10-rack7-host9 |
| 45 | chromeos2-row10-rack8-host1 |
| 46 | chromeos2-row10-rack8-host13 |
| 47 | chromeos2-row10-rack8-host15 |
| 48 | chromeos2-row10-rack8-host17 |
| 49 | chromeos2-row10-rack8-host19 |
| 50 | chromeos2-row10-rack8-host21 |
| 51 | chromeos2-row10-rack8-host3 |
| 52 | chromeos2-row10-rack8-host5 |
| 53 | chromeos2-row10-rack8-host7 |
| 54 | chromeos2-row10-rack8-host9 |
| 55 | chromeos2-row10-rack9-host11 |
| 56 | chromeos2-row10-rack9-host13 |
| 57 | chromeos2-row10-rack9-host15 |
| 58 | chromeos2-row10-rack9-host17 |
| 59 | chromeos2-row10-rack9-host19 |
| 60 | chromeos2-row10-rack9-host21 |
| 61 | chromeos2-row10-rack9-host3 |
| 62 | chromeos2-row10-rack9-host5 |
| 63 | chromeos2-row10-rack9-host7 |
| 64 | chromeos2-row10-rack9-host9 |
| 65 | chromeos9-audiobox1-host1 |
| 66 | chromeos9-audiobox1-host2 |
| 67 | chromeos9-audiobox2-host1 |
| 68 | chromeos9-audiobox2-host2 |
| 69 | chromeos9-audiobox3-host1 |
| 70 | chromeos9-audiobox3-host2 |
| 71 | chromeos9-audiobox4-host1 |
| 72 | chromeos9-audiobox4-host2 |
| 73 | chromeos9-audiobox5-host1 |
| 74 | chromeos9-audiobox5-host2 |
| 75 | chromeos9-audiobox6-host1 |
| 76 | chromeos9-audiobox6-host2 |
| 77 | chromeos9-audiobox7-host1 |
| 78 | chromeos9-audiobox7-host2 |
| 79 | chromeos1-row5-rack1-host2 |
| 80 | chromeos1-row5-rack2-host2 |
| 81 | chromeos1-row2-rack3-host4 |
| 82 | chromeos1-row2-rack4-host4" |
| 83 | |
| 84 | # NOTE: May need to update based on where test_rsa is located. |
| 85 | SSH_OPTIONS="-q -i ~/.ssh/.test_rsa \ |
| 86 | -o UserKnownHostsFile=/dev/null \ |
| 87 | -o StrictHostKeyChecking=no" |
| 88 | |
| 89 | PROBE_RESULT_DIR="/tmp/chameleon_probe_result" |
| 90 | |
| 91 | SEP_LINE="--------------------------------------------------------------------------------------" |
| 92 | |
| 93 | |
| 94 | function disp_result { |
| 95 | test "$1" -eq "0" && echo ok || echo "-" |
| 96 | } |
| 97 | |
| 98 | function probe_chameleon { |
| 99 | chameleon="$1-chameleon.cros" |
| 100 | |
| 101 | # ping test |
| 102 | ping -q -w 10 -c1 "${chameleon}" > /dev/null 2>&1 |
| 103 | ping_result="$(disp_result $?)" |
| 104 | |
| 105 | # checking /dev/root space |
| 106 | devroot_space=$(ssh ${SSH_OPTIONS} root@"$chameleon" \ |
| 107 | df -h | awk -F' ' 'FNR == 2 {print $5}')\ |
| 108 | |
| 109 | # Check if chameleond is running. |
| 110 | test $(ssh ${SSH_OPTIONS} root@"$chameleon" \ |
| 111 | ps | awk '$5~"run_chameleond"' | wc -l) -gt "0" |
| 112 | chameleond_result="$(disp_result $?)" |
| 113 | |
| 114 | # Check chameleond version |
| 115 | chameleond_version=$(ssh ${SSH_OPTIONS} root@"$chameleon" \ |
| 116 | cat /etc/default/chameleond | \ |
| 117 | awk -F'=' '/BUNDLE_VERSION/ {print $2}')\ |
| 118 | |
| 119 | # Print the result |
| 120 | printf "$1-chameleon %5s %10s %10s %s\n" "${ping_result}" \ |
| 121 | "${devroot_space}" "${chameleond_result}" "${chameleond_version}" \ |
| 122 | > "${PROBE_RESULT_DIR}/${chameleon}" |
| 123 | } |
| 124 | |
| 125 | function probe_chameleons { |
| 126 | # Fork parallel processes to probe the chameleon boards. |
| 127 | for host in $HOSTS; do |
| 128 | probe_chameleon $host & |
| 129 | chameleon_pids="${chameleon_pids} $!" |
| 130 | done |
| 131 | } |
| 132 | |
| 133 | function create_ping_result_dir { |
| 134 | chameleon_pids="" |
| 135 | |
| 136 | mkdir -p "${PROBE_RESULT_DIR}" |
| 137 | rm -fr "${PROBE_RESULT_DIR}"/* |
| 138 | } |
| 139 | |
| 140 | function print_chameleon_status { |
| 141 | echo "Chameleon ping /dev/root chameleond version" |
| 142 | echo "${SEP_LINE}" |
| 143 | |
| 144 | # Wait for all probing children processes to terminate. |
| 145 | for pid in ${chameleon_pids}; do |
| 146 | wait ${pid} |
| 147 | done |
| 148 | |
| 149 | # Sort and print the results. |
| 150 | cat "${PROBE_RESULT_DIR}"/*-chameleon.cros | sort |
| 151 | echo; echo |
| 152 | } |
| 153 | |
| 154 | create_ping_result_dir |
| 155 | probe_chameleons |
| 156 | print_chameleon_status |