Fix not to show redundant hostname #2473

This commit is contained in:
Ilia Ross
2025-05-15 13:16:41 +03:00
parent 806c8f4128
commit 6ab3247d3d

View File

@@ -54,9 +54,11 @@ my $fselect = shift;
my $lines = $in{'lines'} ? int($in{'lines'}) : int($config{'lines'}) || 1000;
my $journalctl_cmd = &has_command('journalctl');
return () if (!$journalctl_cmd);
my $reverse = "";
$reverse = " -r" if ($config{'reverse'});
$journalctl_cmd = "journalctl$reverse";
my $eflags = "";
$eflags = " -r" if ($config{'reverse'});
my $jver = &get_journalctl_version();
$eflags .= " --no-hostname" if (!$config{'showhost'} && $jver && $jver >= 239);
$journalctl_cmd = "journalctl$eflags";
my @rs = (
{ 'cmd' => "$journalctl_cmd -n $lines",
'desc' => $text{'journal_journalctl'},
@@ -278,5 +280,17 @@ else {
}
}
# get_journalctl_version()
# Returns the version of journalctl
sub get_journalctl_version
{
my $bin = &has_command('journalctl');
my $out = &backquote_command("\"$bin\" --version 2>&1");
if ($out =~ /systemd\s+([0-9]+(?:\.[0-9A-Za-z\-\+]+)*)/) {
return $1;
}
return undef;
}
1;