Cacti监控Tomcatserver实现过程
1 首先去官网上面下载通用的监控模板
一般使用TomcatStats-0.1.zip 模板居多,下载地址:
http://forums.cacti.net/download/file.php?id=12310,
在linuxserver上面使用wget下载,wget http://forums.cacti.net/download/file.php?id=12310,报例如以下错误:
正在连接 forums.cacti.net|173.225.179.10|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:http://forums.cacti.net/ [尾随至新的 URL]
已超过 20 次重定向。
能够在windows7的google浏览器上输入http://forums.cacti.net/download/file.php?id=12310点击回车下载,然后通过SecureFX客户端工具scp到linuxserver上就可以。
然后解压缩得到3个文件cacti_host_template_tomcat_server.xml,INSTALL.txt,tomcatstats.pl 3个文件。
2 在cacti主server的网址上面导入模板
打开cactiserver的网址:
进入http://10.xx.1.xx/cacti/index.php->Console –> Templates -> Import Templates ,选择文件导入(cacti_host_template_tomcat_server.xml)文件,选择Importbutton载入tomcat模板。

3 cactiserver端载入tomcatstats.pl统计脚本
将解压缩TomcatStats-0.1.zip 得到的tomcatstats.pl 放到/var/www/html/cacti/scritps 文件夹下,而且赋予运行权限
Chown –R apache.apache tomcatstats.pl
chmod 755 tomcatstats.pl
改动tomcatstats.pl,大概第20行,将
1. my $xml = `GET $url`;
改动为
1. my $xml = `wget -qO - $url`;
不然在你导入之后非常可能出现数据出不来。
Check URL连接是否正确
Vim tomcatstats.pl 后,在第17行后面加入print $url,在控制台打出url,例如以下所看到的:
my $url = "http://$username:$password"."\@$host/manager/status?XML=true";
print $url;
print “ ”;
然后用perl来check下统计脚本,例如以下:
[root@squid-2 scripts]# perl tomcatstats.pl 10.xx.3.xx:9444 'tomcat' '9ssspw ' http-9444
http://tomcat:tomcat0401@10.xx.3.xx:9444/manager/status?XML=true jvm_memory_free:2925944104 jvm_memory_max:3892314112 jvm_memory_total:3892314112 connector_max_time:131 connector_error_count:4464 connector_bytes_sent:19559190 connector_processing_time:11552 connector_request_count:8931 connector_bytes_received:0 connector_current_thread_count:4 connector_min_spare_threads: connector_max_threads:150 connector_max_spare_threads: connector_current_threads_busy:1
也能够在windows7的google浏览器里面,输入上面URL,也会出现非常多tomcat的统计信息,例如以下所看到的:

4 改动cacti中tomcat获取数据的url地址
进入cacti---> console ---> Data Input Methods --->Tomcat Status
改动Input String 中字段
改动为:perl <path_cacti>/scripts/tomcatstats.pl <hostname>:8080 tomcat 9ssspw http-8080
注意:替换上面的username 和password 为实际的tomcat 管理员账号和密码。
要开启tomcat 的manager 管理员账号 附件内有Enable the Tomcat manager application 介绍,例如以下图:

