将使用jmx4perl和jolokia
1.把一个WAR agent 安装到一个新的Tomcat环境
下载 Jolokia WAR-agent 拷贝它到Tomcat的webapp 目录 $ cd /usr/local/tomcat6/webapps $ wget http://repo1.maven.org/maven2/org/jolokia/jolokia-war/1.2.3/jolokia-war-1.2.3.war $ mv jolokia-war-1.2.3.war jolokia.war
这时应该能访问http://localhost:8080/jolokia/了2. Install Jmx4Perl 安装Jmx4Perl
$ perl -MCPAN -e shell Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.9205) ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?) cpan[1]> install JMX::Jmx4Perl ... ... jmx4perl ======== jmx4perl is a command line utility for accessing Jolokia agents (www.jolokia.org). It can be used for script based exploration and easy inspection of the JMX space. Install 'jmx4perl' ? (y/n) [y ]3. 安装完了后可以使用直接使用check_jmx4perl --url http://192.168.67.130:8080/jolokia --name heap_memory_used --mbean java.lang:type=Memory --attribute HeapMemoryUsage --path used
命令路径在/usr/local/bin中
4. su - shinken
shinken install tomcat
>在/etc/shinken/packs中会有tomcat了,在其中的commands.cfg中修改command_line 中的路径为/usr/local/bin/check_jmx4perl
并修改其中的$HOSTNAME$为$HOSTADDRESS$(感觉这是个bug,不修改会影响下一步,涉及到host中的address而不是host_name,好不好!!!!!)
>/etc/shinken/packs中的macros.cfg中的$JOLOKIAPATH$看看是不是你装的jolokia名字
5. 在hosts中添加新的host.cfg或者是在已有的host.cfg中的use添加.
define host{
use generic-host,linux-snmp,tomcat-host
host_name host2
address
192.168.67.130
contact_groups admins
}
6.systemctl restart shinken重启看看吧