[pve-devel] [PATCH manager] syslog: allow to dump journal from specific boot

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Feb 16 15:15:04 CET 2016


Helpful when persistent logging is on (use simple check for
existence of /var/log/journal) as else we get an timeout from
the syslog api call as journalctl by default read every thing.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/API2/Nodes.pm | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index aa1fa0b..0a1f12e 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -535,6 +535,14 @@ __PACKAGE__->register_method({
 		minimum => 0,
 		optional => 1,
 	    },
+	    boot_offset => {
+		type => 'integer',
+		default => 0,
+		description => 'Show messages from a specific boot. Where < 0 ' .
+		    'describes the offset from now backwards and > 0 from the ' .
+		    'beginning of the logs forwards.',
+		optional => 1,
+	    },
 	},
     },
     returns => {
@@ -560,11 +568,18 @@ __PACKAGE__->register_method({
 	my $user = $rpcenv->get_user();
 	my $node = $param->{node};
 
-	my ($count, $lines) = PVE::Tools::dump_journal($param->{start}, $param->{limit});
+	$param->{boot_offset} = 0 if !defined($param->{boot_offset});
+
+	# if we do not have persistent logging this is useless
+	my $boot_offset = (-d '/var/log/journal') ? $param->{boot_offset} : undef ;
+
+	my ($count, $lines) = PVE::Tools::dump_journal($param->{start},
+						       $param->{limit},
+						       $boot_offset);
 
 	$rpcenv->set_result_attrib('total', $count);
-	    
-	return $lines; 
+
+	return $lines;
     }});
 
 my $sslcert;
-- 
2.1.4





More information about the pve-devel mailing list