Skip to content

Commit

Permalink
tools: troubleshoot: add more common logging commands
Browse files Browse the repository at this point in the history
Extend some of the common information that gets logged. This includes:

* /proc/cpuinfo
* lspci -tv
* /var/log/boot.log
* rpm -qa
* dpkg -l

Both the 'rpm' and 'dpkg' commands are executed without adding the
complexity of system detection. To compensate for this both std_out and
std_err are logged to the same file for these two commands.

Signed-off-by: Louis Peens <[email protected]>
Reviewed-by: Ryno Swart <[email protected]>
  • Loading branch information
louis-peens committed Aug 18, 2023
1 parent b9cfa17 commit 4920320
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tools/nfp_troubleshoot_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,11 @@ def common_data(outDir):
lspci_path = f'{outDir}/lspci'
write_logfile(lspci_info, lspci_path)

# lspci - tree view
lspci_tv_info, _, _ = scmd('lspci -tv', fail=False)
lspci_tv_path = f'{outDir}/lspci_tv'
write_logfile(lspci_tv_info, lspci_tv_path)

# firewalld
firewalld_info, _, _ = scmd('systemctl status firewalld', fail=False)
firewalld_path = f'{outDir}/systemctl_status_firewalld'
Expand Down Expand Up @@ -546,6 +551,23 @@ def common_data(outDir):
numactl_path = f'{outDir}/numactl_hardware'
write_logfile(numactl_info, numactl_path)

# The next two commands tries to capture the installed packages on
# the system. Adding system detection that is stable accross all
# OS's is complicated and error prone, so instead just log both
# std_out and std_err for both 'rpm -qa' and 'dpkg -l'

# rpm -qa
rpm_info, err, _ = scmd('rpm -qa', fail=False)
rpm_info += f"\n{err}"
rpm_path = f'{outDir}/rpm_package_list'
write_logfile(rpm_info, rpm_path)

# dpkg -l
deb_info, err, _ = scmd('dpkg -l', fail=False)
deb_info += f"\n{err}"
deb_path = f'{outDir}/deb_package_list'
write_logfile(deb_info, deb_path)

# dmidecode
for dmi in ["bios", "system", "baseboard", "chassis", "processor",
"memory", "cache", "connector", "slot"]:
Expand All @@ -561,6 +583,20 @@ def common_data(outDir):
except Exception:
write_logfile('Error reading /proc/meminfo', meminfo_path)

# /proc/cpuinfo
cpuinfo_path = f'{outDir}/proc_cpuinfo'
try:
shutil.copy2('/proc/cpuinfo', cpuinfo_path)
except Exception:
write_logfile('Error reading /proc/cpuinfo', cpuinfo_path)

# /var/boot.log
bootlog_path = f'{outDir}/boot.log'
try:
shutil.copy2('/var/log/boot.log', bootlog_path)
except Exception:
write_logfile('Error reading /var/log/boot.log', bootlog_path)

# history
home_dir = os.path.expanduser('~')
history_infile = f'{home_dir}/.bash_history'
Expand Down

0 comments on commit 4920320

Please sign in to comment.