mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-27 10:01:38 +00:00
new helper dump_journal to view systemd journal
This commit is contained in:
parent
a1609259d3
commit
6de95a662f
@ -988,6 +988,37 @@ sub dump_logfile {
|
|||||||
return ($count, $lines);
|
return ($count, $lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub dump_journal {
|
||||||
|
my ($start, $limit, $filter) = @_;
|
||||||
|
|
||||||
|
my $lines = [];
|
||||||
|
my $count = 0;
|
||||||
|
|
||||||
|
$start = 0 if !$start;
|
||||||
|
$limit = 50 if !$limit;
|
||||||
|
|
||||||
|
my $parser = sub {
|
||||||
|
my $line = shift;
|
||||||
|
|
||||||
|
return if $count++ < $start;
|
||||||
|
return if $limit <= 0;
|
||||||
|
push @$lines, { n => int($count), t => $line};
|
||||||
|
$limit--;
|
||||||
|
};
|
||||||
|
|
||||||
|
my $cmd = ['journalctl', '-o', 'short', '--no-pager'];
|
||||||
|
run_command($cmd, outfunc => $parser);
|
||||||
|
|
||||||
|
# HACK: ExtJS store.guaranteeRange() does not like empty array
|
||||||
|
# so we add a line
|
||||||
|
if (!$count) {
|
||||||
|
$count++;
|
||||||
|
push @$lines, { n => $count, t => "no content"};
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($count, $lines);
|
||||||
|
}
|
||||||
|
|
||||||
sub dir_glob_regex {
|
sub dir_glob_regex {
|
||||||
my ($dir, $regex) = @_;
|
my ($dir, $regex) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user