Develope/Programming

[Jolokia] Tomcat + JMX + Jolokia + Telegraf

고로이 2018. 5. 28. 16:02
반응형

제안서 항목의 일환으로 telegraf 와 jolokia 연동을 맡았다.

뭐.. 수정할 여력이 생긴다면 수정하겟드아


*참고 : 졸로키아의 proxy mode 와 agent 모드..... 가 바뀐거같다

근데 아무리봐도

아키텍쳐 설계 그림보면 아닌데.... 두가지 방법이 잇는거같은데 차이점은 알겟는데 뭐가몬지 모르겟다


글이 왜 깨지지?




  1. 설치
    1. Tomcat 설치
      1. tar -xvf apache-tomcat-8.5.31.tar.gz

    2. Jolokia 설치
      1. cd apache-tomcat-8.5.31/webapps
      2. mv jolokia-war-1.2.3.war jolokia.war
      3. mv remotecontent\?filepath\=org%2Fjolokia%2Fjolokia-jvm%2F1.5.0%2Fjolokia-jvm-1.5.0-agent.jar jolokia-jvm-1.5.0-agent.jar



      4. java -jar jolokia-jvm-1.5.0-agent.jar

        [tcore-ic@tcore-ic-test jolokia]$ java -jar jolokia-jvm-1.5.0-agent.jar
            7921   org.apache.zookeeper.server.quorum.QuorumPeerMain /home/tcore-ic/applications/zookeeper/bin/../conf/
            6098   org.apache.catalina.startup.Bootstrap start
            8652   kafka.Kafka config/server.properties
            908   jolokia-jvm-1.5.0-agent.jar
            32287   kafka.tools.ConsoleConsumer --zookeeper tcore-ic-test:2181/kafka --topic telegraf

      5. java -jar jolokia-jvm-1.5.0-agent.jar start catalina
        [tcore-ic@tcore-ic-test jolokia]$ java -jar jolokia-jvm-1.5.0-agent.jar start catalina
            Jolokia is already attached to process matching "catalina" (PID: 6098)
            http://127.0.0.1:8778/jolokia/

    3. Jmx 설정
      3-1. Jmx 변수 설정
          tomcat/bin/catalina.bat
          set CATALINA_OPTS="-Dcom.sun.management.jmxremot -Dcom.sun.management.jmxremote.port=9309 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false”
          혹은
      [tcore-ic@tcore-ic-test bin]$ cat setenv.sh
          export JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9309 -    Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

      3-2. Tomcat 시작
          ./startup

  1. 실행확인
    1. Tomcat 실행확인
    2. Jolokia 실행확인
      [tcore-ic@tcore-ic-test webapps]$ curl http://localhost:8778/jolokia/read/java.lang:type=Memory

      {"request":{"mbean":"java.lang:type=Memory","type":"read"},"value":{"ObjectPendingFinalizationCount":0,"Verbose":false,"HeapMemoryUsage":{"init":513802240,"committed":257949696,"max":7285506048,"used":23310944},"NonHeapMemoryUsage":{"init":2555904,"committed":33210368,"max":-1,"used":31935240},"ObjectName":{"objectName":"java.lang:type=Memory"}},"timestamp":1526876824,"status":200}


  1. Telegraf 설정
    1. vi /etc/telegraf/telegraf.conf
      [[outputs.influxdb]]
        database = "telegraf"

    2. Influx DB 확인
      1. DB 확인
        [root@tcore-ic-test telegraf]# influx
        Connected to http://localhost:8086 version 1.5.2
        InfluxDB shell version: 1.5.2
        > show databases;
            name: databases
            name
            ----
            _internal    
            mon
            telegraf
        > use telegraf    
            Using database telegraf
> show measurements
name: measurements
name
----
cpu
disk
diskio
http
http_response
httpjson
jolokia
kernel
mem
net_response
ping
processes
swap
system
zookeeper
>
>
>
>  show tag keys from jolokia
name: jolokia
tagKey
------
host
jolokia_host
jolokia_name
jolokia_port
>
>
>  show tag values from jolokia with key=host
name: jolokia
key  value
---  -----
host tcore-ic-test
>
>
> show field keys from jolokia
name: jolokia
fieldKey                             fieldType
--------                             ---------
heap_memory_usage_committed          float
heap_memory_usage_init               float
heap_memory_usage_max                float
heap_memory_usage_used               float
thread_count_DaemonThreadCount       float
thread_count_PeakThreadCount         float
thread_count_ThreadCount             float
thread_count_TotalStartedThreadCount float
>
>
> select host, heap_memory_usage_max, heap_memory_usage_used, thread_count_DaemonThreadCount from jolokia limit 10;
name: jolokia

    



반응형