124226c4fSGopichand Paturi#!/usr/bin/env bash 224226c4fSGopichand Paturi# 324226c4fSGopichand Paturi# config: 234 10 424226c4fSGopichand Paturi# @brief: Get the occ information. 524226c4fSGopichand Paturi# 624226c4fSGopichand Paturi 724226c4fSGopichand Paturi# shellcheck disable=SC1091 824226c4fSGopichand Paturi. "$DREPORT_INCLUDE"/functions 924226c4fSGopichand Paturi 10*90bb9ad2SChris Cainif [ ! -e "/usr/bin/openpower-occ-control" ]; then 11*90bb9ad2SChris Cain exit 0 12*90bb9ad2SChris Cainfi 13*90bb9ad2SChris Cain 1424226c4fSGopichand Paturi#fetch occ control data 1524226c4fSGopichand Paturifile_name="occ.log" 1624226c4fSGopichand Paturi 1724226c4fSGopichand Paturidesc="occ control" 1824226c4fSGopichand Paturicommand="busctl call --verbose --no-pager \ 1924226c4fSGopichand Paturi org.open_power.OCC.Control \ 2024226c4fSGopichand Paturi /org/open_power/control \ 2124226c4fSGopichand Paturi org.freedesktop.DBus.ObjectManager \ 2224226c4fSGopichand Paturi GetManagedObjects" 2324226c4fSGopichand Paturi 2424226c4fSGopichand Paturiadd_cmd_output "$command" "$file_name" "$desc" 2524226c4fSGopichand Paturi 2624226c4fSGopichand Paturi#fetch occ control host data 27eb46252dSManojkiran Edadesc="occ control host" 2824226c4fSGopichand Paturicommand="busctl call --verbose --no-pager \ 2924226c4fSGopichand Paturi org.open_power.OCC.Control \ 3024226c4fSGopichand Paturi /xyz/openbmc_project/control \ 3124226c4fSGopichand Paturi org.freedesktop.DBus.ObjectManager \ 3224226c4fSGopichand Paturi GetManagedObjects" 3324226c4fSGopichand Paturiadd_cmd_output "$command" "$file_name" "$desc" 3424226c4fSGopichand Paturi 3524226c4fSGopichand Paturi#fetch occ sensors data 3624226c4fSGopichand Paturidesc="occ sensor" 3724226c4fSGopichand Paturicommand="busctl call --verbose --no-pager \ 3824226c4fSGopichand Paturi org.open_power.OCC.Control \ 3924226c4fSGopichand Paturi /xyz/openbmc_project/sensors \ 4024226c4fSGopichand Paturi org.freedesktop.DBus.ObjectManager \ 4124226c4fSGopichand Paturi GetManagedObjects" 4224226c4fSGopichand Paturiadd_cmd_output "$command" "$file_name" "$desc" 4324226c4fSGopichand Paturi 44*90bb9ad2SChris Cain#save occ-control persisted data 4524226c4fSGopichand Paturiocc_dir="/var/lib/openpower-occ-control" 4624226c4fSGopichand Paturiif [ -d "$occ_dir" ]; then 4724226c4fSGopichand Paturi add_copy_file "$occ_dir" "$desc" 4824226c4fSGopichand Paturifi 49*90bb9ad2SChris Cain 50*90bb9ad2SChris Cain#collect occ-control data 51*90bb9ad2SChris Cainfile_name="/tmp/occ_control_dump.json" 52*90bb9ad2SChris Cainrm -f $file_name 53*90bb9ad2SChris Cainkillall -s SIGUSR1 openpower-occ-control 54*90bb9ad2SChris Cain#wait up to 5 seconds for file to be created 55*90bb9ad2SChris Cainseconds=0 56*90bb9ad2SChris Cainwhile [ ! -e "$file_name" ]; do 57*90bb9ad2SChris Cain seconds=$(( seconds + 1 )) 58*90bb9ad2SChris Cain if [ $seconds -eq 5 ]; then 59*90bb9ad2SChris Cain echo "Timed out waiting for occ-control data dump" 60*90bb9ad2SChris Cain exit 0 61*90bb9ad2SChris Cain fi 62*90bb9ad2SChris Cain sleep 1 63*90bb9ad2SChris Caindone 64*90bb9ad2SChris Caindesc="occ-control data dump" 65*90bb9ad2SChris Cainadd_copy_file "$file_name" "$desc" 66*90bb9ad2SChris Cainrm -rf "$file_name" 67