1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-11-25 19:47:02 +00:00

- have some dirs

This commit is contained in:
Steve Schnepp 2012-02-13 18:24:46 +01:00
parent 0b089ea777
commit 08346aac58
687 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,97 @@
#!/usr/bin/perl -w
=head1 NAME
nginx_hitmiss - Munin plugin to show hit rate of nginx proxy cache
=head1 APPLICABLE SYSTEMS
nginx caching proxy
=head1 CONFIGURATION
File::ReadBackwards is used and must be installed.
You can override the log file location.
[nginx*]
env.logfile /var/log/nginx/cache-access.log
Nginx must be configured to include "cs=$upstream_cache_status" in the
log file. Example format:
log_format cache '$remote_addr - $host [$time_local] "$request" $status '
'$body_bytes_sent "$http_referer" '
'rt=$request_time ut="$upstream_response_time" '
'cs=$upstream_cache_status';
By default the last 1000 log lines are read, you may want to change this.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 LICENSE
BSD
=cut
use File::ReadBackwards;
my $line_counter=1000;
my $LOG = exists $ENV{'logfile'} ? $ENV{'logfile'}
: "/var/log/nginx/cache-access.log";
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
unless (-r $LOG) {
print "$LOG not readable\n";
exit 0;
} else {
print "yes\n";
exit 0;
}
}
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_title NGINX hit rates\n";
print "graph_args -l 0 -u 100 --rigid\n";
print "graph_category nginx\n";
print "graph_vlabel %\n";
print "hit.label Hits\n";
print "hit.draw AREA\n";
print "hit.min 0\n";
print "hit.cdef hit,$line_counter,/,100,*\n";
print "miss.label Misses\n";
print "miss.draw STACK\n";
print "miss.min 0\n";
print "miss.cdef miss,$line_counter,/,100,*\n";
print "expired.label Expired Objects\n";
print "expired.draw STACK\n";
print "expired.min 0\n";
print "expired.cdef expired,$line_counter,/,100,*\n";
exit 0;
}
my ($e,$h,$m) = (0,0,0);
my $file_counter=0;
FILE: while ($line_counter > 0) {
my $file_extension = $file_counter==0? "" : ".$file_counter";
my $lh= File::ReadBackwards->new( "$LOG$file_extension" )
or ( warn "$line_counter lines to read, but $LOG$file_extension: $!"
and last FILE);
$file_counter++;
while (defined ($_= $lh->readline)) {
$line_counter--;
/cs=HIT/ and $h++;
/cs=MISS/ and $m++;
/cs=EXPIRED/ and $e++;
last FILE if $line_counter==0;
}
$lh->close();
}
print "hit.value $h\n";
print "miss.value $m\n";
print "expired.value $e\n";

161
plugins/nginx/nginx-combined Executable file
View file

