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