2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Add configuration option for the logs setup

This commit is contained in:
Neraud 2017-07-08 10:36:46 +02:00
parent 3a17b22edf
commit a1f7808b9e
4 changed files with 29 additions and 55 deletions

View File

@ -21,21 +21,12 @@ In your munin plugin configuration file (for example, a new dedicated /etc/munin
[byprojects_*]
env.logtail /usr/local/bin/logtail
Multiple logs can be used for the same project/vhost and a regular expression (regex) can be used as a filter:
Multiple logs can be used for the same project/vhost and a regular expression (regex) can be used as a filter.
Each log is defined in a dedicated environment variable, named env.site.[siteName]. The value is JSON formatted.
my %logs = (
'prod' => [
{'path' => '/home/prod/log/access.log'}
],
'dev' => [
{'path' => '/var/log/httpd/ssl-dev-access.log'},
{'path' => '/home/dev/log/access*.log'} # glob is supported
],
'test' => [
{'path' => '/var/log/access.log', 'regex' => '"[A-Z]+ /test/'},
{'path' => '/home/test/log/access.log'}
],
);
env.site.prod [{"path":"/home/prod/log/access.log"}]
env.site.dev [{"path":"/var/log/httpd/ssl-dev-access.log"}, {"path":"/home/dev/log/access*.log"}]
env.site.test [{"path":"/var/log/access.log","regex":"\"[A-Z]+ /test/"}, {"path":"/home/test/log/access.log"}]
In the previous example the prod project graph will be using everything in /home/prod/log/access.log. The test project will be using eveything in /home/test/log/access.log and stuff that match '"[A-Z] /test/' in /var/log/httpd/access.log (e.g. "GET /test/).

View File

@ -1,5 +1,6 @@
#!/usr/bin/perl -w
use strict;
use JSON qw(decode_json);
#
# byprojects_access
#
@ -27,25 +28,19 @@ use strict;
# Configuration
# [byprojects_*]
# env.logtail_path /usr/local/bin/logtail
# env.site.prod [{"path":"/home/prod/log/access.log"}]
# env.site.dev [{"path":"/var/log/httpd/ssl-dev-access.log"}, {"path":"/home/dev/log/access*.log"}]
# env.site.test [{"path":"/var/log/access.log","regex":"\"[A-Z]+ /test/"}, {"path":"/home/test/log/access.log"}]
my $server = 'Nginx';
my $statepath = $ENV{MUNIN_PLUGSTATE};
my $logtail = $ENV{logtail_path} || '/usr/local/bin/logtail';
my %logs = (
'prod' => [
{'path' => '/home/prod/log/access.log'}
],
'dev' => [
{'path' => '/var/log/httpd/ssl-dev-access.log'},
{'path' => '/home/dev/log/access*.log'} # glob is supported
],
'test' => [
{'path' => '/var/log/access.log', 'regex' => '"[A-Z]+ /test/'},
{'path' => '/home/test/log/access.log'}
],
);
my @loglist = grep {$_ =~ /site\./} keys(%ENV);
my %envLogs = %ENV{@loglist};
my %logs;
while(my($k, $v) = each %envLogs) { @logs{substr($k, 5)} = decode_json($v); }
###########

View File

@ -1,5 +1,6 @@
#!/usr/bin/perl -w
use strict;
use JSON qw(decode_json);
#
# byprojects_bandwidth
#
@ -33,26 +34,19 @@ use strict;
# Configuration
# [byprojects_*]
# env.logtail_path /usr/local/bin/logtail
# env.site.prod [{"path":"/home/prod/log/access.log"}]
# env.site.dev [{"path":"/var/log/httpd/ssl-dev-access.log"}, {"path":"/home/dev/log/access*.log"}]
# env.site.test [{"path":"/var/log/access.log","regex":"\"[A-Z]+ /test/"}, {"path":"/home/test/log/access.log"}]
my $server = 'Nginx';
my $statepath = $ENV{MUNIN_PLUGSTATE};
my $logtail = $ENV{logtail_path} || '/usr/local/bin/logtail';
my %logs = (
'prod' => [
{'path' => '/home/prod/log/access.log'}
],
'dev' => [
{'path' => '/var/log/httpd/ssl-dev-access.log'},
{'path' => '/home/dev/log/access.log'}
],
'test' => [
{'path' => '/var/log/access.log', 'regex' => '"[A-Z]+ /test/'},
{'path' => '/home/test/log/access.log'}
],
);
my @loglist = grep {$_ =~ /site\./} keys(%ENV);
my %envLogs = %ENV{@loglist};
my %logs;
while(my($k, $v) = each %envLogs) { @logs{substr($k, 5)} = decode_json($v); }
###########

View File

@ -1,5 +1,6 @@
#!/usr/bin/perl -w
use strict;
use JSON qw(decode_json);
#
# byprojects_inout_bandwidth
#
@ -33,26 +34,19 @@ use strict;
# Configuration
# [byprojects_*]
# env.logtail_path /usr/local/bin/logtail
# env.site.prod [{"path":"/home/prod/log/access.log"}]
# env.site.dev [{"path":"/var/log/httpd/ssl-dev-access.log"}, {"path":"/home/dev/log/access*.log"}]
# env.site.test [{"path":"/var/log/access.log","regex":"\"[A-Z]+ /test/"}, {"path":"/home/test/log/access.log"}]
my $server = 'Nginx';
my $statepath = $ENV{MUNIN_PLUGSTATE};
my $logtail = $ENV{logtail_path} || '/usr/local/bin/logtail';
my %logs = (
'prod' => [
{'path' => '/home/prod/log/access.log'}
],
'dev' => [
{'path' => '/var/log/httpd/ssl-dev-access.log'},
{'path' => '/home/dev/log/access.log'}
],
'test' => [
{'path' => '/var/log/access.log', 'regex' => '"[A-Z]+ /test/'},
{'path' => '/home/test/log/access.log'}
],
);
my @loglist = grep {$_ =~ /site\./} keys(%ENV);
my %envLogs = %ENV{@loglist};
my %logs;
while(my($k, $v) = each %envLogs) { @logs{substr($k, 5)} = decode_json($v); }
###########