xref: /openbmc/openpower-debug-collector/dump/tools/common/include/opfunctions (revision 0d72381feff226fff27ad11fb8efc9550d195f9d)
124226c4fSGopichand Paturi#!/usr/bin/env bash
224226c4fSGopichand Paturi
3*0d72381fSGopichand Paturideclare -rx TYPE_FAULTDATA="faultdata"
4*0d72381fSGopichand Paturi
524226c4fSGopichand Paturi# @brief fetch serial number
624226c4fSGopichand Paturi# @param serial number
724226c4fSGopichand Paturifunction fetch_serial_number() {
824226c4fSGopichand Paturi    serialNo=$(busctl get-property xyz.openbmc_project.Inventory.Manager \
924226c4fSGopichand Paturi            /xyz/openbmc_project/inventory/system xyz.openbmc_project.Inventory.Decorator.Asset \
1024226c4fSGopichand Paturi        SerialNumber | cut -d " " -f 2 | sed "s/^\(\"\)\(.*\)\1\$/\2/g")
1124226c4fSGopichand Paturi
1224226c4fSGopichand Paturi    if [ -z "$serialNo" ]; then
1324226c4fSGopichand Paturi        serialNo="0000000"
1424226c4fSGopichand Paturi    fi
1524226c4fSGopichand Paturi}
1624226c4fSGopichand Paturi
1724226c4fSGopichand Paturi# @brief Add BMC dump File Name
1824226c4fSGopichand Paturi# @param BMC Dump File Name
1924226c4fSGopichand Paturifunction get_bmc_dump_filename() {
2024226c4fSGopichand Paturi    fetch_serial_number
219a39f43dSSwethaParasa    dump_id=$(printf %08d $dump_id)
2224226c4fSGopichand Paturi    if [ $dump_type = "$TYPE_FAULTDATA" ]; then
2324226c4fSGopichand Paturi        header_dump_name="FLTDUMP"
2424226c4fSGopichand Paturi        name="NAGDUMP.${serialNo}.${dump_id}.${dDay}"
2524226c4fSGopichand Paturi    else
2624226c4fSGopichand Paturi        header_dump_name="BMCDUMP"
2724226c4fSGopichand Paturi        name="BMCDUMP.${serialNo}.${dump_id}.${dDay}"
2824226c4fSGopichand Paturi    fi
2924226c4fSGopichand Paturi}
30