Package: munin-node
Version: 1.4.5-3
Severity: wishlist
Tags: patch

Currently the Perl-based tomcat_{access,threads,volume} plugins can only
monitor the http-connector they themselves connect through. This makes
it impossible to for example monitor AJP connectors and such. The
attached patch makes this configurable, keeping the same default as
before.

The Ruby-based tomcat_ plugin can probably do this already, but I'd
rather not install Ruby on all of my Tomcat running servers..

-- 
Arto Jantunen

diff -ur munin-1.4.5.orig/plugins/node.d/tomcat_access.in munin-1.4.5/plugins/node.d/tomcat_access.in
--- munin-1.4.5.orig/plugins/node.d/tomcat_access.in	2012-03-23 11:25:27.224933948 +0200
+++ munin-1.4.5/plugins/node.d/tomcat_access.in	2012-03-23 11:26:41.651101573 +0200
@@ -10,11 +10,12 @@
 
 The following environment variables are used by this plugin
 
- timeout  - Connection timeout
- url      - Override default status-url
- ports    - HTTP port numbers
- user     - Manager username
- password - Manager password
+ timeout   - Connection timeout
+ url       - Override default status-url
+ ports     - HTTP port numbers
+ user      - Manager username
+ password  - Manager password
+ connector - Override connector to monitor
 
 =head1 USAGE
 
@@ -63,11 +64,12 @@
     $ret .= "XML::Simple not found";
 } 
 
-my $URL      = exists $ENV{'url'}      ? $ENV{'url'}      : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true";;
-my $PORT     = exists $ENV{'ports'}    ? $ENV{'ports'}    : 8080;
-my $USER     = exists $ENV{'user'}     ? $ENV{'user'}     : "munin";
-my $PASSWORD = exists $ENV{'password'} ? $ENV{'password'} : "munin";
-my $TIMEOUT  = exists $ENV{'timeout'}  ? $ENV{'timeout'}  : 30;
+my $URL       = exists $ENV{'url'}       ? $ENV{'url'}       : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true";;
+my $PORT      = exists $ENV{'ports'}     ? $ENV{'ports'}     : 8080;
+my $USER      = exists $ENV{'user'}      ? $ENV{'user'}      : "munin";
+my $PASSWORD  = exists $ENV{'password'}  ? $ENV{'password'}  : "munin";
+my $CONNECTOR = exists $ENV{'connector'} ? $ENV{'connector'} : 'http-'.$PORT;
+my $TIMEOUT   = exists $ENV{'timeout'}   ? $ENV{'timeout'}   : 30;
 
 my $url = sprintf $URL, $USER, $PASSWORD, $PORT;
 
@@ -105,8 +107,8 @@
 my %options = ( KeyAttr => { connector => 'name' }, ForceArray => 1 );
 my $xml = $xs->XMLin($response->content, %options);
 
-if($xml->{'connector'}->{'http-'.$PORT}->{'requestInfo'}->[0]->{'requestCount'}) {
-    print "accesses.value " . $xml->{'connector'}->{'http-'.$PORT}->{'requestInfo'}->[0]->{'requestCount'} . "\n";
+if($xml->{'connector'}->{$CONNECTOR}->{'requestInfo'}->[0]->{'requestCount'}) {
+    print "accesses.value " . $xml->{'connector'}->{$CONNECTOR}->{'requestInfo'}->[0]->{'requestCount'} . "\n";
 } else {
     print "accesses.value U\n";
 }
diff -ur munin-1.4.5.orig/plugins/node.d/tomcat_threads.in munin-1.4.5/plugins/node.d/tomcat_threads.in
--- munin-1.4.5.orig/plugins/node.d/tomcat_threads.in	2012-03-23 11:25:27.228934050 +0200
+++ munin-1.4.5/plugins/node.d/tomcat_threads.in	2012-03-23 11:26:41.651101573 +0200
@@ -11,11 +11,12 @@
 
 Configurable variables
 
- timeout  - Connection timeout
- url      - Override default status-url
- ports    - HTTP port numbers
- user     - Manager username
- password - Manager password
+ timeout   - Connection timeout
+ url       - Override default status-url
+ ports     - HTTP port numbers
+ user      - Manager username
+ password  - Manager password
+ connector - Override connector to monitor
 
 =head1 USAGE
 
@@ -62,11 +63,12 @@
     $ret .= "XML::Simple not found";
 } 
 
