Ad Widget

Collapse

issue java with zabbix 2

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    issue java with zabbix 2

    I need help in Tomcat monitoring. I have referred the Zabbix Manual for JMX thing. But still i'm facing issue with Tomcat monitoring with zabbix 2.0.

    Here are zabbix details -
    zabbix 2.0.3
    zabbix agent 2.0.3

    zabbix server port - 10051
    zabbix agent port - 10050

    JMX port - 8889

    Configuration Details are:-

    1) In my tomcat environment, I have enabled the jmx setting for the jvm as below:

    JAVA_OPTS="${JAVA_OPTS} -Djavax.sql.DataSource.Factory=org.apache.commons.d bcp.BasicDataSourceFactory -Xms512m -Xmx512m -Dcom.sun.management.jmxremote.port=8889 -Dcom.sun.management.jmxremote.password.file=$CATAL INA_BASE/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=$CATALIN A_BASE/conf/jmxremote.access -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.1.22"

    2) from zabbix frontend, created items for JMX monitoring and also created trigerrs and graphs-
    Tomcat Heap Memory jmx["java.lang:type=Memory","HeapMemoryUsage.used"]
    Tomcat http-8080 threads allocated jmx[Catalina:type=ThreadPool,name=http-8080][currentThreadCount]
    Tomcat http-8080 threads busy jmx[Catalina:type=ThreadPool,name=http-8080][currentThreadsBusy]
    Tomcat http-8080 threads max jmx[Catalina:type=ThreadPool,name=http-8080][maxThreads]
    Tomcat http-8443 threads allocated jmx[Catalina:type=ThreadPool,name=http-8443][currentThreadCount]
    Tomcat http-8443 threads busy jmx[Catalina:type=ThreadPool,name=http-8443][currentThreadsBusy]
    Tomcat http-8443 threads max jmx[Catalina:type=ThreadPool,name=http-8443][maxThreads]
    Tomcat jk-8009 threads allocated jmx[Catalina:type=ThreadPool,name=jk-8009][currentThreadCount]
    Tomcat jk-8009 threads busy jmx[Catalina:type=ThreadPool,name=jk-8009][currentThreadsBusy]
    Tomcat jk-8009 threads max jmx[Catalina:type=ThreadPool,name=jk-8009][maxThreads] 30

    3) All the items and triggers are enabled and showing green.
    4) from zabbix server logs, i see some of the below messages:-

    item [tomcat:jmx[Catalina:type=ThreadPool,name=http-8080][currentThreadCount]] became not supported: Not supported by Zabbix Agent
    item [tomcat:jmx[Catalina:type=ThreadPool,name=http-8080][currentThreadsBusy]] became not supported: Not supported by Zabbix Agent
    item [tomcat:jmx[Catalina:type=ThreadPool,name=http-8080][maxThreads]] became not supported: Not supported by Zabbix Agent
    5) Also i tried with zabbix_get on command prompt and get below result -
    zabbix_get -s 192.168.1.22 -k jmx["java.lang:type=Memory","HeapMemoryUsage.used"]
    ZBX_NOTSUPPORTED

    Please let me know what steps i should take to resolve this issue. Your esteem help is required.

    Thanks.

    #2
    You need several things to make the java monitoring work, since you didn't give all the details, I'll start from the beginning :

    1/ Zabbix.gateway.JavaGateway must be running on the Zabbix server
    2/ On you host definition, you need to set the "JMX interfaces" with the correct IP/DNS and the correct JMX port (in your case 8889)
    3/ ON your tomcat server, in JAVA_OPTS or CATALINA_OPTS, you need :

    Code:
    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.port=8889
    -Dcom.sun.management.jmxremote.ssl=false
    -Dcom.sun.management.jmxremote.authenticate=true
    -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password 
    -Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access
    Not sure but you had a space in the word "CATALINA", maybe double check that ?

    4/ In your item definition, make sure you have the following :

    Code:
    Type = JMX agent
    key = a working bean (see bellow how to check)
    User name =  a user defined in your file jmxremote.password with correct access in jmxremote.access
    Password = your correct password for the user
    5/ Finally, you need to find some working beans you want to monitor and test them before creating the items. You cannot do that with zabbix_get since zabbix_get don't use the Zabbix Java Gateway. I'm using jmxterm to do that, for example :

    Code:
    [email protected]:~# java -jar jmxterm-1.0-alpha-4-uber.jar
    Welcome to JMX terminal. Type "help" for available commands.
    $>open -u xxxxxxxxx -p xxxxxxxxxx example.com:8889
    #Connection to example.com:8889 is opened
    $>domains
    #following domains are available
    Catalina
    JMImplementation
    Users
    com.sun.management
    java.lang
    java.nio
    java.util.logging
    logback
    org.apache.derby
    org.dozer.jmx
    I let you look at the documentation to see how to get the exact string for a bean. BTW, be very careful for beans containing ", you must use \" else zabbix won't understand them, bellow are some example of my current items for Tomcat 7 :

    Code:
    jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",maxThreads]
    jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadsBusy]
    jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadCount]
    jmx["Catalina:type=Server",serverInfo]
    jmx["Catalina:type=ProtocolHandler,port=8080",compression]
    Hope this help.

    Comment


      #3
      By the way, almost forgot but you need either to add in /etc/hosts a line with the IP/name that you'll be using in Zabbix to monitor the JMX :

      192.168.0.100 your.server.dns.name.where.the.jmx.remote.runs

      Or you can :

      -Djava.rmi.server.hostname=hostname as JMX parameter in client resolved my issue.
      According to pradhanparas in http://www.zabbix.com/forum/showthread.php?t=36436 .

      Comment


        #4
        Originally posted by Slash View Post
        You need several things to make the java monitoring work, since you didn't give all the details, I'll start from the beginning :

        1/ Zabbix.gateway.JavaGateway must be running on the Zabbix server
        2/ On you host definition, you need to set the "JMX interfaces" with the correct IP/DNS and the correct JMX port (in your case 8889)
        3/ ON your tomcat server, in JAVA_OPTS or CATALINA_OPTS, you need :

        Code:
        -Dcom.sun.management.jmxremote
        -Dcom.sun.management.jmxremote.port=8889
        -Dcom.sun.management.jmxremote.ssl=false
        -Dcom.sun.management.jmxremote.authenticate=true
        -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password 
        -Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access
        Not sure but you had a space in the word "CATALINA", maybe double check that ?

        4/ In your item definition, make sure you have the following :

        Code:
        Type = JMX agent
        key = a working bean (see bellow how to check)
        User name =  a user defined in your file jmxremote.password with correct access in jmxremote.access
        Password = your correct password for the user
        5/ Finally, you need to find some working beans you want to monitor and test them before creating the items. You cannot do that with zabbix_get since zabbix_get don't use the Zabbix Java Gateway. I'm using jmxterm to do that, for example :

        Code:
        [email protected]:~# java -jar jmxterm-1.0-alpha-4-uber.jar
        Welcome to JMX terminal. Type "help" for available commands.
        $>open -u xxxxxxxxx -p xxxxxxxxxx example.com:8889
        #Connection to example.com:8889 is opened
        $>domains
        #following domains are available
        Catalina
        JMImplementation
        Users
        com.sun.management
        java.lang
        java.nio
        java.util.logging
        logback
        org.apache.derby
        org.dozer.jmx
        I let you look at the documentation to see how to get the exact string for a bean. BTW, be very careful for beans containing ", you must use \" else zabbix won't understand them, bellow are some example of my current items for Tomcat 7 :

        Code:
        jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",maxThreads]
        jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadsBusy]
        jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadCount]
        jmx["Catalina:type=Server",serverInfo]
        jmx["Catalina:type=ProtocolHandler,port=8080",compression]
        Hope this help.
        Thanks! I almost have the same problem.

        Comment


          #5
          Originally posted by Slash View Post
          You need several things to make the java monitoring work, since you didn't give all the details, I'll start from the beginning :

          1/ Zabbix.gateway.JavaGateway must be running on the Zabbix server
          2/ On you host definition, you need to set the "JMX interfaces" with the correct IP/DNS and the correct JMX port (in your case 8889)
          3/ ON your tomcat server, in JAVA_OPTS or CATALINA_OPTS, you need :

          Code:
          -Dcom.sun.management.jmxremote
          -Dcom.sun.management.jmxremote.port=8889
          -Dcom.sun.management.jmxremote.ssl=false
          -Dcom.sun.management.jmxremote.authenticate=true
          -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password 
          -Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access
          Not sure but you had a space in the word "CATALINA", maybe double check that ?

          4/ In your item definition, make sure you have the following :

          Code:
          Type = JMX agent
          key = a working bean (see bellow how to check)
          User name =  a user defined in your file jmxremote.password with correct access in jmxremote.access
          Password = your correct password for the user
          5/ Finally, you need to find some working beans you want to monitor and test them before creating the items. You cannot do that with zabbix_get since zabbix_get don't use the Zabbix Java Gateway. I'm using jmxterm to do that, for example :

          Code:
          [email protected]:~# java -jar jmxterm-1.0-alpha-4-uber.jar
          Welcome to JMX terminal. Type "help" for available commands.
          $>open -u xxxxxxxxx -p xxxxxxxxxx example.com:8889
          #Connection to example.com:8889 is opened
          $>domains
          #following domains are available
          Catalina
          JMImplementation
          Users
          com.sun.management
          java.lang
          java.nio
          java.util.logging
          logback
          org.apache.derby
          org.dozer.jmx
          I let you look at the documentation to see how to get the exact string for a bean. BTW, be very careful for beans containing ", you must use \" else zabbix won't understand them, bellow are some example of my current items for Tomcat 7 :

          Code:
          jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",maxThreads]
          jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadsBusy]
          jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadCount]
          jmx["Catalina:type=Server",serverInfo]
          jmx["Catalina:type=ProtocolHandler,port=8080",compression]
          Hope this help.
          This solution is great! Good!

          Comment


            #6
            how to create the jmx item?

            hello Slash,
            thank you for your detailed answer about this issue,
            I added the following line in zabbix_agentd.conf
            UserParameter=ajp-apr-8080 currentThreadsBusy,jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadsBusy]
            but I got a error in zabbix_agentd.log,said:
            [COLOR="black"][COLOR="black"]cannot add user parameter "ajp-apr-8080 currentThreadsBusy,jmx["Catalina:type=ThreadPool,name=\"http-bio-8080\"",currentThreadsBusy]": syntax error
            when I use the following command,I can get the right result
            java -jar cmdline-jmxclient-0.10.3.jar - 133.133.134.97:12345 Catalina:type=ThreadPool,name=\"http-bio-8080\" currentThreadsBusy
            01/25/2015 15:48:09 +0800 org.archive.jmx.Client currentThreadsBusy: 0
            java -jar cmdline-jmxclient-0.10.3.jar - 133.133.134.97:12345 Catalina:type=ThreadPool,name=\"http-bio-8080\" maxThreads
            01/25/2015 15:47:42 +0800 org.archive.jmx.Client maxThreads: 200
            waiting for your help,many thanks to you!

            Comment


              #7
              Hello gzy,

              The java monitoring doesn't use any userparameters, it uses the Zabbix Java Gateway to leverage the JMX interface from your target JVM.

              So you don't have to create any user parameters, but a template with the correct items.

              Bellow is an example of a parameter to monitor the current usage of the metaspace (notice the item type "JMX agent):

              Comment


                #8
                Thank you , Slash

                Thank you , Slash . I resolved the poblem just now by you help.
                Now I am trying to monitor hadoop through zabbix, I think this time I need to use UserParameter. But when I use hadoop-monitor.conf which contains
                UserParameter=DFSUsed,/usr/local/zabbix2.2.8/etc/zabbix_agentd.conf.d/OnceMonAgent/bin/startup.sh
                in my customize conf, the zabbix frontend show me the DFSUsed item is not supported ,do you have any good idea?
                when I execute
                /usr/local/zabbix2.2.8/etc/zabbix_agentd.conf.d/OnceMonAgent/bin/startup.sh
                I get what I want.
                I hava Include=/usr/local/zabbix2.2.8/etc/zabbix_agentd.conf.d/ in my zabbix_agentd.conf, and hadoop-monitor.conf in zabbix_agentd.conf.d

                Comment

                Announcement

                Collapse
                No announcement yet.
                Working...
                X