[pve-devel] [PATCH manager 1/2] syslog: allow since/until parameters

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Mar 1 16:32:35 CET 2016


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 d02e5f2..0fe62ee 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;
-- 
2.1.4





More information about the pve-devel mailing list