-my $URL      = exists $ENV{'url'}      ? $ENV{'url'}      : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true";;
-my $PORT     = exists $ENV{'ports'}    ? $ENV{'ports'}    : 8080;
-my $USER     = exists $ENV{'user'}     ? $ENV{'user'}     : "munin";
-my $PASSWORD = exists $ENV{'password'} ? $ENV{'password'} : "munin";
-my $TIMEOUT  = exists $ENV{'timeout'}  ? $ENV{'timeout'}  : 30;
+my $URL       = exists $ENV{'url'}       ? $ENV{'url'}       : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true";;
+my $PORT      = exists $ENV{'ports'}     ? $ENV{'ports'}     : 8080;
+my $USER      = exists $ENV{'user'}      ? $ENV{'user'}      : "munin";
+my $PASSWORD  = exists $ENV{'password'}  ? $ENV{'password'}  : "munin";
+my $CONNECTOR = exists $ENV{'connector'} ? $ENV{'connector'} : 'http-'.$PORT;
+my $TIMEOUT   = exists $ENV{'timeout'}   ? $ENV{'timeout'}   : 30;
 
 my $url = sprintf $URL, $USER, $PASSWORD, $PORT;
 
@@ -106,12 +108,12 @@
 my %options = ( KeyAttr => { connector => 'name' }, ForceArray => 1 );
 my $xml = $xs->XMLin($response->content, %options);
 
-if($xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadsBusy'} &&
-    $xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadCount'}) {
-    print "busy.value " . $xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadsBusy'} . "\n";
+if($xml->{'connector'}->{$CONNECTOR}->{'threadInfo'}->[0]->{'currentThreadsBusy'} &&
+    $xml->{'connector'}->{$CONNECTOR}->{'threadInfo'}->[0]->{'currentThreadCount'}) {
+    print "busy.value " . $xml->{'connector'}->{$CONNECTOR}->{'threadInfo'}->[0]->{'currentThreadsBusy'} . "\n";
     print "idle.value " .
-	  ($xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadCount'} -
-	  $xml->{'connector'}->{'http-'.$PORT}->{'threadInfo'}->[0]->{'currentThreadsBusy'}) . "\n";
+	  ($xml->{'connector'}->{$CONNECTOR}->{'threadInfo'}->[0]->{'currentThreadCount'} -
+	  $xml->{'connector'}->{$CONNECTOR}->{'threadInfo'}->[0]->{'currentThreadsBusy'}) . "\n";
 } else {
     print "busy.value U\n";
     print "idle.value U\n";
diff -ur munin-1.4.5.orig/plugins/node.d/tomcat_volume.in munin-1.4.5/plugins/node.d/tomcat_volume.in
--- munin-1.4.5.orig/plugins/node.d/tomcat_volume.in	2012-03-23 11:25:27.224933948 +0200
+++ munin-1.4.5/plugins/node.d/tomcat_volume.in	2012-03-23 11:26:41.651101573 +0200
@@ -37,9 +37,10 @@
 =head2 CONFIGURATION EXAMPLE
 
  [tomcat_volume]
-  env.ports    8081
-  env.user     someuser
-  env.password somepassword
+  env.ports     8081
+  env.user      someuser
+  env.password  somepassword
+  env.connector http-8081
 
 =head1 AUTHOR
 
@@ -83,11 +84,12 @@
     $ret .= "XML::Simple not found";
 } 
 
-my $URL      = exists $ENV{'url'}      ? $ENV{'url'}      : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true";;
-my $PORT     = exists $ENV{'ports'}    ? $ENV{'ports'}    : 8080;
-my $USER     = exists $ENV{'user'}     ? $ENV{'user'}     : "munin";
-my $PASSWORD = exists $ENV{'password'} ? $ENV{'password'} : "munin";
-my $TIMEOUT  = exists $ENV{'timeout'}  ? $ENV{'timeout'}  : 30;
+my $URL       = exists $ENV{'url'}       ? $ENV{'url'}       : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true";;
+my $PORT      = exists $ENV{'ports'}     ? $ENV{'ports'}     : 8080;
+my $USER      = exists $ENV{'user'}      ? $ENV{'user'}      : "munin";
+my $PASSWORD  = exists $ENV{'password'}  ? $ENV{'password'}  : "munin";
+my $CONNECTOR = exists $ENV{'connector'} ? $ENV{'connector'} : 'http-'.$PORT;
+my $TIMEOUT   = exists $ENV{'timeout'}   ? $ENV{'timeout'}   : 30;
 
 my $url = sprintf $URL, $USER, $PASSWORD, $PORT;
 
@@ -126,8 +128,8 @@
 my $xml = $xs->XMLin($response->content, %options);
 
 
-if($xml->{'connector'}->{'http-'.$PORT}->{'requestInfo'}->[0]->{'bytesSent'}) {
-    print "volume.value " . $xml->{'connector'}->{'http-'.$PORT}->{'requestInfo'}->[0]->{'bytesSent'} . "\n";
+if($xml->{'connector'}->{$CONNECTOR}->{'requestInfo'}->[0]->{'bytesSent'}) {
+    print "volume.value " . $xml->{'connector'}->{$CONNECTOR}->{'requestInfo'}->[0]->{'bytesSent'} . "\n";
 } else {
     print "volume.value U\n";
 }

Reply via email to