| 1 |
Description: Add ability to search systemd journals by syslog identifiers |
| 2 |
Forwarded: https://github.com/lausser/check_logfiles/pull/80 |
| 3 |
Author: John Lines <[email protected]> |
| 4 |
Last-Update: 2024-01-15 |
| 5 |
|
| 6 |
diff --git a/plugins-scripts/Nagios/CheckLogfiles/Search/Journald.pm b/plugins-scripts/Nagios/CheckLogfiles/Search/Journald.pm |
| 7 |
index 45a4ac4..b9d28cc 100755 |
| 8 |
--- a/plugins-scripts/Nagios/CheckLogfiles/Search/Journald.pm |
| 9 |
+++ b/plugins-scripts/Nagios/CheckLogfiles/Search/Journald.pm |
| 10 |
@@ -26,6 +26,7 @@ sub init { |
| 11 |
if ($self->{journaldunit} and $self->{tag} eq "default") { |
| 12 |
$self->{tag} = $self->{journaldunit}; |
| 13 |
} |
| 14 |
+ $self->{journaldidentifier} = $params->{journald}->{identifier}; |
| 15 |
$self->default_options({ exeargs => "", }); |
| 16 |
$self->SUPER::init($params); |
| 17 |
} |
| 18 |
@@ -49,6 +50,9 @@ sub collectfiles { |
| 19 |
if ($self->{journaldunit}) { |
| 20 |
$cmdline = $cmdline." --unit '".$self->{journaldunit}."'"; |
| 21 |
} |
| 22 |
+ if ($self->{journaldidentifier}) { |
| 23 |
+ $cmdline = $cmdline." --identifier '".$self->{journaldidentifier}."'"; |
| 24 |
+ } |
| 25 |
$cmdline = $cmdline." --since '".strftime("%Y-%m-%d %H:%M:%S", localtime($self->{journald}->{since}))."'|"; |
| 26 |
if ($fh->open($cmdline)) { |
| 27 |
push(@{$self->{relevantfiles}}, |
| 28 |
diff --git a/plugins-scripts/Nagios/Tivoli/Config/Logfile.pm b/plugins-scripts/Nagios/Tivoli/Config/Logfile.pm |
| 29 |
index ac0d19a..8a3420f 100755 |
| 30 |
--- a/plugins-scripts/Nagios/Tivoli/Config/Logfile.pm |
| 31 |
+++ b/plugins-scripts/Nagios/Tivoli/Config/Logfile.pm |
| 32 |
@@ -5,6 +5,8 @@ |
| 33 |
# tivoli config files and |
| 34 |
# return it as hash structure |
| 35 |
# |
| 36 |
+# John Lines update to filter on journald:identifier |
| 37 |
+# to allow, for example --type=journald:identifier='postfix/smtp' |
| 38 |
package Nagios::Tivoli::Config::Logfile; |
| 39 |
|
| 40 |
use strict; |