From 01b753b6b1342a2ba40807972a712fd43a0c7ac6 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 1 Mar 2016 16:32:35 +0100 Subject: [PATCH] syslog: allow since/until parameters allow the since/until parameters which journalctl understands We use a really simple regex to check a valit date (time) stamp. This can be done as this API call gets mainly used by the GUI where we have full controll over what we send and additional journalctl has already a good timestamp parser which can handle that. --- PVE/API2/Nodes.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index d02e5f26..68f6d19b 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -535,6 +535,18 @@ __PACKAGE__->register_method({ minimum => 0, optional => 1, }, + since => { + type=> 'string', + pattern => '^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$', + description => "Display all log since this date-time string.", + optional => 1, + }, + until => { + type=> 'string', + pattern => '^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$', + description => "Display all log until this date-time string.", + optional => 1, + }, }, }, returns => { @@ -560,11 +572,12 @@ __PACKAGE__->register_method({ my $user = $rpcenv->get_user(); my $node = $param->{node}; - my ($count, $lines) = PVE::Tools::dump_journal($param->{start}, $param->{limit}); + my ($count, $lines) = PVE::Tools::dump_journal($param->{start}, $param->{limit}, + $param->{since}, $param->{until}); $rpcenv->set_result_attrib('total', $count); - - return $lines; + + return $lines; }}); my $sslcert;