xref: /openbmc/openpower-debug-collector/dump/tools/bmcdump/plugins/occ (revision 90bb9ad27c9d4d595a9459a24864e569d82912ba)
1#!/usr/bin/env bash
2#
3# config: 234 10
4# @brief: Get the occ information.
5#
6
7# shellcheck disable=SC1091
8. "$DREPORT_INCLUDE"/functions
9
10if [ ! -e "/usr/bin/openpower-occ-control" ]; then
11    exit 0
12fi
13
14#fetch occ control data
15file_name="occ.log"
16
17desc="occ control"
18command="busctl call --verbose --no-pager \
19                org.open_power.OCC.Control \
20                /org/open_power/control \
21                org.freedesktop.DBus.ObjectManager \
22                GetManagedObjects"
23
24add_cmd_output "$command" "$file_name" "$desc"
25
26#fetch occ control host data
27desc="occ control host"
28command="busctl call --verbose --no-pager \
29                org.open_power.OCC.Control \
30                /xyz/openbmc_project/control \
31                org.freedesktop.DBus.ObjectManager \
32                GetManagedObjects"
33add_cmd_output "$command" "$file_name" "$desc"
34
35#fetch occ sensors data
36desc="occ sensor"
37command="busctl call --verbose --no-pager \
38                org.open_power.OCC.Control \
39                /xyz/openbmc_project/sensors \
40                org.freedesktop.DBus.ObjectManager \
41                GetManagedObjects"
42add_cmd_output "$command" "$file_name" "$desc"
43
44#save occ-control persisted data
45occ_dir="/var/lib/openpower-occ-control"
46if [ -d "$occ_dir" ]; then
47    add_copy_file "$occ_dir" "$desc"
48fi
49
50#collect occ-control data
51file_name="/tmp/occ_control_dump.json"
52rm -f $file_name
53killall -s SIGUSR1 openpower-occ-control
54#wait up to 5 seconds for file to be created
55seconds=0
56while [ ! -e "$file_name" ]; do
57    seconds=$(( seconds + 1 ))
58    if [ $seconds -eq 5 ]; then
59        echo "Timed out waiting for occ-control data dump"
60        exit 0
61    fi
62    sleep 1
63done
64desc="occ-control data dump"
65add_copy_file "$file_name" "$desc"
66rm -rf "$file_name"
67