dreport: Add support for multi-chassis BMCs
Add support for BMCs which are capable of managing power to multiple
chassis. This is done by maintaining the same code path supported for
single chassis systems and adding a run-time check to detect multiple
chassis.
Tested: built into a Yosemite4 BMC (8-host system) and ran dreport
to and ensured that the tarball contained `chassis0-state.log` to
`chassis8-state.log`.
Change-Id: Id5c2a85a7eae6ecd10dc9f2734c4b0c172f7c831
Signed-off-by: Amithash Prasad <amithash@meta.com>
diff --git a/tools/dreport.d/plugins.d/chassisstate b/tools/dreport.d/plugins.d/chassisstate
index eb1c87f..5199713 100644
--- a/tools/dreport.d/plugins.d/chassisstate
+++ b/tools/dreport.d/plugins.d/chassisstate
@@ -6,12 +6,18 @@
. $DREPORT_INCLUDE/functions
-desc="Chassis State"
-file_name="chassis-state.log"
-command="busctl get-property \
- xyz.openbmc_project.State.Chassis \
- /xyz/openbmc_project/state/chassis0 \
- xyz.openbmc_project.State.Chassis \
- CurrentPowerState"
-
-add_cmd_output "$command" "$file_name" "$desc"
+services=$(busctl list | awk '{print $1}' | grep -E "xyz.openbmc_project.State.Chassis([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="chassis-state.log"
+ desc="Chassis State"
+ else
+ file_name="chassis${index}-state.log"
+ desc="Chassis${index} State"
+ fi
+ command="busctl get-property ${service} ${objpath} \
+ xyz.openbmc_project.State.Chassis CurrentPowerState"
+ add_cmd_output "$command" "$file_name" "$desc"
+done