@ -0,0 +1,161 @@
#!/usr/bin/perl -w
# -*- cperl -*-
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
# nginx_combine_ --- Determine the current status of Nginx
# using the http_stub_status module.
# extend of nginx_status_ plugin of António P. P. Almeida
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
# Copyright (C) 2010 Minato Miray <minatomiray@gmail.com>
# Author: António P. P. Almeida <appa@perusio.net>,
# Author: Minato Miray <minatomiray@gmail.com>
#######################################
# Nginx combined plugin to measure in one graph:
# - Request /sec
# - Connection / sec
# - Request / connection
# - Active connections
# - Reading
# - Writing
# - Waiting
########################################
# Usage:
# Copy to /usr/share/munin/plugins
# ln -s /usr/share/munin/plugins/nginx_combined_ /etc/munin/plugins/nginx_combined_[hostname OR IP address]
#examples based on nginx configuration:
#example1: ./nginx_combined_mysite.net
#example2: ./nginx_combined_10.0.0.1
########################################
my $ret = undef;
if (! eval "require LWP::UserAgent;"){
$ret = "LWP::UserAgent not found";
}
chomp(my $fqdn = `basename $0 | sed 's/^nginx_combined_//g'`);
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
if ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
if ($ret){
print "no ($ret)\n";
exit 1;
}
my $ua = LWP::UserAgent->new(timeout => 30);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
unless ($response->is_success and $response->content =~ /server/im)
{
print "no (no nginx status on $URL)\n";
exit 1;
}
else
{
print "yes\n";
exit 0;
}
}
if ( exists $ARGV[0] and $ARGV[0] eq "config" )
{
print "graph_title NGINX status: $URL\n";
print "graph_args --base 1000\n";
print "graph_category nginx\n";
print "graph_vlabel Connections\n";
print "reqpsec.label Request/sec.\n";
print "reqpsec.info Request/sec.\n";
print "reqpsec.draw LINE2\n";
print "conpersec.label Connection/sec.\n";
print "conpersec.info Connection/sec.\n";
print "conpersec.draw LINE2\n";
print "reqpcon.label Request/conn.\n";
print "reqpcon.info Request/conn.\n";
print "reqpcon.draw LINE2\n";
print "total.label Active connections\n";
print "total.info Active connections\n";
print "total.draw LINE2\n";
print "reading.label Reading\n";
print "reading.info Reading\n";
print "reading.draw LINE2\n";
print "writing.label Writing\n";
print "writing.info Writing\n";
print "writing.draw LINE2\n";
print "waiting.label Waiting\n";
print "waiting.info Waiting\n";
print "waiting.draw LINE2\n";
exit 0;
}
#do requests
my $ua = LWP::UserAgent->new(timeout => 10);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
sleep(1);
my $response2 = $ua->request(HTTP::Request->new('GET',$URL));
#calculate responses
$response->content =~ /Active connections:\s+(\d+).*Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/s;
my $a1 = $1;
my $r1 = $2;
my $w1 = $3;
my $wa1 = $4;
my $out1 = $response->content;
$out1 =~ s/\n/ /g;
my @vals = split(/ /, $out1);
my $tmp1_reqpsec=$vals[11];
my $tmp1_conpsec=$vals[10];
$response2->content =~ /Active connections:\s+(\d+).*Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/s;
my $a2 = $1;
my $r2 = $2;
my $w2 = $3;
my $wa2 = $4;
my $out2 = $response2->content;
$out2 =~ s/\n/ /g;
my @vals2 = split(/ /, $out2);
my $tmp2_reqpsec=$vals2[11];
my $tmp2_conpsec=$vals2[10];
my $conpersec=0;
my $reqpcon=0;
my $reqpsec=0;
if (defined $tmp2_conpsec && $tmp2_conpsec =~ /^[+-]?\d+$/ && $tmp2_conpsec > 0){
$conpersec=$tmp2_conpsec-$tmp1_conpsec;
}
if (defined $tmp2_reqpsec && $tmp2_reqpsec =~ /^[+-]?\d+$/ && $tmp2_reqpsec > 0){
$reqpsec=$tmp2_reqpsec-$tmp1_reqpsec;
}
if ($conpersec > 0){
$reqpcon=$reqpsec/$conpersec;
}
print "reqpsec.value $reqpsec\n";
print "conpersec.value $conpersec\n";
printf("reqpcon.value %.2f\n", $reqpcon);
print "total.value $a2\n";
print "reading.value $r2\n";
print "writing.value $w2\n";
print "waiting.value $wa2\n";

View file

