From 737e03ada07a06f396387c8719aa7df61de1da2f Mon Sep 17 00:00:00 2001
From: Mark Harrison <mark@mivok.net>
Date: Thu, 18 Oct 2012 14:50:59 -0400
Subject: [PATCH] Make filename a parameter rather than use the check name

This allows you to have multiple checks on the same file, but with a different
match string in order to count different types of errors.
---
 lib/Core/Log.pm | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/Core/Log.pm b/lib/Core/Log.pm
index 692dca7..a136cc8 100644
--- a/lib/Core/Log.pm
+++ b/lib/Core/Log.pm
@@ -16,7 +16,7 @@ Core::Log - Monitor a log file for errors matching a certain pattern
 =head1 SYNOPSIS
 
  Core::Log {
-     /var/log/foo: match => ^ERROR:
+     foo: filename => /var/log/foo, match => ^ERROR:
  }
 
 =head1 DESCRIPTION
@@ -34,11 +34,15 @@ can be used to clear an alert for the error count being greater than 0.
 
 =item check_name
 
-The name of the file to monitor
+The check name for this module is descriptive only.
+
+=item filename
+
+The name of the file to monitor.
 
 =item match
 
-Regular expression for matching error lines
+Regular expression for matching error lines.
 
 =back
 
@@ -60,8 +64,8 @@ A string showing the errors
 
 sub handler {
     my $self = shift;
-    my $config = $self->{config}; # All configuration is in here
-    my $file = $self->{check_name}; # The check name is in here
+    my $config = $self->{config};
+    my $file = $config->{filename};
 
     my @statinfo = stat($file);
 
-- 
GitLab