Ad Widget

Collapse

how to configure JMX monitoring?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alien
    Junior Member
    • Apr 2015
    • 3

    #1

    how to configure JMX monitoring?

    Hello,

    I am doing a POC with Zabbix, version 2.4.4. I got Zabbix Server up and running and installed Zabbix Agent on several hosts. I want to add JMX monitoring too, however I cannot seem to get that working properly. It also seems to be undocumented, largely, so I am looking for some help on the matter.

    I have three JVMs which I want to monitor and have added the JMX part on the classpath. I can telnet to ports, so JMX access is working. It does require credentials.

    I have added the three JMX ports on a host, via the Zabbix Server GUI. I also added that host to "Template JMX Generic". I added to that same template these Macros "{$JMX_PASSWORD}" and "{$JMX_USERNAME}" (exactly as written here, in case that matters).
    Because this didn't seem to work, I also clicked on every "Item" in "Template JMX Generic" and put these values for User Name and Password:
    "{$JMX_USERNAME}" and "{$JMX_PASSWORD}"

    Still it doesn't seem to work and that host, which was working fine without JMX is now coming up as:
    <host> is not reachable

    Thanks!

    Hugo
  • zabb
    Junior Member
    • Oct 2014
    • 5

    #2
    Hi
    It also seems to be undocumented, largely ...
    indeed

    Did you configure the Java Part in zabbix_server.conf and zabbix_java_gateway.conf? Pollers are active and start properly?

    zabb

    Comment

    • Alien
      Junior Member
      • Apr 2015
      • 3

      #3
      Hi,

      Everything that I configured, I wrote down in my initial post.
      I did not configure pollers in "zabbix_server.conf". I did notice the setting, but the comment states that it is only required when using the Java Gateway. I thought that since I am not using that, I should not need to configure the amount of pollers.
      I configured "StartPollers=3" and "StartPollersUnreachable=1". That did not seem to do the trick, however.

      I also need to configure "zabbix_gateway.conf"? That would mean that I do in fact need to configure the "Zabbix Java Gateway", to use JMX? I don't fully understand how the Gateway is supposed to fit into the picture...

      There is one more thing that might be of use. When I connect via JConsole, after providing URL + credentials and pressing "Connect", the screen does transition into the next screen, however it does say "connect failed" mentioning SSL something. I can click on button "insecure" and then I do see the graphs. I did not find any setting for (non-)SSL in Zabbix Server, so I hope that it makes no difference.

      Thanks,

      Hugo

      Comment

      • zabb
        Junior Member
        • Oct 2014
        • 5

        #4
        Hi Hugo,
        I have the same Problem a few month ago and take me some time to get everything working.
        You need JavaGateway cause its an separte deamon. But you can place it on localhost if you want to.
        The JavaGateway ask the JMX interface for data. The JavaPollers pick up these data from gateway so zabbix can use them.

        I configured gateway on localhost:
        JavaGateway=127.0.0.1
        JavaGatewayPort=12345
        StartJavaPollers=5

        After Gateway running you can use zabbix_java_gateway.log for troubleshooting.

        zabb

        Comment

        • Alien
          Junior Member
          • Apr 2015
          • 3

          #5
          works!

          Hi,

          I did as you suggested and it works!

          Thanks a lot!

          Hugo

          Comment

          • Moorthy938
            Junior Member
            • Mar 2016
            • 9

            #6
            How to monitor java process using JMX.

            hi Friends am new for using zabbix

            any one can you tell me how to monitor Java prcess using Jmx from the begining.


            pleaase help me to make it done...

            am waiting for your replay....

            Thank you all

            Comment

            • DmitryL
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • May 2016
              • 278

              #7
              Hello!

              Here is a step by step how to set up zabbix-java-gateway and monitor tomcat using built in template
              Or alternatively just watch a HowTo video about it https://www.youtube.com/watch?v=h6MlF4ztekg&t=9s

              Note that i am doing it on Zabbix 3.0.2 With Centos7

              Frontend
              1) Configuration->Hosts
              You can create a dummy host or just add JMX interface to existing.



              2) Add a template click on Templates tab -> Find "Template JMX Generic" click add and update.

              That's all we need to do in frontend. Now lets continue in backend. In my situation it is VM with Zabbix Server 3.0.2. installed from packages.

              Backend
              1) yum install zabbix-java-gateway
              2) yum install tomcat
              3) edit Tomcat config file /etc/tomcat/tomcat.conf

              Be carefull - one extra space can make lots of problems.
              Code:
              # Run tomcat under the Java Security Manager
              SECURITY_MANAGER="false"
              JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
              4) edit zabbix server config /etc/zabbix/zabbix_server.conf
              Count of JavaPollers on server/proxy side should be atliest same as in zabbix_java_gateway.conf
              Code:
              ### Option: JavaGateway
              #       IP address (or hostname) of Zabbix Java gateway.
              #       Only required if Java pollers are started.
              #
              # Mandatory: no
              # Default:
              # JavaGateway=
              
              JavaGateway=127.0.0.1
              
              ### Option: JavaGatewayPort
              #       Port that Zabbix Java gateway listens on.
              #
              # Mandatory: no
              # Range: 1024-32767
              # Default:
              # JavaGatewayPort=10052
              
              
              ### Option: StartJavaPollers
              #       Number of pre-forked instances of Java pollers.
              #
              # Mandatory: no
              # Range: 0-1000
              # Default:
              # StartJavaPollers=0
              
              StartJavaPollers=5
              SERVICES
              Lets add Tomcat and zabbix-java-gateway to autostart, and start them now.

              systemctl enable tomcat
              systemctl enable zabbix-java-gateway
              systemctl start tomcat
              systemctl start zabbix-java-gateway

              We need to restart zabbix-server, because we changed the config file
              systemctl restart zabbix-server

              Now we should see Some Latest Data in frontend under host with Java template!
              Last edited by DmitryL; 18-09-2018, 09:23.

              Comment

              • Moorthy938
                Junior Member
                • Mar 2016
                • 9

                #8
                Java configuration is working

                Thank you Mr.DIMITRY...

                The java method which you posted here is working....

                this exact one which i am searching is...

                thank you very much..

                Comment

                • Moorthy938
                  Junior Member
                  • Mar 2016
                  • 9

                  #9
                  how can i configure server and agent for jmx monitoring

                  i configure the server properly.


                  but the case is one server and more than 10 clients has been connected with this server.

                  i don't knw i how to configure the zabbix-agent system for get responce from the java.

                  that means single system server can monitor the jmx processes by server itself.

                  when the scenarion wll server and client is in seperate.

                  How to configure it please help me frends.....

                  am waiting for your replies...

                  Comment

                  • Balaraju
                    Member
                    • Jun 2016
                    • 40

                    #10
                    apache tomcat8

                    Hi team,

                    Can you tell me how to monitor the apache tomcat8 service is down and up. I need only that service is up/down. Can we monitor from zabbix. I am using zabbix3.0 and client has apache tomcat8. I need to monitor from zabbix3.0 can any body help with step by step process. because i am very new to zabbix.

                    Comment

                    • maxiesguides
                      Junior Member
                      • Jun 2016
                      • 1

                      #11
                      thanks Dmitryb, exactly what i was looking for

                      Comment

                      • Moorthy938
                        Junior Member
                        • Mar 2016
                        • 9

                        #12
                        reg : JMX Monitoring

                        hi people


                        i did n't find your answer... please try to put the post's link over here..

                        because i didn't find any more tutorials or any other posts for configuring and monitoring java service using JMX agent.

                        am waiting for your replay people.

                        Comment

                        • Balaraju
                          Member
                          • Jun 2016
                          • 40

                          #13
                          how to configure JMX monitoring?

                          While i am adding the tomcat jmx i am getting the below error as screen shot.

                          I want to monitor the tomcat service as up/down. For this i have used net.tcp.service[tomcat8] service but i am not getting any data. We have installed this apache tomcat8 using tar.gz and extracted in /opt/apache-tomcat/bin/.startup.sh


                          Need help how should i follow the process. Can any body tell me
                          Attached Files

                          Comment

                          • Balaraju
                            Member
                            • Jun 2016
                            • 40

                            #14
                            how to configure JMX monitoring?

                            Hi Dmitryb,

                            We have installed apache tomcat8 as tar file and extracted in /opt/ . Can we monitor the using tomcat-jmx tool. If we can monitor how we can monitor the service.

                            Comment

                            • mucknet
                              Member
                              • Dec 2004
                              • 59

                              #15
                              Thank you very much for giving the step by step instructions, this thread was really helpful in getting me started. I was still getting errors though because my java web server had multiple interfaces. Here are my notes for getting setup:



                              * Java gateway sits on same server as zabbix_server - It doesn't have to, but in our case it does.


                              Zabbix Server Config
                              * Configure /opt/zabbix/etc/zabbix_server.conf
                              * * JavaGateway=127.0.0.1
                              * * JavaGateWayPort=10052
                              * * StartJavaPollers=4
                              * Configure /opt/zabbix/sbin/zabbix_java/settings.sh
                              * * LISTEN_PORT=10052
                              * Configure zabbix_java to auto start. I did that by adding it to existing zabbix_server startup script:
                              Code:
                              ZABBIX_JAVA_DIR="/opt/zabbix/sbin/zabbix_java"
                               
                              if [ ! -x ${ZABBIX_BIN} ] ; then
                                      echo -n "${ZABBIX_BIN} not installed! "
                                      # Tell the user this has skipped
                                      exit 5
                              fi
                               
                              start() {
                                      echo -n $"Starting $prog: "
                                      daemon $ZABBIX_BIN
                                      RETVAL=$?
                                      [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zabbix_server
                                      echo
                                  runuser -l zabbix -c "$ZABBIX_JAVA_DIR/startup.sh"
                              }
                               
                              stop() {
                                      echo -n $"Stopping $prog: "
                                      killproc $ZABBIX_BIN
                                      RETVAL=$?
                                      [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zabbix_server
                                      echo
                                  runuser -l zabbix -c "$ZABBIX_JAVA_DIR/shutdown.sh"
                              }
                              Host Config (JVM and Firewall):
                              * If you have Multiple Interfaces on the host, you need to configure the "-Djava.rmi.server.hostname" option, otherwise you get a convoluted and useless "No Route To Host" error.
                              * The hostname you configure, does NOT have to be in /etc/hosts - at least our JDK 6 will use DNS to get the results. Having it in /etc/hosts isn't a bad idea though, if possible.
                              * Firewall Changes:
                              * * For JDK6, you have to allow all ports from your java gateway server (same as zabbix server in this case):
                              * * -A INPUT -m conntrack -i eth2 --ctstate NEW -m tcp -p tcp -s zabbixserver.sub.domain.com -j ACCEPT -m comment --comment "zabbixserver.sub.domain.com"
                              * * For JDK7u4, you can specify an rmi port, and just allow access to that port from your Java Gateway Server
                              * * -A INPUT -m conntrack -i eth2 --ctstate NEW -m tcp -p tcp --match multiport -s zabbixserver.sub.domain.com --dports 22,80,443,10050,10099,10199 -j ACCEPT -m comment --comment "zabbixserver.sub.domain.com"

                              * resin.conf changes - JDK 7 supports specifying RMI port - JDK6 Does not:
                              * This was for a resin server, but the same options should work for any java web server - tomcat, weblogic, etc
                              * * Also note that these settings should be considered insecure, and depending on your environment you should lock down JMX access better than this
                              Code:
                              <jvm-arg>-Dcom.sun.management.jmxremote.port=10099</jvm-arg>
                                    <jvm-arg>-Dcom.sun.management.jmxremote.authenticate=false</jvm-arg>
                                    <jvm-arg>-Dcom.sun.management.jmxremote.ssl=false</jvm-arg>
                                    <jvm-arg>-Djava.rmi.server.hostname=app-server.sub.domain.com</jvm-arg>
                                   <jvm-arg>-Dcom.sun.management.jmxremote.rmi.port=10199</jvm-arg>
                              Zabbix Host UI Config
                              * JMX Interface: Can use IP or Hostname (app-server.sub.domain.com). Hostname needs to match the hostname used in the JVM config (or more accurately they both need to resolve to the same IP address)
                              * Apply JMX Template to Host

                              Search Keywords: zabbix_java.log zabbix_java JMX resin tomcat Java Gateway jconsole No Route To Host Exception Creating connection NoRouteToHostException Host Unreachable

                              Comment

                              Working...