アイビスヘッダー

IBS
ラベル tomcat の投稿を表示しています。 すべての投稿を表示
ラベル tomcat の投稿を表示しています。 すべての投稿を表示

2012年2月1日水曜日

munin で tomcat7 監視設定

CentOS6.2(x86_64) +  tomcat7.0.25 + munin-node1.4.6(epel) の環境です。

tomcat設定
$TOMCAT_HOME/conf/tomcat-users.xml に2行追加

<role rolename="manager-status"/>
<user username="munin" password="munin" roles="manager-status"/>


munin-node設定
/etc/munin/plugin-conf.d/tomcat ファイルを作成

[tomcat_*]
env.host 127.0.0.1
env.port 8080
env.request /manager/status?XML=true
env.user munin
env.password munin
env.timeout 30
env.connector jk-8009


リンクをはる
# ln -s /usr/share/munin/plugins/tomcat_* /etc/munin/plugins/


確認
# /usr/share/munin/plugins/tomcat_access autoconf
# curl http://munin:munin@127.0.0.1:8080/manager/status?XML=true


必須パッケージに、perl-XML-Simpleが必要なところではまりましたが
/usr/share/munin/plugins/tomcat_access autoconf が教えてくれました。

pluginファイルがそのままでは、tomcat7では利用できませんので編集します。
/etc/munin/plugins/tomcat_access

if($xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'requestInfo'}->[0]->{'requestCount'}) {
    print "accesses.value " . $xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'requestInfo'}->[0]->{'requestCount'} . "\n";
} else {
    print "accesses.value U\n";
}

/etc/munin/plugins/tomcat_threads

if($xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'threadInfo'}->[0]->{'currentThreadsBusy'} &&
    $xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'threadInfo'}->[0]->{'currentThreadCount'}) {
    print "busy.value " . $xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'threadInfo'}->[0]->{'currentThreadsBusy'} . "\n";
    print "idle.value " .
          ($xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'threadInfo'}->[0]->{'currentThreadCount'} -
          $xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'threadInfo'}->[0]->{'currentThreadsBusy'}) . "\n";
} else {
    print "busy.value U\n";
    print "idle.value U\n";
}

/etc/munin/plugins/tomcat-volume

if($xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'requestInfo'}->[0]->{'bytesSent'}) {
    print "volume.value " . $xml->{'connector'}->{'"http-bio-'.$PORT.'"'}->{'requestInfo'}->[0]->{'bytesSent'} . "\n";
} else {
    print "volume.value U\n";
}

変更内容としては、tomcat6までは connector name が
'http-8080'
で返ってきてたんですが、tomcat7からは
'"http-bio-8080"'
で返ってくるので、それに対応することです。

後は、tomcatの再起動と、munin-nodeの再起動で完成です。

2011年1月11日火曜日

JSESSIONID と jsessionid について

Tomcat6のセッション管理を確認すると、URLには大文字で「JSESSIONID」と表示されていて、cookieには小文字で「jsessionid」と記録されています。

ApacheのProxyPassでバランサーの設定を行った場合、上記は別のものとみなされます。

cookieを無効にしているブラウザや、携帯電話からアクセスされる場合には、両方に対応する設定が必要です。

下記の記述により、問題が無いことを確認しました。

ProxyPass / balancer://test/ lbmethod=byrequests nofailover=Off maxattempts=1 stickysession=JSESSIONID|jsessionid