r4034 - trunk/varnish-tools/munin

kristian at projects.linpro.no kristian at projects.linpro.no
Fri Apr 17 14:27:33 CEST 2009


Author: kristian
Date: 2009-04-17 14:27:32 +0200 (Fri, 17 Apr 2009)
New Revision: 4034

Modified:
   trunk/varnish-tools/munin/varnish_
Log:
POD-documentation + config for the munin-plugin

Modified: trunk/varnish-tools/munin/varnish_
===================================================================
--- trunk/varnish-tools/munin/varnish_	2009-04-14 10:27:42 UTC (rev 4033)
+++ trunk/varnish-tools/munin/varnish_	2009-04-17 12:27:32 UTC (rev 4034)
@@ -18,28 +18,72 @@
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-##########
-# Parameteres: 
-#	
-#	config (required)
-#	autoconf (optional - used by munin-conf)
-#	suggest (optional - used by munin-conf to determine valid symlinks)
-#
-# A few aspects are not linked by default. They are marked as 
-# 'DEBUG' => 'yes' (or any other value). They are:
-#
-# data_structures, vcl_and_purges, lru, objects_per_objhead,
-# obj_sendfile_vs_write, losthdr, esi, hcb, shm, shm_writes, overflow,
-# session, session_herd
-#
-# You can link them yourself with something like this:
-# ln -s /foo/varnish_ /etc/munin/plugins/varnish_data_structures
-#
-# Magic markers: Optional but should be included.
-#%# family=auto
-#%# capabilities=autoconf suggest
 
+=head1 NAME
+
+varnish_ - Munin plugin to monitor various aspects of varnish
+
+=head1 APPLICABLE SYSTEMS
+
+Varnish 2.0 or newer with varnishstat
+
+=head1 CONFIGURATION
+
+The plugin needs to be able to execute varnishstat. 
+
+The configuration section shows the defaults
+  [varnish_*]
+     env.varnishstat varnishstat
+     env.name 
+
+env.varnishstat can be a full path to varnishstat if it's
+not in the path already. 
+
+env.name is blank (undefined) by default and can be used to specify a -l
+name argument to varnish if multiple instances are running on the same
+server.
+
+A few aspects are not linked by default. They are marked as 
+'DEBUG' => 'yes' (or any other value). They are:
+
+data_structures, vcl_and_purges, lru, objects_per_objhead,
+obj_sendfile_vs_write, losthdr, esi, hcb, shm, shm_writes, overflow,
+session, session_herd
+
+You can link them yourself with something like this:
+ln -s /foo/varnish_ /etc/munin/plugins/varnish_data_structures
+
+=head1 INTERPERTATION
+
+Each graph uses data from varnishstat.
+
+=head1 MAGIC MARKERS
+
+ #%# family=auto
+ #%# capabilities=autoconf suggest
+
+=head1 VERSION
+
+ $Id$
+
+=head1 BUGS
+
+The hit_rate graph requires munin r2040 or newer to display
+correctly.
+
+=head1 AUTHOR
+
+Kristian Lyngstol <kristian at redpill-linpro.com>
+
+=head1 LICENSE
+
+GPLv2
+
+=cut 
+
+# FIXME: License?
+
+
 use strict;
 
 # Set to 1 to enable output when a variable is defined in a graph but
@@ -50,8 +94,11 @@
 my $FULL_SUGGEST = 0;
 
 # Varnishstat executable. Include full path if it's not in your path.
-my $varnishstat = "varnishstat";
+my $varnishstatexec = exists $ENV{'varnishstat'} ? $ENV{'varnishstat'} : "varnishstat";
 
+# For multiple instances
+my $varnishname = exists $ENV{'name'} ? $ENV{'name'} : undef;
+
 my %varnishstat = ();
 my %varnishstatnames = ();
 my $self; # Haha, myself, what a clever pun.
@@ -593,7 +640,11 @@
 # descriptions.
 sub populate_stats
 {
-	foreach my $line (`$varnishstat -1`) {
+	my $arg = "-1";
+	if ($varnishname) {
+		$arg .= " -l $varnishname";
+	} 
+	foreach my $line (`$varnishstatexec $arg`) {
 		chomp($line);
 		if ($line =~ /^([^ ]*)\s+(\d+)\s+(\d*\.\d*)\s+(.*)$/) {
 			$varnishstat{"$1"} = $2;
@@ -617,8 +668,8 @@
 # Otherwise exit with false and a human-readable reason.
 sub autoconf
 {
-	if (`which $varnishstat` eq '') {
-		print "no (which $varnishstat returns blank)\n";
+	if (`which $varnishstatexec` eq '') {
+		print "no (which $varnishstatexec returns blank)\n";
 		exit 1;
 	}
 	print "yes\n";



More information about the varnish-commit mailing list