diff options
| author | Michael Tritz <mtritz@us.ibm.com> | 2017-01-18 13:54:42 -0600 |
|---|---|---|
| committer | Michael Tritz <mtritz@us.ibm.com> | 2017-01-30 14:57:32 -0600 |
| commit | 3e3f28b4fbeada4b3f254d1b2d836c5fcb0bc28f (patch) | |
| tree | e279685ec904e951d7d6b03b3064552f9e505545 /ffdc | |
| parent | ac8ff06659644d22f83a07c5b6743f42142d04df (diff) | |
| download | phosphor-debug-collector-3e3f28b4fbeada4b3f254d1b2d836c5fcb0bc28f.tar.gz phosphor-debug-collector-3e3f28b4fbeada4b3f254d1b2d836c5fcb0bc28f.zip | |
First version of FFDC script
This script provides users a command-line tool to collect and
tar up debug data.
Change-Id: I28b5431056625e6ff3d194f1ab668a0246b414b4
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
Diffstat (limited to 'ffdc')
| -rw-r--r-- | ffdc | 83 |
1 files changed, 83 insertions, 0 deletions
@@ -0,0 +1,83 @@ +#!/bin/sh + +help=$'FFDC File Collection Script + +Collects various FFDC files and system parameters and places them in a .tar + +usage: ffdc [OPTION] + +Options: + -d, --dir <directory> Specify destination directory. Defaults to /tmp if + invalid or unspecified. + -h, --help Display this help text and exit. +' + +declare -a arr=( +# Commands to be outputted into individual files +# Format: "File name" "Command" + "Build_info.txt" "cat /etc/version" + "FW_level.txt" "cat /etc/os-release" + "BMC_OS.txt" "uname -a" + "BMC_uptime.txt" "uptime" + "BMC_disk_usage.txt" "df -hT" + + "systemctl_status.txt" "systemctl status | cat" + "failed_services.txt" "systemctl --failed" + "host_console.txt" "cat /var/log/obmc-console.log" + + "BMC_proc_list.txt" "top -n 1 -b" + "BMC_journalctl.txt" "journalctl --no-pager" + "BMC_dmesg.txt" "dmesg" + "BMC_procinfo.txt" "cat /proc/cpuinfo" + "BMC_meminfo.txt" "cat /proc/meminfo" + +# Copy all content from these directories into directories in the .tar +# Format: "Directory name" "Directory to copy" + "obmc" "/var/lib/obmc/" +) + +dir=$"ffdc_$(date +"%Y-%m-%d_%H-%M-%S")" +dest="/tmp" + +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + -d|--dir) + if [ -d "$2" ]; then + dest="$2" + else + echo "Invalid or no destination directory specified." + break + fi + shift 2 + ;; + -h|--help) + echo "$help" + exit + ;; + *) + echo "Unknown option $1. Display available options with -h or --help" + exit + ;; + esac +done + +echo "Using destination directory $dest" + +mkdir "$dest/$dir" + +for ((i=0;i<${#arr[@]};i+=2)); do + if [ -d "${arr[i+1]}" ]; then + echo "Copying contents of ${arr[i+1]} to directory ./${arr[i]} ..." + mkdir "$dest/$dir/${arr[i]}" + cp -r ${arr[i+1]}/* $dest/$dir/${arr[i]} + else + echo "Collecting ${arr[i]}..." + ${arr[i+1]} >> "$dest/$dir/${arr[i]}" + fi +done + +tar -cf "$dir.tar" -C $dest $dir +echo "Contents in $dest/$dir.tar" + +rm -r "$dest/$dir" |

