Move dump scripts from phosphor-debug-collector
This commit is intended to move the dump collection
scripts from openbmc/phosphor-debug-collector repository.
Following are the scripts that are pulled from the
specified paths of openbmc/phosphor-debug-collector.
1. tools/dreport.d/ibm.d/package
2. tools/dreport.d/ibm.d/plugins.d/pels
3. tools/dreport.d/ibm.d/plugins.d/badpel
4. tools/dreport.d/ibm.d/plugins.d/vpd_data
5. tools/dreport.d/openpower.d/plugins.d/cfam
6. tools/dreport.d/openpower.d/plugins.d/dumpfilelist
7. tools/dreport.d/openpower.d/plugins.d/guardlist
8. tools/dreport.d/openpower.d/plugins.d/obmcconsole1
9. tools/dreport.d/openpower.d/plugins.d/occ
10.tools/dreport.d/openpower.d/plugins.d/phal_devtree
Also the following 3 patches have been applied.
1.https://gerrit.openbmc.org/c/openbmc/phosphor-debug-collector/+/56428
2.https://gerrit.openbmc.org/c/openbmc/phosphor-debug-collector/+/52436
3.https://gerrit.openbmc.org/c/openbmc/phosphor-debug-collector/+/47917
Also, added meson changes to install the scripts.
Test:
Verified that the scripts are getting installed correctly on BMC.
Change-Id: Iaddf909efaa138db06c877e5ca6a80608feb5baf
Signed-off-by: Gopichand Paturi <gopichandpaturi@gmail.com>
diff --git a/.shellcheck-ignore b/.shellcheck-ignore
index 6f5e42c..cba21bd 100644
--- a/.shellcheck-ignore
+++ b/.shellcheck-ignore
@@ -1,3 +1,14 @@
+dump/tools/bmcdump/plugins/badpel
+dump/tools/bmcdump/plugins/cfam
+dump/tools/bmcdump/plugins/dumpfilelist
+dump/tools/bmcdump/plugins/guardlist
+dump/tools/bmcdump/plugins/obmcconsole1
+dump/tools/bmcdump/plugins/occ
+dump/tools/bmcdump/plugins/pels
+dump/tools/bmcdump/plugins/phal_devtree
+dump/tools/bmcdump/plugins/vpd_data
+dump/tools/bmcdump/scripts/package
dump/tools/common/include/gendumpheader
-dump/tools/opdump/opdreport
dump/tools/common/include/gendumpinfo
+dump/tools/common/include/opfunctions
+dump/tools/opdump/opdreport
diff --git a/dump/meson.build b/dump/meson.build
index 2640c7c..774f8e2 100644
--- a/dump/meson.build
+++ b/dump/meson.build
@@ -50,8 +50,10 @@
bindir = get_option('bindir')
dreport_include_dir = join_paths(get_option('datadir'), 'dreport.d/include.d')
+dreport_plugins_dir = join_paths(get_option('datadir'), 'dreport.d/plugins.d')
scripts_to_install = []
+plugins_to_install = []
include_scripts = []
subdir('tools')
@@ -64,11 +66,17 @@
endif
# Install collected include scripts if any
+if plugins_to_install.length() > 0
+ install_data(plugins_to_install,
+ install_dir: dreport_plugins_dir,
+ install_mode: 'rwxr-xr-x'
+ )
+endif
+
+# Install collected include scripts if any
if include_scripts.length() > 0
install_data(include_scripts,
install_dir: dreport_include_dir,
install_mode: 'rwxr-xr-x'
)
endif
-
-
diff --git a/dump/tools/bmcdump/dreport_op.conf b/dump/tools/bmcdump/dreport_op.conf
new file mode 100644
index 0000000..9490d05
--- /dev/null
+++ b/dump/tools/bmcdump/dreport_op.conf
@@ -0,0 +1,12 @@
+# This file is dreport configuration file and is where all dreport
+# configuration settings are placed.
+# The configuration file consists of sections, led by a [section] header and
+# followed by name: value entries, with continuations in the style INI format.
+# name=value is also accepted.
+
+[DumpType]
+1: core
+2: user
+3: elog
+4: checkstop
+5: ramoops
diff --git a/dump/tools/bmcdump/meson.build b/dump/tools/bmcdump/meson.build
new file mode 100644
index 0000000..3020fae
--- /dev/null
+++ b/dump/tools/bmcdump/meson.build
@@ -0,0 +1,7 @@
+subdir('plugins')
+subdir('scripts')
+
+# Define the path for the configuration file
+dreport_conf_dir = join_paths(get_option('prefix'), get_option('datadir'), 'dreport.d/conf.d')
+conf_file = meson.current_source_dir() / 'dreport_op.conf'
+install_data(conf_file, install_dir: dreport_conf_dir)
diff --git a/dump/tools/bmcdump/plugins/badpel b/dump/tools/bmcdump/plugins/badpel
new file mode 100644
index 0000000..a1de332
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/badpel
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+#
+# config: 2 20
+# @brief: Save the 'badPEL' file
+#
+
+. $DREPORT_INCLUDE/functions
+
+desc="Bad PEL file"
+file_name="/var/lib/phosphor-logging/extensions/pels/badPEL"
+
+if [ -e "$file_name" ]; then
+ add_copy_file "$file_name" "$desc"
+fi
diff --git a/dump/tools/bmcdump/plugins/cfam b/dump/tools/bmcdump/plugins/cfam
new file mode 100644
index 0000000..b34de6b
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/cfam
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+#
+# config: 234 10
+# @brief: Add CFAM details to dump.
+#
+
+# shellcheck disable=SC1091
+. "$DREPORT_INCLUDE"/functions
+
+source /etc/profile.d/power-target.sh
+
+file_name="cfam.log"
+if [ -e "/usr/bin/edbg" ]; then
+ desc="cfam 283c"
+ command="/usr/bin/edbg getcfam pu 283c -pall"
+ add_cmd_output "$command" "$file_name" "$desc"
+
+ desc="cfam 1007"
+ command="/usr/bin/edbg getcfam pu 1007 -pall"
+ add_cmd_output "$command" "$file_name" "$desc"
+
+ desc="cfam 2809"
+ command="/usr/bin/edbg getcfam pu 2809 -pall"
+ add_cmd_output "$command" "$file_name" "$desc"
+fi
diff --git a/dump/tools/bmcdump/plugins/dumpfilelist b/dump/tools/bmcdump/plugins/dumpfilelist
new file mode 100644
index 0000000..805a93e
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/dumpfilelist
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+#
+# config: 2 30
+# @brief: Get the dump and core file information
+#
+
+# shellcheck disable=SC1091
+. "$DREPORT_INCLUDE"/functions
+
+#core files
+file_name="dumplist.log"
+desc="Dumps"
+command="busctl call --verbose --no-pager \
+ xyz.openbmc_project.Dump.Manager \
+ /xyz/openbmc_project/dump \
+ org.freedesktop.DBus.ObjectManager \
+ GetManagedObjects"
+if ! add_cmd_output "$command" "$file_name" "$desc";
+then
+ #bmc dumps
+ dir="/var/lib/phosphor-debug-collector/dumps/"
+ desc="BMC dumps"
+ if [ -d "$dir" ] && [ -n "$(ls -A $dir/)" ]; then
+ add_cmd_output "echo $'[$desc]'" "$file_name" "$desc"
+ add_cmd_output "ls -AX $dir/*/*" "$file_name" "$desc"
+ else
+ log_info "$desc directory is empty"
+ fi
+
+ #hardware dumps
+ dir="/var/lib/phosphor-debug-collector/hardwaredump/"
+ desc="Hardware dumps"
+ if [ -d "$dir" ] && [ -n "$(ls -A $dir/)" ]; then
+ add_cmd_output "echo $'\n[$desc]'" "$file_name" "$desc"
+ add_cmd_output "ls -AX $dir/*/*" "$file_name" "$desc"
+ else
+ log_info "$desc directory is empty"
+ fi
+
+
+ #hostboot dumps
+ dir="/var/lib/phosphor-debug-collector/hostbootdump/"
+ desc="Hostboot dumps"
+ if [ -d "$dir" ] && [ -n "$(ls -A $dir/)" ]; then
+ add_cmd_output "echo $'\n[$desc]'" "$file_name" "$desc"
+ add_cmd_output "ls -AX $dir/*/*" "$file_name" "$desc"
+ else
+ log_info "$desc directory is empty"
+ fi
+
+
+ #sbe dumps
+ dir="/var/lib/phosphor-debug-collector/sbedump/"
+ desc="SBE dumps"
+ if [ -d "$dir" ] && [ -n "$(ls -A $dir/)" ]; then
+ add_cmd_output "echo $'\n[$desc]'" "$file_name" "$desc"
+ add_cmd_output "ls -AX $dir/*/*" "$file_name" "$desc"
+ else
+ log_info "$desc directory is empty"
+ fi
+fi
+
+#capture core file list
+dir="/var/lib/systemd/coredump/"
+desc="core files"
+if [ -d "$dir" ] && [ -n "$(ls -A $dir/)" ] && [ -n "$(ls -A $dir/core*)" ]; then
+ add_cmd_output "echo $'[$desc]'" "$file_name" "$desc"
+ add_cmd_output "ls -AX $dir/core*" "$file_name" "$desc"
+else
+ log_info "$desc directory is empty"
+fi
+
diff --git a/dump/tools/bmcdump/plugins/guardlist b/dump/tools/bmcdump/plugins/guardlist
new file mode 100644
index 0000000..919a9d1
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/guardlist
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# config: 234 40
+# @brief: Collect GUARD record information.
+#
+
+# shellcheck disable=SC1091
+. "$DREPORT_INCLUDE"/functions
+
+desc="GUARD Records"
+source /etc/profile.d/power-target.sh
+
+guard_part_file="/var/lib/phosphor-software-manager/hostfw/running/GUARD"
+
+# Check file is present and not empty.
+if [ -e "$guard_part_file" ]; then
+ add_copy_file "$guard_part_file" "$desc"
+fi
+
+# collect guarded list
+guard_log_file=guard.log
+if [ -e "/usr/bin/guard" ]; then
+ desc="Guard list"
+ add_cmd_output "echo $'[$desc]'" "$guard_log_file" "$desc"
+ add_cmd_output "/usr/bin/guard -l" "$guard_log_file" "$desc"
+
+ desc="Guard resolved records"
+ add_cmd_output "echo $'\n[$desc]'" "$guard_log_file" "$desc"
+ add_cmd_output "/usr/bin/guard -a" "$guard_log_file" "$desc"
+
+ desc="Guard ephemeral records"
+ add_cmd_output "echo $'\n[$desc]'" "$guard_log_file" "$desc"
+ add_cmd_output "/usr/bin/guard -e" "$guard_log_file" "$desc"
+fi
diff --git a/dump/tools/bmcdump/plugins/meson.build b/dump/tools/bmcdump/plugins/meson.build
new file mode 100644
index 0000000..1985f44
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/meson.build
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: Apache-2.0
+
+plugins_to_install += meson.current_source_dir() / 'badpel'
+plugins_to_install += meson.current_source_dir() / 'cfam'
+plugins_to_install += meson.current_source_dir() / 'dumpfilelist'
+plugins_to_install += meson.current_source_dir() / 'guardlist'
+plugins_to_install += meson.current_source_dir() / 'obmcconsole1'
+plugins_to_install += meson.current_source_dir() / 'occ'
+plugins_to_install += meson.current_source_dir() / 'pels'
+plugins_to_install += meson.current_source_dir() / 'phal_devtree'
+plugins_to_install += meson.current_source_dir() / 'vpd_data'
diff --git a/dump/tools/bmcdump/plugins/obmcconsole1 b/dump/tools/bmcdump/plugins/obmcconsole1
new file mode 100644
index 0000000..c6e7781
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/obmcconsole1
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+#
+# config: 2 25
+# @brief: Collect OBMC console1 log.
+#
+
+. $DREPORT_INCLUDE/functions
+
+desc="OBMC console1 log"
+file_name="/var/log/obmc-console1.log"
+if [ -e $file_name ]; then
+ add_copy_file "$file_name" "$desc"
+fi
diff --git a/dump/tools/bmcdump/plugins/occ b/dump/tools/bmcdump/plugins/occ
new file mode 100644
index 0000000..3e9c805
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/occ
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+#
+# config: 234 10
+# @brief: Get the occ information.
+#
+
+# shellcheck disable=SC1091
+. "$DREPORT_INCLUDE"/functions
+
+#fetch occ control data
+file_name="occ.log"
+
+desc="occ control"
+command="busctl call --verbose --no-pager \
+ org.open_power.OCC.Control \
+ /org/open_power/control \
+ org.freedesktop.DBus.ObjectManager \
+ GetManagedObjects"
+
+add_cmd_output "$command" "$file_name" "$desc"
+
+#fetch occ control host data
+desc="occ conrol host"
+command="busctl call --verbose --no-pager \
+ org.open_power.OCC.Control \
+ /xyz/openbmc_project/control \
+ org.freedesktop.DBus.ObjectManager \
+ GetManagedObjects"
+add_cmd_output "$command" "$file_name" "$desc"
+
+#fetch occ sensors data
+desc="occ sensor"
+command="busctl call --verbose --no-pager \
+ org.open_power.OCC.Control \
+ /xyz/openbmc_project/sensors \
+ org.freedesktop.DBus.ObjectManager \
+ GetManagedObjects"
+add_cmd_output "$command" "$file_name" "$desc"
+
+occ_dir="/var/lib/openpower-occ-control"
+if [ -d "$occ_dir" ]; then
+ add_copy_file "$occ_dir" "$desc"
+fi
diff --git a/dump/tools/bmcdump/plugins/pels b/dump/tools/bmcdump/plugins/pels
new file mode 100644
index 0000000..fd531f1
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/pels
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# config: 23 20
+#
+# 23 = User dump(2), elog dump(3)
+# 20 = priority
+
+# @brief: Collect the PEL files
+
+# shellcheck disable=SC1091
+. "$DREPORT_INCLUDE"/functions
+
+dir="/var/lib/phosphor-logging/extensions/pels/logs"
+desc="PEL Files"
+if [ -d $dir ]; then
+ add_copy_file "$dir" "$desc"
+fi
diff --git a/dump/tools/bmcdump/plugins/phal_devtree b/dump/tools/bmcdump/plugins/phal_devtree
new file mode 100644
index 0000000..bf768ee
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/phal_devtree
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+#
+# config: 234 25
+# @brief: Collect PHAL devtree debug data
+#
+
+# shellcheck disable=SC1091
+. "$DREPORT_INCLUDE"/functions
+
+# shellcheck source=./power-target.sh
+source /etc/profile.d/power-target.sh
+
+#export attributes list to attribute_list.txt
+attributes="/usr/bin/attributes"
+file_name="PHAL_devtree.txt"
+attr_cmd="$attributes export"
+desc="Attribute list"
+if [ -x $attributes ]; then
+ add_cmd_output "$attr_cmd" "$file_name" "$desc"
+fi
+#copy PHAL device tree file to dump
+file_name="$PDBG_DTB"
+desc="Device tree file"
+if [ -e "$file_name" ]; then
+ add_copy_file "$file_name" "$desc"
+fi
+
+#copy PHAL export device tree to dump
+file_name="/var/lib/phal/exportdevtree"
+desc="Exported device tree file"
+if [ -e "$file_name" ]; then
+ add_copy_file "$file_name" "$desc"
+fi
+
+#copy attribues info db to dump
+file_name="$PDATA_INFODB"
+desc="Attribute info db"
+if [ -e "$file_name" ]; then
+ add_copy_file "$file_name" "$desc"
+fi
diff --git a/dump/tools/bmcdump/plugins/vpd_data b/dump/tools/bmcdump/plugins/vpd_data
new file mode 100644
index 0000000..f146e47
--- /dev/null
+++ b/dump/tools/bmcdump/plugins/vpd_data
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+#
+# config: 2 50
+# @brief: Collect VPD persistent data
+#
+
+. $DREPORT_INCLUDE/functions
+
+file_name="/var/lib/vpd"
+desc="VPD persistent data"
+
+if [ -d "$file_name" ]; then
+ add_copy_file "$file_name" "$desc"
+else
+ log_info "No $desc data"
+fi
+
+desc="Bad VPD"
+dir_name="/tmp/bad-vpd"
+
+if [ -f $dir_name ]; then
+ add_copy_file "$dir_name" "$desc"
+else
+ log_info "No $desc data"
+fi
diff --git a/dump/tools/bmcdump/scripts/meson.build b/dump/tools/bmcdump/scripts/meson.build
new file mode 100644
index 0000000..088d13a
--- /dev/null
+++ b/dump/tools/bmcdump/scripts/meson.build
@@ -0,0 +1 @@
+include_scripts += meson.current_source_dir() / 'package'
diff --git a/dump/tools/bmcdump/scripts/package b/dump/tools/bmcdump/scripts/package
new file mode 100644
index 0000000..df87315
--- /dev/null
+++ b/dump/tools/bmcdump/scripts/package
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# @brief Packaging the dump, applying the header
+# and transferring to dump location.
+function custom_package()
+{
+ tar -Jcf "$name_dir.bin" -C \
+ "$(dirname "$name_dir")" "$(basename "$name_dir")"
+ # shellcheck disable=SC2181 # need output from `tar` in above if cond.
+ if [ $? -ne 0 ]; then
+ echo "$($TIME_STAMP)" "Could not create the compressed tar file"
+ rm -r "$name_dir.bin"
+ return "$INTERNAL_FAILURE"
+ fi
+
+ echo "Adding Dump Header :"$HEADER_EXTENSION
+ ("$HEADER_EXTENSION")
+
+ cat "$name_dir.bin" | tee -a "/tmp/dumpheader_$EPOCHTIME" > /dev/null
+ #remove the temporary name specific directory
+ rm -rf "$name_dir"
+ mv "/tmp/dumpheader_$EPOCHTIME" "$name_dir"
+
+ echo "$($TIME_STAMP)" "Report is available in $dump_dir"
+ if [ "$TMP_DIR" == "$dump_dir" ] || [ "$TMP_DIR/" == "$dump_dir" ]; then
+ return "$SUCCESS"
+ fi
+
+ #copy the compressed tar file into the destination
+ cp "$name_dir" "$dump_dir"
+ if [ $? -ne 0 ]; then
+ echo "Failed to copy the $name_dir to $dump_dir"
+ rm "$name_dir.bin"
+ return "$INTERNAL_FAILURE"
+ fi
+
+ #Remove the temporary copy of the file
+ rm -rf "$name_dir.bin" "$name_dir"
+}
+
+# Executing function
+custom_package
diff --git a/dump/tools/common/include/meson.build b/dump/tools/common/include/meson.build
index baac424..8feab83 100644
--- a/dump/tools/common/include/meson.build
+++ b/dump/tools/common/include/meson.build
@@ -1,2 +1,3 @@
include_scripts += meson.current_source_dir() / 'gendumpheader'
include_scripts += meson.current_source_dir() / 'gendumpinfo'
+include_scripts += meson.current_source_dir() / 'opfunctions'
diff --git a/dump/tools/common/include/opfunctions b/dump/tools/common/include/opfunctions
new file mode 100644
index 0000000..0808597
--- /dev/null
+++ b/dump/tools/common/include/opfunctions
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+# @brief fetch serial number
+# @param serial number
+function fetch_serial_number() {
+ serialNo=$(busctl get-property xyz.openbmc_project.Inventory.Manager \
+ /xyz/openbmc_project/inventory/system xyz.openbmc_project.Inventory.Decorator.Asset \
+ SerialNumber | cut -d " " -f 2 | sed "s/^\(\"\)\(.*\)\1\$/\2/g")
+
+ if [ -z "$serialNo" ]; then
+ serialNo="0000000"
+ fi
+}
+
+# @brief Add BMC dump File Name
+# @param BMC Dump File Name
+function get_bmc_dump_filename() {
+ fetch_serial_number
+ dump_id=$(printf %07d $dump_id)
+ if [ $dump_type = "$TYPE_FAULTDATA" ]; then
+ header_dump_name="FLTDUMP"
+ name="NAGDUMP.${serialNo}.${dump_id}.${dDay}"
+ else
+ header_dump_name="BMCDUMP"
+ name="BMCDUMP.${serialNo}.${dump_id}.${dDay}"
+ fi
+}
diff --git a/dump/tools/common/meson.build b/dump/tools/common/meson.build
index 1e82fd3..5d13ec5 100644
--- a/dump/tools/common/meson.build
+++ b/dump/tools/common/meson.build
@@ -1 +1 @@
-subdir('include')
\ No newline at end of file
+subdir('include')
diff --git a/dump/tools/meson.build b/dump/tools/meson.build
index fed2cca..aedf0c1 100644
--- a/dump/tools/meson.build
+++ b/dump/tools/meson.build
@@ -1,2 +1,3 @@
+subdir('bmcdump')
subdir('opdump')
-subdir('common')
\ No newline at end of file
+subdir('common')
diff --git a/dump/tools/opdump/meson.build b/dump/tools/opdump/meson.build
index 9f9b4ba..c28f1a0 100644
--- a/dump/tools/opdump/meson.build
+++ b/dump/tools/opdump/meson.build
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
-scripts_to_install += meson.current_source_dir() / 'opdreport'
\ No newline at end of file
+scripts_to_install += meson.current_source_dir() / 'opdreport'