dreport: Add support for multi-host BMCs
Extend the current script to dump the current state of as many hosts as
supported on the current BMC. This is done by checking the number of
host-state services.
Tested: Run on Yosemite4 a 8-host platform and ensure the dreport
tarball contains host1-state.log to host8-state.log
Change-Id: Ibf8968923043ded237efda74a120d7e41e584f5a
Signed-off-by: Amithash Prasad <amithash@meta.com>
diff --git a/tools/dreport.d/plugins.d/hoststate b/tools/dreport.d/plugins.d/hoststate
index 4c64ff1..7885f55 100644
--- a/tools/dreport.d/plugins.d/hoststate
+++ b/tools/dreport.d/plugins.d/hoststate
@@ -6,12 +6,19 @@
. $DREPORT_INCLUDE/functions
-desc="Host State"
-file_name="host-state.log"
-command="busctl get-property \
- xyz.openbmc_project.State.Host \
- /xyz/openbmc_project/state/host0 \
- xyz.openbmc_project.State.Host \
- CurrentHostState"
-
-add_cmd_output "$command" "$file_name" "$desc"
+# Discover all services managing host states
+services=$(busctl list | awk '{print $1}' | grep -E "xyz.openbmc_project.State.Host([0-9]*)?$")
+for service in ${services}; do
+ objpath=$(busctl tree --list $service | tail -n 1)
+ index=$(echo "$service" | grep -o '[0-9]*$')
+ if [ -z "$index" ]; then
+ file_name="host-state.log"
+ desc="Host State"
+ else
+ file_name="host${index}-state.log"
+ desc="Host${index} State"
+ fi
+ command="busctl get-property ${service} ${objpath} \
+ xyz.openbmc_project.State.Host CurrentHostState"
+ add_cmd_output "$command" "$file_name" "$desc"
+done