mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Merge pull request #859 from Neraud/master
Update nginx byprojects plugins
This commit is contained in:
commit
fd8b33247a
@ -6,35 +6,27 @@ Count the number of hits per projects/vhost.
|
|||||||
![byproject_access](https://www.mantor.org/~northox/misc/munin-plugins/nginx_byprojects_access1-month.png "byproject_access")
|
![byproject_access](https://www.mantor.org/~northox/misc/munin-plugins/nginx_byprojects_access1-month.png "byproject_access")
|
||||||
|
|
||||||
## munin_byprojects_bandwidth
|
## munin_byprojects_bandwidth
|
||||||
Count the total bandwidth used by each projects/vhost. [Logtail] (https://www.fourmilab.ch/webtools/logtail/) is required.
|
Count the total bandwidth used by each projects/vhost. [Logtail](https://www.fourmilab.ch/webtools/logtail/) is required.
|
||||||
![byproject_bandwidth](https://www.mantor.org/~northox/misc/munin-plugins/apache_byprojects_bandwidth-month.png "byproject_bandwidth")
|
![byproject_bandwidth](https://www.mantor.org/~northox/misc/munin-plugins/apache_byprojects_bandwidth-month.png "byproject_bandwidth")
|
||||||
|
|
||||||
## munin_byprojects_inout_bandwidth
|
## munin_byprojects_inout_bandwidth
|
||||||
Counts the in/out bandwidth used by each projects/vhost. [Logtail] (https://www.fourmilab.ch/webtools/logtail/) is required.
|
Counts the in/out bandwidth used by each projects/vhost. [Logtail](https://www.fourmilab.ch/webtools/logtail/) is required.
|
||||||
![byproject_inout_bandwidth](https://www.mantor.org/~northox/misc/munin-plugins/apache_byprojects_inout_bandwidth-month.png "byproject_inout_bandwidth")
|
![byproject_inout_bandwidth](https://www.mantor.org/~northox/misc/munin-plugins/apache_byprojects_inout_bandwidth-month.png "byproject_inout_bandwidth")
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
The setup is pretty straight forward. First you need to configure the plugin:
|
The setup is pretty straight forward. First you need to configure the plugin:
|
||||||
|
|
||||||
Define the path to logtail:
|
In your munin plugin configuration file (for example, a new dedicated /etc/munin/plugin-conf.d/nginx_byprojects), configure the plugins :
|
||||||
|
|
||||||
$logtail = '/usr/local/bin/logtail';
|
[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 = (
|
env.site.prod [{"path":"/home/prod/log/access.log"}]
|
||||||
'prod' => [
|
env.site.dev [{"path":"/var/log/httpd/ssl-dev-access.log"}, {"path":"/home/dev/log/access*.log"}]
|
||||||
{'path' => '/home/prod/log/access.log'}
|
env.site.test [{"path":"/var/log/access.log","regex":"\"[A-Z]+ /test/"}, {"path":"/home/test/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'}
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
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/).
|
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/).
|
||||||
|
|
||||||
@ -42,5 +34,7 @@ Then link the file just as any other plugins.
|
|||||||
|
|
||||||
ln -s /usr/local/sbin/<plugin> /usr/local/etc/munin/plugins/<plugin>
|
ln -s /usr/local/sbin/<plugin> /usr/local/etc/munin/plugins/<plugin>
|
||||||
|
|
||||||
|
And restart the munin-node service.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
MIT
|
MIT
|
||||||
|
27
plugins/nginx/nginx_byprojects/byprojects_access
Normal file → Executable file
27
plugins/nginx/nginx_byprojects/byprojects_access
Normal file → Executable file
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
use strict;
|
use strict;
|
||||||
|
use JSON qw(decode_json);
|
||||||
#
|
#
|
||||||
# byprojects_access
|
# byprojects_access
|
||||||
#
|
#
|
||||||
@ -23,25 +24,23 @@ use strict;
|
|||||||
# Test graph will be using everything file matching /home/test/log/access*.log
|
# Test graph will be using everything file matching /home/test/log/access*.log
|
||||||
# and stuff that match the expression '"[A-Z] /test/' in /var/log/access.log
|
# and stuff that match the expression '"[A-Z] /test/' in /var/log/access.log
|
||||||
# such as '"GET /test/'
|
# such as '"GET /test/'
|
||||||
|
#
|
||||||
|
# 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 $server = 'Nginx';
|
||||||
|
|
||||||
my $statepath = $ENV{MUNIN_PLUGSTATE};
|
my $statepath = $ENV{MUNIN_PLUGSTATE};
|
||||||
my $logtail = '/usr/local/bin/logtail';
|
my $logtail = $ENV{logtail_path} || '/usr/local/bin/logtail';
|
||||||
|
|
||||||
my %logs = (
|
my @loglist = grep {$_ =~ /site\./} keys(%ENV);
|
||||||
'prod' => [
|
my %envLogs = %ENV{@loglist};
|
||||||
{'path' => '/home/prod/log/access.log'}
|
my %logs;
|
||||||
],
|
while(my($k, $v) = each %envLogs) { @logs{substr($k, 5)} = decode_json($v); }
|
||||||
'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'}
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
###########
|
###########
|
||||||
|
|
||||||
|
28
plugins/nginx/nginx_byprojects/byprojects_bandwidth
Normal file → Executable file
28
plugins/nginx/nginx_byprojects/byprojects_bandwidth
Normal file → Executable file
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
use strict;
|
use strict;
|
||||||
|
use JSON qw(decode_json);
|
||||||
#
|
#
|
||||||
# byprojects_bandwidth
|
# byprojects_bandwidth
|
||||||
#
|
#
|
||||||
@ -29,26 +30,23 @@ use strict;
|
|||||||
# Test graph will be using everything file matching /home/test/log/access*.log
|
# Test graph will be using everything file matching /home/test/log/access*.log
|
||||||
# and stuff that match the expression '"[A-Z] /test/' in /var/log/access.log
|
# and stuff that match the expression '"[A-Z] /test/' in /var/log/access.log
|
||||||
# such as '"GET /test/'
|
# such as '"GET /test/'
|
||||||
|
#
|
||||||
|
# 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 $server = 'Nginx';
|
||||||
|
|
||||||
my $statepath = $ENV{MUNIN_PLUGSTATE};
|
my $statepath = $ENV{MUNIN_PLUGSTATE};
|
||||||
my $logtail = '/usr/local/bin/logtail';
|
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); }
|
||||||
|
|
||||||
###########
|
###########
|
||||||
|
|
||||||
|
28
plugins/nginx/nginx_byprojects/byprojects_inout_bandwidth
Normal file → Executable file
28
plugins/nginx/nginx_byprojects/byprojects_inout_bandwidth
Normal file → Executable file
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
use strict;
|
use strict;
|
||||||
|
use JSON qw(decode_json);
|
||||||
#
|
#
|
||||||
# byprojects_inout_bandwidth
|
# byprojects_inout_bandwidth
|
||||||
#
|
#
|
||||||
@ -29,26 +30,23 @@ use strict;
|
|||||||
# Test graph will be using everything file matching /home/test/log/access*.log
|
# Test graph will be using everything file matching /home/test/log/access*.log
|
||||||
# and stuff that match the expression '"[A-Z] /test/' in /var/log/access.log
|
# and stuff that match the expression '"[A-Z] /test/' in /var/log/access.log
|
||||||
# such as '"GET /test/'
|
# such as '"GET /test/'
|
||||||
|
#
|
||||||
|
# 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 $server = 'Nginx';
|
||||||
|
|
||||||
my $statepath = $ENV{MUNIN_PLUGSTATE};
|
my $statepath = $ENV{MUNIN_PLUGSTATE};
|
||||||
my $logtail = '/usr/local/bin/logtail';
|
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); }
|
||||||
|
|
||||||
###########
|
###########
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user