this uses the new journalreader instead of journalctl, which is a bit faster and can read from/to cursor and returns a start/end cursor
also you can give an unix epoch as time parameters Signed-off-by: Dominik Csapak <d.csa...@proxmox.com> --- PVE/API2/Nodes.pm | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/control | 1 + 2 files changed, 72 insertions(+) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index df47be1f..426c026e 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -699,6 +699,77 @@ __PACKAGE__->register_method({ return $lines; }}); +__PACKAGE__->register_method({ + name => 'journal', + path => 'journal', + method => 'GET', + description => "Read Journal", + proxyto => 'node', + permissions => { + check => ['perm', '/nodes/{node}', [ 'Sys.Syslog' ]], + }, + protected => 1, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + since => { + type=> 'number', + description => "Display all log since this UNIX epoch.", + optional => 1, + }, + until => { + type=> 'number', + description => "Display all log until this UNIX epoch.", + optional => 1, + }, + lastentries => { + description => "Limit to the last X lines.", + type => 'integer', + optional => 1, + }, + startcursor => { + description => "Start after the given Cursor.", + type => 'string', + optional => 1, + }, + endcursor => { + description => "End before the given Cursor.", + type => 'string', + optional => 1, + }, + }, + }, + returns => { + type => 'array', + items => { + type => "string", + } + }, + code => sub { + my ($param) = @_; + + my $rpcenv = PVE::RPCEnvironment::get(); + my $user = $rpcenv->get_user(); + + my $lines = []; + + my $parser = sub { + push @$lines, shift; + }; + + my $cmd = ["/usr/bin/mini-journalreader"]; + push @$cmd, '-n', $param->{lastentries} if $param->{lastentries}; + push @$cmd, '-b', $param->{since} if $param->{since}; + push @$cmd, '-e', $param->{until} if $param->{until}; + push @$cmd, '-f', $param->{startcursor} if $param->{startcursor}; + push @$cmd, '-t', $param->{endcursor} if $param->{endcursor}; + + PVE::Tools::run_command($cmd, outfunc => $parser); + + return $lines; + }}); + my $sslcert; my $shell_cmd_map = { diff --git a/debian/control b/debian/control index eb39e1e9..1a200c0a 100644 --- a/debian/control +++ b/debian/control @@ -60,6 +60,7 @@ Depends: apt-transport-https, pciutils, perl (>= 5.10.0-19), postfix | mail-transport-agent, + proxmox-mini-journalreader, proxmox-widget-toolkit (>= 1.0-26), pve-cluster (>= 5.0-27), pve-container (>= 2.0-21), -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel