My Tomcat access graphs for munin had stopped logging data and I set out to find out why it isn’t working anymore. After some debugging, I concluded it must have been because of AJP/APR/libtcnative-1 changes I did just recently (oh don’t we all love these silly abbreviations and cryptic package names…)
I log server stats with Munin-Node, I even have some custom made plugins to monitor a few changing numbers like cable modem Signal-to-Noise ratio, number of people online on a remote website etc. It’s really simple.
The script I am using can be found originally, on Ubuntu, in /usr/share/munin/plugins/tomcat_access . Okay, so I don’t actually use the default plugin as is, because it’s pretty broken on a mod_jk configuration with Apache 2.2 in front of Tomcat. Conventional method is to make a symbolic link of that script into /etc/munin/plugins/ but instead I copied the original and made some custom modifications. I once made the mistake of modifying the original file and lost all my customizations when I did a system upgrade. Please everyone, don’t make the same mistake!
I’ve added the following environment parameter into the script:
my $CONN = exists $ENV{'connector'}? $ENV{'connector'} : 'jk-80';
In the munin-node configuration file /etc/munin/plugins/munin-node I have
[tomcat_*]
env.url "http://%s:%s@example.com/manager/status?XML=true"
env.port 80
env.user secret
env.password something
env.timeout 20
env.connector jk-8109
The jk-8109 had changed into ajp-8109. After changing the parameter, munin can read the Tomcat status servlet variables again.
Oh, and in order to use the $CONN parameter, I have this
if($xml->{'connector'}->{$CONN}->{'requestInfo'}->{'requestCount'}) {
print "accesses.value " . $xml->{'connector'}->{$CONN}->{'requestInfo'}->{'requestCount'} . "\n";
} else {
print "accesses.value U\n";
}
Now… this current AJP connector solution is far from optimal, I think I will have to drop it for now.
When I have 1 GB of logs in less than an hour for crap like this:
Dec 3, 2009 1:10:32 PM org.apache.tomcat.util.net.AprEndpoint$Acceptor run
SEVERE: Socket accept failed
org.apache.tomcat.jni.Error: Too many open files
at org.apache.tomcat.jni.Socket.accept(Native Method)
at org.apache.tomcat.util.net.AprEndpoint$Acceptor.run(AprEndpoint.java:1110)
at java.lang.Thread.run(Thread.java:717)
…it makes me want to return to the old configuration. *sigh* At least without the native connector, errors weren’t logged too fast.

Recent Comments