标签:coding mem nmp sed 3.0 sof username 属性 tomcat服务
以前做过通过jmx监控单个tomcat实例,但是有的时候公司一台服务器上有10个tomcat容器那怎么办呢,来吧往下看吧1,注意操作文件路径:
zabbix安装路径; /data/zabbix/etc/zabbix_agentd.conf.d/jmx_discovery.sh
/etc/zabbix/zabbix_agentd.conf 配置文件中 UnsafeUserParameters=1 必须打开,否则模板的自动发现功能报错。
该模板的监控和触发属性在自动发现中配置,所以导入模板后,下属的监控项和触发器等都为空。需要等一会儿,数据等还会出来。
操作步骤:
1、上传 catalina-jmx-remote.jar,cmdline-jmxclient-0.10.3.jar到 /lib下jmx_discovery.sh 和 add_service_tomcat.sh 到 /data/zabbix/etc/zabbix_agentd.conf.d/目录下
2、给 add_service_tomcat.sh 赋执行权限,并执行
3、zabbix服务端对主机添加模版
脚本说明:
add_service_tomcat.sh
#!/bin/bash
#因为lunix版本的及命令格式等问题,上面两句不一定能得到正确路径,所以用下面两句替换上面两行,各自改下你们安装tomcat的路径即可。
t_datadir=`find /data/tomcat*/bin/ -name catalina.sh|awk -F "/bin/catalina.sh" '{print $1}'`
tomcat_no=`find /data/tomcat*/bin/ -name catalina.sh|awk -F "/bin/catalina.sh" '{print $1}'|wc -l`
n_port=9999 #配置监控初始端口
local_ip=`ifconfig em4 |awk -F '[ :]+' 'NR==2 {print $4}'` #提取主机IP
for tomcat in $t_datadir
do
m_no=`cat -n $tomcat/bin/catalina.sh|grep 'Execute The Requested Command'|awk '{print $1}'` #提取代码插入位置
cp $tomcat/bin/catalina.sh $tomcat/bin/catalina.sh_bak #备份catalina.sh
#cp /tmp/catalina-jmx-remote.jar $tomcat/lib/catalina-jmx-remote.jar #复制文件到实例lib目录
sed -i ''$m_no'a export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote"' $tomcat/bin/catalina.sh #插入监控配置
let "m_no=m_no+1" #设置行号
sed -i ''$m_no'a export CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname='$local_ip'"' $tomcat/bin/catalina.sh #插入监控配置
let "m_no=m_no+1" #设置行号
sed -i ''$m_no'a export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port='$n_port'"' $tomcat/bin/catalina.sh #插入监控配置
let "m_no=m_no+1" #设置行号
sed -i ''$m_no'a export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false"' $tomcat/bin/catalina.sh #插入监控配置
let "m_no=m_no+1" #设置行号
sed -i ''$m_no'a export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"' $tomcat/bin/catalina.sh #插入监控配置
let "n_port=n_port+1"
done
local_ip=`ifconfig em4 |awk -F '[ :]+' 'NR==2 {print $4}'` #提取主机IP
cat >> /data/zabbix/zabbix_agentd.conf.d/tomcat.conf <<END #修改zabbix_agentd.conf,添加KEY
UserParameter=java.jmx.discovery[*],/data/zabbix/etc/zabbix_agentd.conf.d/jmx_discovery.sh
UserParameter=java.Runtime.status[*],java -jar /lib/cmdline-jmxclient-0.10.3.jar - $local_ip:\$1 java.lang:type=Runtime \$2 2>&1 |grep \$2 |awk '{print \$NF}'
UserParameter=java.Memory.status[*],java -jar /lib/cmdline-jmxclient-0.10.3.jar - $local_ip:\$1 java.lang:type=Memory \$2 2>&1 |grep \$2 |awk '{print \$NF}'
UserParameter=java.System.status[*],java -jar /lib/cmdline-jmxclient-0.10.3.jar - $local_ip:\$1 java.lang:type=OperatingSystem \$2 2>&1 |grep \$2 |awk '{print \$NF}'
UserParameter=java.HeapMemoryUsage.status[*],java -jar /lib/cmdline-jmxclient-0.10.3.jar - $local_ip:\$1 java.lang:type=Memory HeapMemoryUsage 2>&1 |grep \$2 |awk '{print \$NF}'
UserParameter=java.NonHeapMemoryUsage.status[*],java -jar /lib/cmdline-jmxclient-0.10.3.jar - $local_ip:\$1 java.lang:type=Memory NonHeapMemoryUsage 2>&1 |grep \$2 |awk '{print \$NF}'
UserParameter=java.LoadClass.status[*],java -jar /lib/cmdline-jmxclient-0.10.3.jar - $local_ip:\$1 java.lang:type=ClassLoading \$2 2>&1 |awk '{print \$NF}'
UserParameter=java.Threading.status[*],java -jar /lib/cmdline-jmxclient-0.10.3.jar - $local_ip:\$1 java.lang:type=Threading \$2 2>&1 |awk '{print \$NF}'
END
chmod +x /data/zabbix/etc/zabbix_agentd.conf.d/jmx_discovery.sh 然后执行脚本
jmx_discovery.sh:
#!/bin/bash
#因为lunix版本的及命令格式等问题,上面两句不一定能得到正确路径,所以用下面两句替换上面两行,各自改下你们安装tomcat的路径即可。
t_datadir=`find /data/tomcat*/bin/ -name catalina.sh|awk -F "/bin/catalina.sh" '{print $1}'`
tomcat_no=`find /data/tomcat*/bin/ -name catalina.sh|awk -F "/bin/catalina.sh" '{print $1}'|wc -l`
n_port=9999 #配置监控初始端口
i=1
printf '{"data":[\n'
for tomcat in $t_datadir #输出JSON文件
do
t_service=`echo "$tomcat"|awk -F"/" '{print $(NF)}'`
if [ "$i" != ${tomcat_no} ];then
printf "\t\t{ \n"
printf "\t\t\t\"{#JMX_PORT}\":\"${n_port}\",\n"
printf "\t\t\t\"{#JAVA_NAME}\":\"${t_service}\"},\n"
else
printf "\t\t{ \n"
printf "\t\t\t\"{#JMX_PORT}\":\"${n_port}\",\n"
printf "\t\t\t\"{#JAVA_NAME}\":\"${t_service}\"}]}\n"
fi
let "n_port=n_port+1"
let "i=i+1"
done
tomcat监控模板如下:
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>3.0</version>
<date>2016-06-08T01:26:24Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>Template for Tomcat</template>
<name>Template for Tomcat</name>
<description/>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
<application>
<name>Tomcat_类</name>
</application>
<application>
<name>Tomcat_系统</name>
</application>
<application>
<name>Tomcat_线程</name>
</application>
<application>
<name>Tomcat_运行时间</name>
</application>
</applications>
<items/>
<discovery_rules>
<discovery_rule>
<name>Tomcat Server</name>
<type>0</type>
<snmp_community/>
<snmp_oid/>
<key>java.jmx.discovery</key>
<delay>30</delay>
<status>0</status>
<allowed_hosts/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<delay_flex/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<filter>
<evaltype>0</evaltype>
<formula/>
<conditions>
<condition>
<macro>{#JMX_PORT}</macro>
<value/>
<operator>8</operator>
<formulaid>A</formulaid>
</condition>
</conditions>
</filter>
<lifetime>30</lifetime>
<description>发现查找tomcat服务</description>
<item_prototypes>
<item_prototype>
<name>{#JAVA_NAME} 堆内存提交值:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.HeapMemoryUsage.status[{#JMX_PORT},committed]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>java提交内存</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 堆内存最大值:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.HeapMemoryUsage.status[{#JMX_PORT},max]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>java最大使用内存</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 堆内存使用值:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.HeapMemoryUsage.status[{#JMX_PORT},used]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>java使用内存</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 已加装当前类的数量:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.LoadClass.status[{#JMX_PORT},LoadedClassCount]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>加载的类</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_类</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 已加载类总数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.LoadClass.status[{#JMX_PORT},TotalLoadedClassCount]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>总共加载过的类个数</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_类</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 已卸载类的数量:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.LoadClass.status[{#JMX_PORT},UnloadedClassCount]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>卸载回收类个数</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_类</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 被挂起的对象的计数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Memory.status[{#JMX_PORT},ObjectPendingFinalizationCount]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 非堆内存提交值:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.NonHeapMemoryUsage.status[{#JMX_PORT},committed]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>堆内存提交大小</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 非堆内存最大值:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.NonHeapMemoryUsage.status[{#JMX_PORT},max]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>堆内存最大值</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 非堆内存使用值:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.NonHeapMemoryUsage.status[{#JMX_PORT},used]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>B</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>堆内存使用大小</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_内存</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} JVM启动时间:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Runtime.status[{#JMX_PORT},Uptime]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>uptime</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_运行时间</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} JVM名称:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Runtime.status[{#JMX_PORT},VmName]</key>
<delay>30</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>4</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_运行时间</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} JVM版本:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Runtime.status[{#JMX_PORT},VmVersion]</key>
<delay>60</delay>
<history>7</history>
<trends>0</trends>
<status>0</status>
<value_type>1</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_运行时间</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 系统可打开最大打开文件数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.System.status[{#JMX_PORT},MaxFileDescriptorCount]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_系统</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 系统应用当前打开文件数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.System.status[{#JMX_PORT},OpenFileDescriptorCount]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_系统</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 系统平均负载:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.System.status[{#JMX_PORT},SystemLoadAverage]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>0</value_type>
<allowed_hosts/>
<units>%</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_系统</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 守护程序线程数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Threading.status[{#JMX_PORT},DaemonThreadCount]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_线程</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 线程峰值数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Threading.status[{#JMX_PORT},PeakThreadCount]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>活动线程峰值个数</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_线程</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 活动线程计数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Threading.status[{#JMX_PORT},ThreadCount]</key>
<delay>60</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>运行tomcat的活动线程</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_线程</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
<item_prototype>
<name>{#JAVA_NAME} 启动的线程总数:</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>java.Threading.status[{#JMX_PORT},TotalStartedThreadCount]</key>
<delay>30</delay>
<history>7</history>
<trends>30</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description>线程总个数</description>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Tomcat_线程</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<application_prototypes/>
</item_prototype>
</item_prototypes>
<trigger_prototypes>
<trigger_prototype>
<expression>{Template for Tomcat:java.HeapMemoryUsage.status[{#JMX_PORT},used].last()}>({Template for Tomcat:java.HeapMemoryUsage.status[{#JMX_PORT},max].last()}*0.7)</expression>
<name>{#JAVA_NAME} 堆内存使用率超过70%</name>
<url/>
<status>0</status>
<priority>1</priority>
<description/>
<type>0</type>
<dependencies/>
</trigger_prototype>
<trigger_prototype>
<expression>{Template for Tomcat:java.HeapMemoryUsage.status[{#JMX_PORT},committed].last()}={Template for Tomcat:java.HeapMemoryUsage.status[{#JMX_PORT},max].last()}</expression>
<name>{#JAVA_NAME} 堆内存提交值达到最大限制.</name>
<url/>
<status>1</status>
<priority>1</priority>
<description/>
<type>0</type>
<dependencies/>
</trigger_prototype>
<trigger_prototype>
<expression>{Template for Tomcat:java.System.status[{#JMX_PORT},SystemLoadAverage].last()}>50</expression>
<name>{#JAVA_NAME} 当前应用占用系统负载大于50%</name>
<url/>
<status>0</status>
<priority>1</priority>
<description/>
<type>0</type>
<dependencies/>
</trigger_prototype>
<trigger_prototype>
<expression>{Template for Tomcat:java.System.status[{#JMX_PORT},OpenFileDescriptorCount].last()}>({Template for Tomcat:java.System.status[{#JMX_PORT},MaxFileDescriptorCount].last()}*0.7)</expression>
<name>{#JAVA_NAME} 当前应用打开文件数已占用系统最大70%</name>
<url/>
<status>0</status>
<priority>1</priority>
<description/>
<type>0</type>
<dependencies/>
</trigger_prototype>
<trigger_prototype>
<expression>{Template for Tomcat:java.NonHeapMemoryUsage.status[{#JMX_PORT},used].last()}>({Template for Tomcat:java.NonHeapMemoryUsage.status[{#JMX_PORT},max].last()}*0.7)</expression>
<name>{#JAVA_NAME} 非堆内存使用率超过70%</name>
<url/>
<status>0</status>
<priority>1</priority>
<description/>
<type>0</type>
<dependencies/>
</trigger_prototype>
</trigger_prototypes>
<graph_prototypes>
<graph_prototype>
<name>堆对象内存状态:{#JAVA_NAME}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>00C800</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.HeapMemoryUsage.status[{#JMX_PORT},committed]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>0</drawtype>
<color>C80000</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.HeapMemoryUsage.status[{#JMX_PORT},max]</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<drawtype>0</drawtype>
<color>0000C8</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.HeapMemoryUsage.status[{#JMX_PORT},used]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
<graph_prototype>
<name>类状态:{#JAVA_NAME}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>00C800</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.LoadClass.status[{#JMX_PORT},UnloadedClassCount]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>0</drawtype>
<color>C80000</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.LoadClass.status[{#JMX_PORT},LoadedClassCount]</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<drawtype>0</drawtype>
<color>0000C8</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.LoadClass.status[{#JMX_PORT},TotalLoadedClassCount]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
<graph_prototype>
<name>系统打开文件系统数:{#JAVA_NAME}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>1A7C11</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.System.status[{#JMX_PORT},MaxFileDescriptorCount]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>0</drawtype>
<color>F63100</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.System.status[{#JMX_PORT},OpenFileDescriptorCount]</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<drawtype>0</drawtype>
<color>2774A4</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.System.status[{#JMX_PORT},SystemLoadAverage]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
<graph_prototype>
<name>线程状态:{#JAVA_NAME}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>00C800</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.Threading.status[{#JMX_PORT},ThreadCount]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>0</drawtype>
<color>C80000</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.Threading.status[{#JMX_PORT},PeakThreadCount]</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<drawtype>0</drawtype>
<color>0000C8</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.Threading.status[{#JMX_PORT},TotalStartedThreadCount]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
<graph_prototype>
<name>非堆对象内存状态:{#JAVA_NAME}</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>0</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>1A7C11</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.NonHeapMemoryUsage.status[{#JMX_PORT},used]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>0</drawtype>
<color>F63100</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.NonHeapMemoryUsage.status[{#JMX_PORT},committed]</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<drawtype>0</drawtype>
<color>2774A4</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>Template for Tomcat</host>
<key>java.NonHeapMemoryUsage.status[{#JMX_PORT},max]</key>
</item>
</graph_item>
</graph_items>
</graph_prototype>
</graph_prototypes>
<host_prototypes/>
</discovery_rule>
</discovery_rules>
<macros/>
<templates/>
<screens/>
</template>
</templates>
</zabbix_export>
然后等5分钟左右,一主机N实例监控tomcat完成,拿走不谢!注意根据实际路径修改!name:系统运维工程师 李超!
标签:coding mem nmp sed 3.0 sof username 属性 tomcat服务
原文地址:http://blog.51cto.com/13120271/2070640