@ -0,0 +1,154 @@
#!/usr/bin/perl -w
# -*- mode: cperl; mode: autopair -*-
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
# nginx_connection request --- Determine the requests/connection
# served by nginx.
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
# Author: António P. P. Almeida <appa@perusio.net>
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the sale,
# use or other dealings in this Software without prior written authorization.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
=head1 NAME
nginx_connection_request - Munin plugin to show number of
requests/connection served by nginx.
=encoding utf8
=head1 APPLICABLE SYSTEMS
Any nginx host
=head1 CONFIGURATION
This shows the default configuration of this plugin. You can override
the status URL and User Agent.
[nginx*]
env.url http://localhost/nginx_status
env.ua nginx-status-verifier/0.1
Nginx must also be configured. Firstly the stub-status module must be
compiled, and secondly it must be configured like this:
server {
listen 127.0.0.1;
server_name localhost;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
1.1
=head1 BUGS
None known
=head1 AUTHOR
António Almeida <appa@perusio.net>
=head1 REPOSITORY
Source code at http://github.com/perusio/nginx-munin
=head1 LICENSE
MIT
=cut
my $ret = undef;
if (! eval "require LWP::UserAgent;") {
$ret = "LWP::UserAgent not found";
}
chomp(my $fqdn=`hostname -f`);
## Environment defined variables.
## The default URL is nginx_status if different set it in the environment.
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
## The default user agent is ngnix-status-verifier/0.1 if different
## set it in the environment.
my $UA = exists $ENV{'ua'} ? $ENV{'ua'} : 'nginx-status-verifier/0.1';
## Munin autoconf method.
if (exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
if ($ret) {
print "no ($ret)\n";
exit 1;
}
my $ua = LWP::UserAgent->new(timeout => 30);
# Set the UA to something different from the libwww-perl.
# That UA is blocked.
$ua->agent($UA);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
unless ($response->is_success and $response->content =~ /server/im) {
print "no (no nginx status on $URL)\n";
exit 1;
} else {
print "yes\n";
exit 0;
}
}
## Munin config method.
if (exists $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title nginx requests/connection handled\n";
print "graph_category nginx\n";
print "graph_vlabel Request/Connection\n";
print "connection_request.label requests/connection\n";
print "connection_request.min 0\n";
print "connection_request.draw LINE2\n";
exit 0;
}
my $ua = LWP::UserAgent->new(timeout => 30);
# Set the UA to something different from the libwww-perl.
# That UA is blocked.
$ua->agent($UA);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
if ($response->content =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/m) {
printf("connection_request.value %.2f\n", $3/$2);
} else {
print "connection_request.value U\n";
}

86
plugins/nginx/nginx_memory Executable file
View file

@ -0,0 +1,86 @@
#!/usr/bin/perl -w
# -*- mode: cperl; mode: autopair -*-
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
# nginx_memory --- Munin plugin for monitoring Nginx memory
# usage. Based on the nginx_memory.pl plugin
# by AkyRhO <akyrho@gmail.com>.
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
# Author: António P. P. Almeida <appa@perusio.net>
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the sale,
# use or other dealings in this Software without prior written authorization.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
=head1 NAME
nginx_memory - Munin plugin to show the RAM used by nginx.
=encoding utf8
=head1 APPLICABLE SYSTEMS
Any nginx host
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
1.0
=head1 BUGS
None known
=head1 AUTHOR
Based on a script by AkyRhO <akyrho@gmail.com>. Modified by António
Almeida <appa@perusio.net>
=head1 REPOSITORY
Source code at http://github.com/perusio/nginx-munin
=head1 LICENSE
MIT
=cut
## Munin config method.
if (exists $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title nginx RAM usage\n";
print "graph_vlabel RAM\n";
print "graph_category nginx\n";
print "ram.label RAM\n";
print "graph_args --base 1024\n";
exit 0;
} else {
my $m = `ps u -p \$(pidof nginx) | awk 'NR > 1 {nm += \$5} END {print nm*1024}'`;
print "ram.value $m";
}

158
plugins/nginx/nginx_request Executable file
View file

@ -0,0 +1,158 @@
#!/usr/bin/perl -w
# -*- mode: cperl; mode: autopair -*-
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
# nginx_request --- Determine the current connection rate for
# nginx. Based on a nginx_request plugin by unknown
# author.
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
# Author: António P. P. Almeida <appa@perusio.net>
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the sale,
# use or other dealings in this Software without prior written authorization.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
=head1 NAME
nginx_request - Munin plugin to show number of requests/connection served by nginx.
=encoding utf8
=head1 APPLICABLE SYSTEMS
Any nginx host
=head1 CONFIGURATION
This shows the default configuration of this plugin. You can override
the status URL and User Agent.
[nginx*]
env.url http://localhost/nginx_status
env.ua nginx-status-verifier/0.1
Nginx must also be configured. Firstly the stub-status module must be
compiled, and secondly it must be configured like this:
server {
listen 127.0.0.1;
server_name localhost;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
1.1
=head1 BUGS
None known
=head1 AUTHOR
Unknown. Modified by António Almeida <appa@perusio.net>
=head1 REPOSITORY
Source code at http://github.com/perusio/nginx-munin
=head1 LICENSE
MIT
=cut
my $ret = undef;
if (! eval "require LWP::UserAgent;") {
$ret = "LWP::UserAgent not found";
}
chomp(my $fqdn=`hostname -f`);
## Environment defined variables.
## The default URL is nginx_status if different set it in the environment.
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
## The default user agent is ngnix-status-verifier/0.1 if different
## set it in the environment.
my $UA = exists $ENV{'ua'} ? $ENV{'ua'} : 'nginx-status-verifier/0.1';
if (exists $ARGV[0] and $ARGV[0] eq "autoconf") {
if ($ret) {
print "no ($ret)\n";
exit 1;
}
my $ua = LWP::UserAgent->new(timeout => 30);
# Set the UA to something different from the libwww-perl.
# That UA is blocked.
$ua->agent($UA);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
unless ($response->is_success and $response->content =~ /server/im)
{
print "no (no nginx status on $URL)\n";
exit 1;
} else {
print "yes\n";
exit 0;
}
}
## Munin config method.
if (exists $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title NGINX requests\n";
print "graph_args --base 1000\n";
print "graph_category nginx\n";
print "graph_vlabel Request per second\n";
print "request.label req/sec\n";
print "request.type DERIVE\n";
print "request.min 0\n";
print "request.draw LINE2\n";
exit 0;
}
my $ua = LWP::UserAgent->new(timeout => 30);
# Set the UA to something different from the libwww-perl.
# That UA is blocked.
$ua->agent($UA);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
if ($response->content =~ /^\s+(\d+)\s+(\d+)\s+(\d+)/m) {
print "request.value $3\n";
} else {
print "request.value U\n";
}

178
plugins/nginx/nginx_status Executable file
View file

@ -0,0 +1,178 @@
#!/usr/bin/perl -w
# -*- cperl -*-
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
# nginx_status --- Determine the current status of Nginx
# using the http_stub_status module.
# Copyright (C) 2010 António P. P. Almeida <appa@perusio.net>
# Author: António P. P. Almeida <appa@perusio.net>
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the sale,
# use or other dealings in this Software without prior written authorization.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
=head1 NAME
nginx_status - Munin plugin to show the connection status for nginx
=encoding utf8
=head1 APPLICABLE SYSTEMS
Any nginx host
=head1 CONFIGURATION
This shows the default configuration of this plugin. You can override
the status URL and the User Agent.
[nginx*]
env.url http://localhost/nginx_status
env.ua nginx-status-verifier/0.1
Nginx must also be configured. Firstly the stub-status module must be
compiled, and secondly it must be configured like this:
server {
listen 127.0.0.1;
server_name localhost;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 VERSION
1.1
=head1 BUGS
None known
=head1 AUTHOR
Unknown. Mantained by António Almeida <appa@perusio.net>
=head1 REPOSITORY
Source code at http://github.com/perusio/nginx-munin
=head1 LICENSE
MIT
=cut
my $ret = undef;
if (! eval "require LWP::UserAgent;") {
$ret = "LWP::UserAgent not found";
}
chomp(my $fqdn=`hostname -f`);
## Environment defined variables.
## The default URL is nginx_status if different set it in the environment.
my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://$fqdn/nginx_status";
## The default user agent is ngnix-status-verifier/0.1 if different
## set it in the environment.
my $UA = exists $ENV{'ua'} ? $ENV{'ua'} : 'nginx-status-verifier/0.1';
## Munin autoconf method.
if (exists $ARGV[0] and $ARGV[0] eq "autoconf" ) {
if ($ret) {
print "no ($ret)\n";
exit 1;
}
my $ua = LWP::UserAgent->new(timeout => 30);
# Set the UA to something different from the libwww-perl.
# This UA is blocked.
$ua->agent($UA);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
unless ($response->is_success and $response->content =~ /server/im) {
print "no (no nginx status on $URL)\n";
exit 1;
} else {
print "yes\n";
exit 0;
}
}
## Munin config method.
if (exists $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title NGINX status\n";
print "graph_args --base 1000\n";
print "graph_category nginx\n";
print "graph_vlabel Connections\n";
print "total.label Active connections\n";
print "total.info Active connections\n";
print "total.draw LINE2\n";
print "reading.label Reading\n";
print "reading.info Reading\n";
print "reading.draw LINE2\n";
print "writing.label Writing\n";
print "writing.info Writing\n";
print "writing.draw LINE2\n";
print "waiting.label Waiting\n";
print "waiting.info Waiting\n";
print "waiting.draw LINE2\n";
exit 0;
}
my $ua = LWP::UserAgent->new(timeout => 30);
# Set the UA to something different from the libwww-perl.
# That UA is blocked.
$ua->agent($UA);
my $response = $ua->request(HTTP::Request->new('GET',$URL));
# Active connections: 1845
# server accepts handled requests
# 4566318 4566318 84218236
# Reading: 2 Writing: 278 Waiting: 1565
if ($response->content =~ /Active connections:\s+(\d+).*Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/s) {
print "total.value $1\n";
print "reading.value $2\n";
print "writing.value $3\n";
print "waiting.value $4\n";
} else {
foreach (qw(total reading writing waiting)) {
print "$_.value U\n";
}
}

103
plugins/nginx/nginx_vhost_traffic Executable file
View file

@ -0,0 +1,103 @@
#!/bin/sh
#
# Script for monitoring nginx Virtual host output traffic
#
# Requierements: logtail awk
# one unique access log file with $bytes_sent value for more accuracy
# check http://wiki.nginx.org/NginxHttpLogModule
#
# Configuration Options (all options have defauts)
# [nginx_vhost_traffic]
#
# Virtual host list
# env.vhosts "example.com example.net example.org"
#
# Log path
# env.logdir = /var/log/nginx
# env.flogfile = access.log
#
# Position of the $bytes_sent in the access.log file
# env.bparam 11
#
# Aggregate subdomains
# ex: example.com will match www.example.com, webmail.example.com and *example.com
# BUG: will also match also www.bad-example.com
# env.aggregate true #change to false to disable aggregation
#
# To report bugs, improvements or get updates
# see http://github.com/joanpc/nginix_vhost_traffic
#
# inspired in postfix_filtered_awk
# Copyright (c) 2010, Joan Perez i Cauhe
LOGDIR=${logdir:-/var/log/nginx}
ACCESS_LOG=$LOGDIR/${logfile:-access.log}
LOGTAIL=${logtail:-`which logtail`}
STATEFILE=/var/lib/munin/plugin-state/nginx_vhost_traffic.state
VHOSTS=${vhosts:-`hostname`}
AGGREGATE=${aggregate:true}
BPARAM=${bparam:-11}
case $1 in
config)
DRAW=AREA
echo 'graph_title Nginx Virtual host traffic'
echo 'graph_vlabel bits out / ${graph_period}'
echo 'graph_args --base 1000 -l 0'
echo 'graph_category Nginx'
i=0
for vhost in $VHOSTS
do
i=$(($i + 1))
echo vhost$i.label $vhost
echo vhost$i.type ABSOLUTE
echo vhost$i.cdef vhost$i,8,*
echo vhost$i.draw $DRAW
DRAW=STACK
done
echo rest.label Rest
echo rest.type ABSOLUTE
echo rest.cdef rest,8,*
echo rest.draw STACK
exit 0;;
esac
export BPARAM
export VHOSTS
export AGGREGATE
# Awk Script
$LOGTAIL ${ACCESS_LOG} -o $STATEFILE | awk '
BEGIN {
split(ENVIRON["VHOSTS"], hosts)
for (host in hosts) { track[hosts[host]] = host}
}
{
cn[$2]+=$ENVIRON["BPARAM"]
}
END {
for (host in cn) {
if (match(ENVIRON["AGGREGATE"], "true")) {
found = 0
for (vhost in track) {
if (index(host, vhost)) {
res[vhost] += cn[host]
found = 1
break
}
}
if (! found) rest+=cn[host]
} else {
if (host in track) {
res[host] += cn[host]
} else rest+=cn[host]
}
}
print "agregate: " ENVIRON["AGGREGATE"]
for (vhost in track) print "vhost" track[vhost] ".value " res[vhost]+0
print "rest.value " rest + 0
}'

27
plugins/nginx/ngnix_memory Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env perl
#
# Munin plugin for monitoring Nginx memory usage
#
# Written by AkyRhO <akyrho@gmail.com> - Please e-mail for support/question/request/feedback
#
# Last release (v0.1) 2009-04-20
# Last release (v0.1a) 2009-04-26 - fix the base to 1024
#
# ---
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_title NGINX ram usage\n";
print "graph_vlabel ram\n";
print "graph_category nginx\n";
print "ram.label ram\n";
print "graph_args --base 1024\n";
} else {
my $i = Integer;
@cmd = `ps auwx | grep nginx | grep -v grep | grep -v nginx_memory`;
foreach (@cmd) {
@return = split(/ +/, $_);
$i += @return[5]*1024;
}
print "ram.value ".$i."\n";
}

51
plugins/nginx/php5-fpm_status Executable file
View file

@ -0,0 +1,51 @@
#!/bin/bash
#
# Plugin to monitor php5-fpm process manager, php5-fpm 5.3.3 is required
# 20100726 21:15:39 radar AT aol DOT pl
# modified by Daniel Caillibaud on 20110926
#
# /etc/php5/fpm/php5-fpm.conf:
#
# pm.status_path = /fpm-status
#
#
# Magic markers (optional - only used by munin-config and some installation scripts):
#%# family=contrib
vhost=${0#/etc/munin/plugins/php5-fpm_status_}
url="http://$vhost/fpm-status"
statusfile="/tmp/fpm-status_$vhost.txt"
wget $url -O $statusfile 2>/dev/null
if [ "$1" = "config" ]; then
pool=$(awk '/pool/{print $2}' $statusfile)
echo "graph_title php5-fpm status $pool"
echo "graph_args --base 1000 -l 0"
echo "graph_vlabel Processes"
echo "graph_scale yes"
echo "graph_category nginx"
echo "graph_info This graph shows the php5-fpm process manager status from pool: $pool"
echo "active.label Active processes"
echo "active.type GAUGE"
echo "active.draw AREA"
echo "active.info The number of active processes"
echo "idle.label Idle processes"
echo "idle.type GAUGE"
echo "idle.draw STACK"
echo "idle.info The number of idle processes"
echo "total.label Total processes"
echo "total.type GAUGE"
echo "total.draw LINE2"
echo "total.info The number of idle + active processes"
exit 0
else
awk '
/^idle/ {print "active.value " $3}
/^active/{print "idle.value " $3}
/^total/ {print "total.value " $3}
' < $statusfile
fi
rm -f $statusfile