def collect_system_logs(self, lines=None, units=None): """Query the contents of the systemd journal. :param lines: Maximum number of lines to retrieve from the logs. If None, return everything. :param units: A list with the names of the units we should retrieve the logs from. If None retrieve the logs for everything. :raises: CommandExecutionError if failed to collect the system logs. :returns: A dictionary with the key `system_logs` and the value of a gzipped and base64 encoded string of the file with the logs. """ logs = utils.get_journald_logs(lines=lines, units=units) return {'system_logs': utils.gzip_and_b64encode_str(logs, file_name='journal')}
def collect_logs(data, failures): """Collect journald logs from the ramdisk. As inspection runs before any nodes details are known, it's handy to have logs returned with data. This collector sends logs to inspector in format expected by the 'ramdisk_error' plugin: base64 encoded tar.gz. This collector should be installed last in the collector chain, otherwise it won't collect enough logs. This collector does not report failures. :param data: mutable data that we'll send to inspector :param failures: AccumulatedFailures object """ try: logs = utils.get_journald_logs(lines=10000) except errors.CommandExecutionError: return data['logs'] = utils.gzip_and_b64encode_str(logs, file_name='journal')