xref: /openbmc/phosphor-debug-collector/tools/dreport.d/plugins.d/chassisstate (revision e5af9c67d266812e4099a20cd318c2e3c6e013c9)
1#!/bin/bash
2#
3# config: 1234 5
4# @brief: Collect Chassis state information.
5#
6
7# shellcheck source=tools/dreport.d/include.d/functions
8. "$DREPORT_INCLUDE"/functions
9
10services=$(busctl list | awk '{print $1}' | grep -E "xyz.openbmc_project.State.Chassis([0-9]*)?$")
11for service in ${services}; do
12    objpath=$(busctl tree --list "$service"  | tail -n 1)
13    index=$(echo "$service" | grep -o '[0-9]*$')
14    if [ -z "$index" ]; then
15        file_name="chassis-state.log"
16        desc="Chassis State"
17    else
18        file_name="chassis${index}-state.log"
19        desc="Chassis${index} State"
20    fi
21    command="busctl get-property ${service} ${objpath} \
22              xyz.openbmc_project.State.Chassis CurrentPowerState"
23    add_cmd_output "$command" "$file_name" "$desc"
24done
25