zoukankan      html  css  js  c++  java
  • zabbix 监控tomcat

    <pre name="code" class="html"><pre name="code" class="html">zabbix 服务端安装,监控jmx 需要--enable-java
    
    ./configure -sysconfdir=/etc/zabbix/  -enable-server -enable-agent -with-net-snmp -with-libcurl -with-mysql --enable-java
    
    make && make install
    
    #此处指定sysconfdir配置文件的路径就在/etc/zabbix/目录下了,如果不指定默认在/usr/local/etc下
    
    10、Copyzabbixserver端跟agent端的启动脚本,并设置执行权限
    
    cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
    
    cp misc/init.d/tru64/zabbix_server /etc/init.d/
    
    chmod +x /etc/init.d/zabbix_*
    
    
    
    2.zabbix_server端安装jdk
    
    安装jdk
    
    [root@nginx tmp]# tar xf jdk-7u9-linux-x64.tar.gz -C /usr/local/
    [root@nginx tmp]# ls /usr/local/jdk1.7.0_09/
    bin        jre      README.html                         THIRDPARTYLICENSEREADME.txt
    COPYRIGHT  lib      release
    db         LICENSE  src.zip
    include    man      THIRDPARTYLICENSEREADME-JAVAFX.txt
    
    3.修改zabbix_java相关选项
    
    然后进入到下面的目录下面进行seeting.sh脚本编辑
    
    zabbix:/usr/local/sbin/zabbix_java# pwd
    /usr/local/sbin/zabbix_java
    zabbix:/usr/local/sbin/zabbix_java# ls
    bin  lib  settings.sh  shutdown.sh  startup.sh
    
     LISTEN_IP="0.0.0.0"
    LISTEN_PORT=10052
    PID_FILE="/tmp/zabbix_java.pid"
    START_POLLERS=5
    
    
    zabbix:/usr/local/sbin/zabbix_java# ./startup.sh 
    -------------------
    5
    zabbix:/usr/local/sbin/zabbix_java# cat startup.sh 
    #!/bin/bash
    
    cd $(dirname $0)
    source settings.sh
    echo "-------------------"
    echo $START_POLLERS
                      
    
    
    其中 LISTEN_PORT 和 LISTEN_IP 可以不配置,zabbix_java 会采用默认值。但是 PID_FILE 和 START_POLLERS 必须配置,尤其主意 START_POLLERS,若不配置 zabbix_java 依旧可以启动但是是不工作的。
    
    [root@nginx zabbix_java]#
    
    4.修改配置选项:在zabbix服务端上配置
    /etc/zabbix/zabbix_server.conf
    
    添加:
    JavaGateway=127.0.0.1  ##这个地址是服务端的地址
    JavaGatewayPort=10052
    StartJavaPollers=5
    
    zabbix:/usr/local/sbin/zabbix_java# netstat -nap | grep 10052
    tcp        0      0 127.0.0.1:54229             127.0.0.1:10052             TIME_WAIT   -                   
    tcp        0      0 127.0.0.1:53891             127.0.0.1:10052             TIME_WAIT   -                   
    tcp        0      0 :::10052                    :::*                        LISTEN      15763/java          
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:54499      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:54149      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:54128      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:53930      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:54207      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:53610      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:53641      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:53590      TIME_WAIT   -                   
    tcp        0      0 ::ffff:127.0.0.1:10052      ::ffff:127.0.0.1:54184      TIME_WAIT   -                   
    zabbix:/usr/local/sbin/zabbix_java# ps -ef | grep 15763
    root     15763     1  3 09:38 pts/0    00:00:01 java -server -classpath lib:lib/logback-classic-0.9.27.jar:lib/logback-core-0.9.27.jar:lib/org-json-2010-12-28.jar:lib/slf4j-api-1.6.1.jar:bin/zabbix-java-gateway-2.2.2.jar
     -Dzabbix.pidFile=/tmp/zabbix_java.pid -Dzabbix.listenIP=0.0.0.0 -Dzabbix.listenPort=10052 -Dzabbix.startPollers=5 com.zabbix.gateway.JavaGateway
    root     15804 14315  0 09:39 pts/0    00:00:00 grep 15763
    5.启动zabbix_java
    
    找到zabbix_java目录路径,然后执行命令./startup.sh
    
    [root@nginx zabbix-2.2.0]# find / -name zabbix_java
    /usr/local/sbin/zabbix_java
    
    
    
    6.调整tomcat端,安装catalina-jmx-remote.jar
    
    wget  http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/extras/catalina-jmx-remote.jar
    
    
    [tomcat@wx01 lib]$ mv /home/tomcat/catalina-jmx-remote.jar .
    [tomcat@wx01 lib]$ ls -ltr  catalina-jmx-remote.jar
    -rw-rw-r-- 1 tomcat tomcat 9533 Feb  5  2011 catalina-jmx-remote.jar
    
    
    
    7.修改catalina.sh文件
    
    修改catalina.sh文件,添加
    
    
    # -----------------------------------------------------------------------------
    CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=5555"
    
    5555端口自定义,自定义端口号
    
    
    [tomcat@wx01 bin]$ netstat -na | grep 5555
    tcp        0      0 0.0.0.0:5555                0.0.0.0:*                   LISTEN  
    
    8.重启启动tomcat服务和zabbix_agentd服务
    
    9.zabbix服务器端测试是否能正常获取信息
    zabbix:/root/zabbix-2.2.2/src/zabbix_java#  java -jar /root/cmdline-jmxclient-0.10.3.jar  - 120.55.118.32:5555 java.lang:type=Memory NonHeapMemoryUsage
    09/28/2015 15:48:16 +0800 org.archive.jmx.Client NonHeapMemoryUsage: 
    committed: 50921472
    init: 2555904
    max: -1
    used: 48782432
    
    
    
    120.55.118.32:5555 客户端地址:端口
    
    <img src="https://img-blog.csdn.net/20150928165932472?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
    
    注意zabbix 默认模板有问题,取不到数据
    
    
    
    参考:
    http://lovelace.blog.51cto.com/1028430/1424964/
    
    
    
    
    
    
    
    
    
    
    
    


    
    
    
    
    
    
    
                                        
    
  • 相关阅读:
    Mysql常用函数总结(二)
    mysql百万的数据快速创建索引
    php 中的sprintf 坑
    php5.5之后新特性整理
    mysql实践总结
    php下载远程图片到本地
    搜藏一个php文件上传类
    Attribute基本介绍
    Fiddler4抓包工具使用教程一
    HTTP传输数据压缩
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351362.html
Copyright © 2011-2022 走看看