5 web端tomcatserver的配置调整
在tomcat/conf/server.xml 里面加入例如以下:
<Service name="Admin">
<Connector port="9444" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
<Engine name="Admin" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps"
unpackWARs="false" autoDeploy="false"
xmlValidation="false" xmlNamespaceAware="false">
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs" prefix="admin_access_log." suffix=".txt"
pattern="combined" resolveHosts="false"
fileDateFormat="yyy-MM-dd"/>
<Context path="/manager" cookies="false"
docBase="server/webapps/manager" debug="0"
privileged="true" reloadable="false" />
</Host>
</Engine>
</Service>
然后在tomcat/conf/tomcat-users.xml里面 加入
<role rolename="manager-gui"/>
<user username="tomcat" password="9ssspw " roles="manager-gui"/>
passwords 为连接密码 可自行更改,然后重新启动tomcat 服务
去cactiserver端运行perl tomcatstats.pl 10.xx.3.xx:9444 'tomcat' '9ssspw ' http-9444 check统计脚本能否取到tomcat的数据,有数据即正常,例如以下所看到的:
[root@squid-2 scripts]# /usr/bin/perl tomcatstats.pl 10.xx.3.xx:9444 'tomcat' 'xxx’ http-9444
http://tomcat:tomcat0401@10.254.3.29:9444/manager/status?XML=true jvm_memory_free:3409129096 jvm_memory_max:3892314112 jvm_memory_total:3892314112 connector_max_time:131 connector_error_count:2 connector_bytes_sent:20241 connector_processing_time:168 connector_request_count:5 connector_bytes_received:0 connector_current_thread_count:4 connector_min_spare_threads: connector_max_threads:150 connector_max_spare_threads: connector_current_threads_busy:1
[root@squid-2 scripts]#
记录debug期间的报错信息例如以下:
[root@squid-2 scripts]# perl tomcatstats.pl 10.xx.3.xx:9300 admin 9ssspw http-9300
Can't locate XML/Simple.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at tomcatstats.pl line 7.
BEGIN failed--compilation aborted at tomcatstats.pl line 7.
须要安装XML::Simple
[root@squid-2 ~]# find / -name cpan
/usr/bin/cpan
[root@squid-2 ~]# /usr/bin/cpan XML::Simple
……
Prepending /root/.cpan/build/XML-Simple-2.20-7zpaOY/blib/arch /root/.cpan/build/XML-Simple-2.20-7zpaOY/blib/lib to PERL5LIB for 'install'
Installing /usr/local/share/perl5/XML/Simple.pm
Installing /usr/local/share/perl5/XML/Simple/FAQ.pod
Installing /usr/local/share/man/man3/XML::Simple.3pm
Installing /usr/local/share/man/man3/XML::Simple::FAQ.3pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
GRANTM/XML-Simple-2.20.tar.gz
/usr/bin/make install -- OK
Warning (usually harmless): 'YAML' not installed, will not store persistent state
继续报错File does not exist: at tomcatstats.pl line 20
[root@squid-2 scripts]# /usr/bin/perl tomcatstats.pl 10.254.3.29:9300 tomcat xxx http-9300
File does not exist: at tomcatstats.pl line 20
须要安装例如以下组件:
[root@squid-2 scripts]#yum install perl-HTML-Parser.i386 perl-HTML-Tagset.noarch perl-libwww-perl.noarch perl-URI.noarch
之后启动tomcat报错例如以下:
[tomcat@web-9 logs]$ cat catalina.out
2014-6-6 15:11:15 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/jdk1.6.0_45/jre/lib/amd64/server:/usr/java/jdk1.6.0_45/jre/lib/amd64:/usr/java/jdk1.6.0_45/jre/../lib/amd64:/usr/local/lib::/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2014-6-6 15:11:16 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'debug' to '0' did not find a matching property.
跟踪后发现是连接池的配置问题:
<Context path="/n" docBase="server/webapps/manager " debug="0" reloadable="true" crossContext="false">
把debug="0"去除就可以。
分析:tomcat的6.0.37这个版本号中可能用别的属性替代了debug功能。
6 Cacti监控tomcat的选项
Graph templates,总共就4个选项,例如以下:

点击监控项连接进去,看到RRDTool Says: ERROR: invalid y-grid format报错信息,
解决的方法是:
进右上角的连接*Edit Graph Template --> Tomcat - Connection Rate --> Unit Grid Value (--unit/--y-grid),默认的值为1,去掉改成为0就可以。
同理解决Tomcat - Heap Statistics 不出图的问题 将1048576 值改空就可以。
之后假设10分钟内还是出不了图,那么能够继续等待,tomcat监控模板出图时间比較漫长,我这里等待了3个小时候后,图出来了,例如以下所看到的:
1) Tomcat - Connection Rate :连接效率

2) Tomcat - Heap Statistics : JVM堆得使用情况

3) Tomcat - Thread Statistics :线程状态

4) Tomcat – Throughput :Tomcat吞吐量

