def add_info(report, ui): problem_type = report.get("ProblemType", None) if problem_type == "Bug": response = ui.yesno("Is the issue you are reporting one you \ encountered when upgrading Ubuntu from one release to another?") else: response = None if response: os.execlp('apport-bug', 'apport-bug', 'ubuntu-release-upgrader') else: attach_gsettings_package(report, 'update-manager') attach_file_if_exists(report, '/var/log/apt/history.log', 'DpkgHistoryLog.txt') attach_file_if_exists(report, '/var/log/apt/term.log', 'DpkgTerminalLog.txt') attach_root_command_outputs( report, { 'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -' }) if command_available('hwe-support-status'): # not using apport's command_output because it doesn't expect a # return code of 10 unsupported = run_hwe_command('--show-all-unsupported') if unsupported: report['HWEunsupported'] = unsupported report['HWEreplacements'] = \ run_hwe_command('--show-replacements') report["Aptdaemon"] = recent_syslog(re.compile("AptDaemon"))
def add_info(report): attach_hardware(report) report['DiskUsage'] = command_output(['df']) report['MemoryUsage'] = command_output(['free']) if command_available('dmraid'): attach_root_command_outputs(report, { 'DmraidSets': 'dmraid -s', 'DmraidDevices': 'dmraid -r' }) if command_available('dmsetup'): attach_root_command_outputs( report, {'DeviceMapperTables': 'dmsetup table'}) try: installer_version = open('/var/log/installer/version') for line in installer_version: if line.startswith('ubiquity '): # File these reports on the ubiquity package instead report['SourcePackage'] = 'ubiquity' break installer_version.close() except IOError: pass add_installation_log(report, 'DIPartman', 'partman') add_installation_log(report, 'DISyslog', 'syslog')
def add_info(report, ui): problem_type = report.get("ProblemType", None) if problem_type == "Bug": response = ui.yesno("Is the issue you are reporting one you \ encountered when upgrading Ubuntu from one release to another?") else: response = None if response: os.execlp('apport-bug', 'apport-bug', 'ubuntu-release-upgrader') else: try: attach_gsettings_package(report, 'update-manager') except: pass attach_file_if_exists(report, '/var/log/apt/history.log', 'DpkgHistoryLog.txt') attach_file_if_exists(report, '/var/log/apt/term.log', 'DpkgTerminalLog.txt') attach_root_command_outputs( report, { 'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -' }) report["Aptdaemon"] = recent_syslog(re.compile("AptDaemon"))
def add_info(report): attach_hardware(report) report['DiskUsage'] = command_output(['df']) report['MemoryUsage'] = command_output(['free']) if command_available('dmraid'): attach_root_command_outputs(report, {'DmraidSets': 'dmraid -s', 'DmraidDevices': 'dmraid -r'}) if command_available('dmsetup'): attach_root_command_outputs(report, {'DeviceMapperTables': 'dmsetup table'}) try: installer_version = open('/var/log/installer/version') for line in installer_version: if line.startswith('ubiquity '): # File these reports on the ubiquity package instead report['SourcePackage'] = 'ubiquity' break installer_version.close() except IOError: pass add_installation_log(report, 'DIPartman', 'partman') add_installation_log(report, 'DISyslog', 'syslog')
def attach_hwinfo(report, ui=None): '''Optionally attach hardware info from lshw.''' prompt = ( 'Your device details (lshw) may be useful to developers when' ' addressing this bug, but gathering it requires admin privileges.' ' Would you like to include this info?') if ui and ui.yesno(prompt): attach_root_command_outputs(report, {'lshw.txt': 'lshw'})
def attach_hwinfo(report, ui=None): """Optionally attach hardware info from lshw.""" prompt = ( "Your device details (lshw) may be useful to developers when" " addressing this bug, but gathering it requires admin privileges." " Would you like to include this info?") if ui and ui.yesno(prompt): attach_root_command_outputs(report, {"lshw.txt": "lshw"})
def attach_cloud_init_logs(report, ui=None): '''Attach cloud-init logs and tarfile from 'cloud-init collect-logs'.''' attach_root_command_outputs(report, { 'cloud-init-log-warnings': 'egrep -i "warn|error" /var/log/cloud-init.log', 'cloud-init-output.log.txt': 'cat /var/log/cloud-init-output.log'}) root_command_output( ['cloud-init', 'collect-logs', '-t', '/tmp/cloud-init-logs.tgz']) attach_file(report, '/tmp/cloud-init-logs.tgz', 'logs.tgz')
def add_installation_log(report, ident, name): if os.path.exists('/var/log/installer/%s' % name): f = '/var/log/installer/%s' % name elif os.path.exists('/var/log/%s' % name): f = '/var/log/%s' % name else: return if os.access(f, os.R_OK): report[ident] = (f,) else: attach_root_command_outputs(report, {ident: "cat '%s'" % f})
def add_installation_log(report, ident, name): if os.path.exists('/var/log/installer/%s' % name): f = '/var/log/installer/%s' % name elif os.path.exists('/var/log/%s' % name): f = '/var/log/%s' % name else: return if os.access(f, os.R_OK): report[ident] = (f, ) else: attach_root_command_outputs(report, {ident: "cat '%s'" % f})
def attach_cloud_init_logs(report, ui=None): """Attach cloud-init logs and tarfile from 'cloud-init collect-logs'.""" attach_root_command_outputs( report, { "cloud-init-log-warnings": ('egrep -i "warn|error" /var/log/cloud-init.log'), "cloud-init-output.log.txt": "cat /var/log/cloud-init-output.log", }, ) root_command_output( ["cloud-init", "collect-logs", "-t", "/tmp/cloud-init-logs.tgz"]) attach_file(report, "/tmp/cloud-init-logs.tgz", "logs.tgz")
def add_info(report, ui): try: attach_gsettings_package(report, 'update-manager') except: pass attach_file_if_exists(report, '/var/log/apt/history.log', 'DpkgHistoryLog.txt') attach_file_if_exists(report, '/var/log/apt/term.log', 'DpkgTerminalLog.txt') attach_root_command_outputs( report, {'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'}) report["Aptdaemon"] = recent_syslog(re.compile("AptDaemon"))
def add_info(report, ui): try: attach_gsettings_package(report, 'ubuntu-release-upgrader') except: pass report['CrashDB'] = 'ubuntu' report.setdefault('Tags', 'dist-upgrade') report['Tags'] += ' dist-upgrade' clone_file = '/var/log/dist-upgrade/apt-clone_system_state.tar.gz' if os.path.exists(clone_file): report['VarLogDistupgradeAptclonesystemstate.tar.gz'] = \ root_command_output(["cat", clone_file], decode_utf8=False) attach_file_if_exists(report, '/var/log/dist-upgrade/apt.log', 'VarLogDistupgradeAptlog') attach_file_if_exists(report, '/var/log/dist-upgrade/apt-term.log', 'VarLogDistupgradeApttermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/history.log', 'VarLogDistupgradeAptHistorylog') attach_file_if_exists(report, '/var/log/dist-upgrade/lspci.txt', 'VarLogDistupgradeLspcitxt') attach_file_if_exists(report, '/var/log/dist-upgrade/main.log', 'VarLogDistupgradeMainlog') attach_file_if_exists(report, '/var/log/dist-upgrade/term.log', 'VarLogDistupgradeTermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/xorg_fixup.log', 'VarLogDistupgradeXorgFixuplog') attach_file_if_exists(report, '/var/log/dist-upgrade/screenlog.0', 'VarLogDistupgradeScreenlog') attach_root_command_outputs( report, {'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'}) problem_type = report.get("ProblemType", None) if problem_type == 'Crash': tmpdir = re.compile('ubuntu-release-upgrader-\w+') tb = report.get("Traceback", None) if tb: dupe_sig = '' for line in tb.splitlines(): scrub_line = tmpdir.sub('ubuntu-release-upgrader-tmpdir', line) dupe_sig += scrub_line + '\n' report["DuplicateSignature"] = dupe_sig
def add_info(report, ui): try: attach_gsettings_package(report, 'ubuntu-release-upgrader') except: pass report['CrashDB'] = 'ubuntu' report.setdefault('Tags', 'dist-upgrade') report['Tags'] += ' dist-upgrade' clone_file = '/var/log/dist-upgrade/apt-clone_system_state.tar.gz' if os.path.exists(clone_file): report['VarLogDistupgradeAptclonesystemstate.tar.gz'] = \ root_command_output(["cat", clone_file], decode_utf8=False) attach_file_if_exists(report, '/var/log/dist-upgrade/apt.log', 'VarLogDistupgradeAptlog') attach_file_if_exists(report, '/var/log/dist-upgrade/apt-term.log', 'VarLogDistupgradeApttermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/history.log', 'VarLogDistupgradeAptHistorylog') attach_file_if_exists(report, '/var/log/dist-upgrade/lspci.txt', 'VarLogDistupgradeLspcitxt') attach_file_if_exists(report, '/var/log/dist-upgrade/main.log', 'VarLogDistupgradeMainlog') attach_file_if_exists(report, '/var/log/dist-upgrade/term.log', 'VarLogDistupgradeTermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/screenlog.0', 'VarLogDistupgradeScreenlog') attach_root_command_outputs( report, {'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'}) problem_type = report.get("ProblemType", None) if problem_type == 'Crash': tmpdir = re.compile('ubuntu-release-upgrader-\w+') tb = report.get("Traceback", None) if tb: dupe_sig = '' for line in tb.splitlines(): scrub_line = tmpdir.sub('ubuntu-release-upgrader-tmpdir', line) dupe_sig += scrub_line + '\n' report["DuplicateSignature"] = dupe_sig
def add_info(report, ui): try: attach_gsettings_package(report, 'update-manager') except: pass response = ui.yesno( "Is the issue you are reporting one you encountered when upgrading Ubuntu from one release to another?" ) if response: report.setdefault('Tags', 'dist-upgrade') report['Tags'] += ' dist-upgrade' attach_file_if_exists( report, '/var/log/dist-upgrade/apt-clone_system_state.tar.gz', 'VarLogDistupgradeAptclonesystemstate.tar.gz') attach_file_if_exists(report, '/var/log/dist-upgrade/apt.log', 'VarLogDistupgradeAptlog') attach_file_if_exists(report, '/var/log/dist-upgrade/apt-term.log', 'VarLogDistupgradeApttermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/history.log', 'VarLogDistupgradeAptHistorylog') attach_file_if_exists(report, '/var/log/dist-upgrade/lspci.txt', 'VarLogDistupgradeLspcitxt') attach_file_if_exists(report, '/var/log/dist-upgrade/main.log', 'VarLogDistupgradeMainlog') attach_file_if_exists(report, '/var/log/dist-upgrade/term.log', 'VarLogDistupgradeTermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/screenlog.0', 'VarLogDistupgradeScreenlog') elif response is None or response is False: attach_file_if_exists(report, '/var/log/apt/history.log', 'DpkgHistoryLog.txt') attach_file_if_exists(report, '/var/log/apt/term.log', 'DpkgTerminalLog.txt') attach_root_command_outputs( report, { 'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -' }) report["Aptdaemon"] = recent_syslog(re.compile("AptDaemon"))
def add_info(report, ui): problem_type = report.get("ProblemType", None) if problem_type == "Bug": response = ui.yesno("Is the issue you are reporting one you \ encountered when upgrading Ubuntu from one release to another?") else: response = None if response: os.execlp('apport-bug', 'apport-bug', 'ubuntu-release-upgrader') else: try: attach_gsettings_package(report, 'update-manager') except: pass attach_file_if_exists(report, '/var/log/apt/history.log', 'DpkgHistoryLog.txt') attach_file_if_exists(report, '/var/log/apt/term.log', 'DpkgTerminalLog.txt') attach_root_command_outputs( report, {'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'}) report["Aptdaemon"] = recent_syslog(re.compile("AptDaemon"))
def add_info(report, ui): try: attach_gsettings_package(report, 'update-manager') except: pass response = ui.yesno("Is the issue you are reporting one you encountered when upgrading Ubuntu from one release to another?") if response: report.setdefault('Tags', 'dist-upgrade') report['Tags'] += ' dist-upgrade' attach_file_if_exists(report, '/var/log/dist-upgrade/apt-clone_system_state.tar.gz', 'VarLogDistupgradeAptclonesystemstate.tar.gz') attach_file_if_exists(report, '/var/log/dist-upgrade/apt.log', 'VarLogDistupgradeAptlog') attach_file_if_exists(report, '/var/log/dist-upgrade/apt-term.log', 'VarLogDistupgradeApttermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/history.log', 'VarLogDistupgradeAptHistorylog') attach_file_if_exists(report, '/var/log/dist-upgrade/lspci.txt', 'VarLogDistupgradeLspcitxt') attach_file_if_exists(report, '/var/log/dist-upgrade/main.log', 'VarLogDistupgradeMainlog') attach_file_if_exists(report, '/var/log/dist-upgrade/system_state.tar.gz', 'VarLogDistupgradeSystemstate.tar.gz') attach_file_if_exists(report, '/var/log/dist-upgrade/term.log', 'VarLogDistupgradeTermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/screenlog.0', 'VarLogDistupgradeScreenlog') elif response is None or response is False: attach_file_if_exists(report, '/var/log/apt/history.log', 'DpkgHistoryLog.txt') attach_file_if_exists(report, '/var/log/apt/term.log', 'DpkgTerminalLog.txt') attach_root_command_outputs(report, {'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'}) report["Aptdaemon"] = recent_syslog(re.compile("AptDaemon"))
def add_info(report, ui): efiboot = '/boot/efi/EFI/ubuntu' if command_available('efibootmgr'): report['EFIBootMgr'] = command_output(['efibootmgr', '-v']) else: report['EFIBootMgr'] = 'efibootmgr not available' commands = {} try: directory = os.stat(efiboot) except OSError as e: if e.errno == errno.ENOENT: report['Missing'] = '/boot/efi/EFI/ubuntu directory is missing' return if e.errno == errno.EACCES: directory = True if directory: arch = report['Architecture'] commands['BootEFIContents'] = 'ls %s' % efiboot commands[ 'ShimDiff'] = 'diff %s/shim%s.efi /usr/lib/shim/shim%s.efi.signed' % ( efiboot, efiarch[arch], efiarch[arch]) commands[ 'GrubDiff'] = 'diff %s/grub%s.efi /usr/lib/grub/%s-efi-signed/grub%s.efi.signed' % ( efiboot, efiarch[arch], grubarch[arch], efiarch[arch]) efivars_dir = '/sys/firmware/efi/efivars' sb_var = os.path.join(efivars_dir, 'SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c') mok_var = os.path.join( efivars_dir, 'MokSBStateRT-605dab50-e046-4300-abb6-3dd810dd8b23') attach_file(report, '/proc/sys/kernel/moksbstate_disabled') commands['SecureBoot'] = 'od -An -t u1 %s' % sb_var commands['MokSBStateRT'] = 'od -An -t u1 %s' % mok_var attach_root_command_outputs(report, commands) report['EFITables'] = recent_syslog(re.compile(r'(efi|esrt):|Secure boot'))
def add_info(report, ui): arch = platform.machine() if arch not in ['ppc64', 'ppc64le']: return is_kernel = report['ProblemType'].startswith( 'Kernel') or 'linux' in report.get('Package') try: with open('/proc/cpuinfo', 'r') as fp: contents = fp.read() ispSeries = 'pSeries' in contents isPowerNV = 'PowerNV' in contents isPowerKVM = 'emulated by qemu' in contents except IOError: ispSeries = False isPowerNV = False isPowerKVM = False if ispSeries or isPowerNV: if is_kernel: add_tar(report, '/proc/device-tree/', 'DeviceTree.tar') attach_file(report, '/proc/misc', 'ProcMisc') attach_file(report, '/proc/locks', 'ProcLocks') attach_file(report, '/proc/loadavg', 'ProcLoadAvg') attach_file(report, '/proc/swaps', 'ProcSwaps') attach_file(report, '/proc/version', 'ProcVersion') report['cpu_smt'] = command_output(['ppc64_cpu', '--smt']) report['cpu_cores'] = command_output(['ppc64_cpu', '--cores-present']) report['cpu_coreson'] = command_output(['ppc64_cpu', '--cores-on']) # To be executed as root if is_kernel: attach_root_command_outputs( report, { 'cpu_runmode': 'ppc64_cpu --run-mode', 'cpu_freq': 'ppc64_cpu --frequency', 'cpu_dscr': 'ppc64_cpu --dscr', 'nvram': 'cat /dev/nvram', }) attach_file_if_exists(report, '/var/log/platform') if ispSeries and not isPowerKVM: attach_file(report, '/proc/ppc64/lparcfg', 'ProcLparCfg') attach_file(report, '/proc/ppc64/eeh', 'ProcEeh') attach_file(report, '/proc/ppc64/systemcfg', 'ProcSystemCfg') report['lscfg_vp'] = command_output(['lscfg', '-vp']) report['lsmcode'] = command_output(['lsmcode', '-A']) report['bootlist'] = command_output(['bootlist', '-m', 'both', '-r']) report['lparstat'] = command_output(['lparstat', '-i']) if command_available('lsvpd'): report['lsvpd'] = command_output(['lsvpd', '--debug']) if command_available('lsvio'): report['lsvio'] = command_output(['lsvio', '-des']) if command_available('servicelog'): report['servicelog_dump'] = command_output( ['servicelog', '--dump']) if command_available('servicelog_notify'): report['servicelo_list'] = command_output( ['servicelog_notify', '--list']) if command_available('usysattn'): report['usysattn'] = command_output(['usysattn']) if command_available('usysident'): report['usysident'] = command_output(['usysident']) if command_available('serv_config'): report['serv_config'] = command_output(['serv_config', '-l']) if isPowerNV: add_tar(report, '/proc/ppc64/', 'ProcPpc64.tar')
def add_info(report, ui): arch = platform.machine() if arch not in ["ppc64", "ppc64le"]: return is_kernel = report["ProblemType"].startswith("Kernel") or "linux" in report.get("Package") try: with open("/proc/cpuinfo", "r") as fp: contents = fp.read() ispSeries = "pSeries" in contents isPowerNV = "PowerNV" in contents isPowerKVM = "emulated by qemu" in contents except IOError: ispSeries = False isPowerNV = False isPowerKVM = False if ispSeries or isPowerNV: if is_kernel: add_tar(report, "/proc/device-tree/", "DeviceTree.tar") attach_file(report, "/proc/misc", "ProcMisc") attach_file(report, "/proc/locks", "ProcLocks") attach_file(report, "/proc/loadavg", "ProcLoadAvg") attach_file(report, "/proc/swaps", "ProcSwaps") attach_file(report, "/proc/version", "ProcVersion") report["cpu_smt"] = command_output(["ppc64_cpu", "--smt"]) report["cpu_cores"] = command_output(["ppc64_cpu", "--cores-present"]) report["cpu_coreson"] = command_output(["ppc64_cpu", "--cores-on"]) # To be executed as root if is_kernel: attach_root_command_outputs( report, { "cpu_runmode": "ppc64_cpu --run-mode", "cpu_freq": "ppc64_cpu --frequency", "cpu_dscr": "ppc64_cpu --dscr", "nvram": "cat /dev/nvram", }, ) attach_file_if_exists(report, "/var/log/platform") if ispSeries and not isPowerKVM: attach_file(report, "/proc/ppc64/lparcfg", "ProcLparCfg") attach_file(report, "/proc/ppc64/eeh", "ProcEeh") attach_file(report, "/proc/ppc64/systemcfg", "ProcSystemCfg") report["lscfg_vp"] = command_output(["lscfg", "-vp"]) report["lsmcode"] = command_output(["lsmcode", "-A"]) report["bootlist"] = command_output(["bootlist", "-m", "both", "-r"]) report["lparstat"] = command_output(["lparstat", "-i"]) if command_available("lsvpd"): report["lsvpd"] = command_output(["lsvpd", "--debug"]) if command_available("lsvio"): report["lsvio"] = command_output(["lsvio", "-des"]) if command_available("servicelog"): report["servicelog_dump"] = command_output(["servicelog", "--dump"]) if command_available("servicelog_notify"): report["servicelo_list"] = command_output(["servicelog_notify", "--list"]) if command_available("usysattn"): report["usysattn"] = command_output(["usysattn"]) if command_available("usysident"): report["usysident"] = command_output(["usysident"]) if command_available("serv_config"): report["serv_config"] = command_output(["serv_config", "-l"]) if isPowerNV: add_tar(report, "/proc/ppc64/", "ProcPpc64.tar")