[autotest] report -1 for machine stats that match no host
graphite keeps the last value of a gauge if no new data is reported. In the
case of a board disconued from a pool, the stats will go stale for the last
value. Set the value to -1 to indicate the stats is not applicable for
analysis.
Also, use host_history script to get host history directly, without making
any RPC through AFE.
CQ-DEPEND=CL:221743
BUG=chromium:419043
TEST=run collect_host_stats.py locally
Change-Id: I5b581873687c8daa5a871bcaa32be3eecb03b266
Reviewed-on: https://chromium-review.googlesource.com/220210
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/site_utils/host_label_utils.py b/site_utils/host_label_utils.py
index 2209383..d283ecf 100755
--- a/site_utils/host_label_utils.py
+++ b/site_utils/host_label_utils.py
@@ -14,6 +14,7 @@
"""
import argparse
+import itertools
import logging
import pprint
import time
@@ -30,6 +31,22 @@
_HOST_LABEL_TIME_INDEX_TYPE = 'host_labels_time_index'
+def get_all_boards():
+ """Get a list of boards from host labels.
+
+ Scan through all labels of all duts and get all possible boards based on
+ label of name board:*
+
+ @return: A list of board names, e.g., ['peppy', 'daisy']
+ """
+ host_labels = get_host_labels()
+ board_labels = [[label[6:] for label in labels
+ if label.startswith('board:')]
+ for labels in host_labels.values()]
+ boards = list(set(itertools.chain.from_iterable(board_labels)))
+ return boards
+
+
def get_host_labels(days_back=0, hostname=None, labels=None):
"""Get the labels for a given host or all hosts.