Cacti监控Tomcatserver实现过程的更多相关文章
- Cacti监控MySQL实现过程中碰到的问题解汇总
前言:cacti监控mysql服务器的大概50张graphs都弄出来了,也出图了,当中遇到一些问题,印象比較深刻的记录例如以下: (一):加入io监控 点击Create Graphs for this ...
- Cacti监控Redis实现过程
Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监測图形分析工具.被广泛的用于对server的运维监控中,Cacti提供了一种插件式的管理.仅仅要按要求写好特定的模板,那 ...
- Cacti监控mysql数据库服务器实现过程
Cacti监控mysql数据库服务器实现过程 2014-05-29 0个评论 来源:Cacti监控mysql数据库服务器实现过程 收藏 我要投稿 1 先在cacti服务器端安 ...
- cacti监控windows服务器
参考文献: 通过Cacti监控windows资源 前提条件 一.已安装好Cacti:ubuntu下cacti安装配置 二.准备好以下安装文件: Cacti_SNMP_ ...
- Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)
Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建) 具体案例:局域网内有两台主机,一台Linux.一台Windows,现在需要配置一台Cacti监控服务器对这两台 ...
- cacti监控
cacti监控 cacti简介 Cacti是一套基于php,mysql,snmp及rrdtool开发的网络流量监测图形分析工具.它通过snmpget获取数据,使用rrdtool绘画图形 Cacti轮询 ...
- cacti监控juniper路由器
之前也没有写过博客,但是最近一直在做监控.从网上查找很多资料都还是感觉差一点.所以自己添加一份我在cacti监控路由器的步骤. 环境,ubuntu14.04,apt-get install cacti ...
- cacti监控mysql
cacti监控mysql 2013-09-25 16:21:43 分类: LINUX 原文地址:cacti监控mysql 作者:baochenggood cacti监控mysql 1 下载cacti监 ...
- Cacti监控Windows主机,Windows主机的正确配置
使用cacti监控Windows主机的时候经常遇到无法获取Windows主机的snmp信息和Windows主机的硬件信息,主要原因是Windows主机没有正确配置snmp,以下是正确的配置步骤:1.安 ...
随机推荐
- Usaco 1.3.2 修理牛棚(Barn Repair)
Barn Repair 题意:在一个夜黑风高,下着暴风雨的夜晚,农民约翰的牛棚的屋顶.门被吹飞了. 好在许多牛正在度假,所以牛棚没有住满. 剩下的牛一个紧挨着另一个被排成一行来过夜. 有些牛棚里有 ...
- js之checkbox的代码全选/全不选,使用id获取元素,而不是name
每当有多个选项的时候,都会有一种想法是:全选,全不选,如果子选项有被选,父选项也得被选. 注意:这里是根据id来获取元素的,但是不能直接用getElementById,因为那只能返回一个,而不是集合. ...
- 设置程序版本等信息(可直接修改pro文件设置,但是更推荐使用rc文件设置)
Qt版本:5.2.0 在.pro文件中设置版本等信息 VERSION = 1.2.3 QMAKE_TARGET_PRODUCT = 产品名称QMAKE_TARGET_COMPANY = 公司QMAKE ...
- python 循环中的else
众多语言中都有if else这对条件选择组合,但是在python中还有更多else使用的地方,比如说循环for,或者while都可以和else组合. 下面简单介绍一下for-else while-el ...
- 关于iptables的u32匹配
前面一篇文章----阐释了iptables最新的bpf match,说它将多个matches并成了一个经过编译的解释型bytecode bpf match,早在bpf match之前,u32 matc ...
- csdn发博文验证码缺陷
csdn验证码的长处: 一,差点儿没有浪费人脑人力,却要花去机器人非常多cpu csdn发博文验证码却有非常大缺陷: 一.验证码的内容终于结果是简单的数字,能够穷举尽的,也就是说不怕被封号的话全然能够 ...
- POJ 1160 Post Office (动态规划)
Post Office Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 15412 Accepted: 8351 Desc ...
- 【从cocos2d-x学习设计模式】第一阶段:辛格尔顿
设计模式,它总结了前辈在许多方案重用代码.它是一个想法. 因为我们爱cocos2d-x,然后我们从去cocos2d-x在设计模式中,右一起学习!本篇解释未来辛格尔顿. 提cocos2d-x中间Dire ...
- [面经] 南京SAP面试(上)
背景 博主乃985弱校的小硕一枚,在南京某外企工作了两年,如今的公司还不错,待遇还行,做的东西也比較有意思.在南京这个地方,给力的公司不太多,仅仅要是跟亲戚朋友聊到我在南京做IT,无一例外都会问&qu ...
- 找工作笔试面试那些事儿(8)---常问的CC++基础题
这一部分是C/C++程序员在面试的时候会被问到的一些题目的汇总.来源于基本笔试面试书籍,可能有一部分题比较老,但是这也算是基础中的基础,就归纳归纳放上来了.大牛们看到一笑而过就好,普通人看看要是能补上 ...