Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugins] speedup big journal collection #3873

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion sos/report/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3083,10 +3083,20 @@ def add_journal(self, units=None, boot=None, since=None, until=None,
if output:
journal_cmd += output_opt % output

fname = journal_cmd
if log_size > 0 and not lines:
# get the last 1000 lines
res = self.exec_cmd(f"{journal_cmd} -n1000")
if res['status'] == 0 and res['output'].count('\n') >= 1000:
# compute how many lines we need to reach log_size from
# the 1000 lines size, add 50% margin to avoid being short
lines = int(log_size*1024*1024/len(res['output'])*1000*1.5)
journal_cmd += lines_opt % lines

self._log_debug(f"collecting journal: {journal_cmd}")
self._add_cmd_output(cmd=journal_cmd, timeout=timeout,
sizelimit=log_size, pred=pred, tags=tags,
priority=priority)
priority=priority, suggest_filename=fname)

def _expand_copy_spec(self, copyspec):
def __expand(paths):
Expand Down
Loading