Monitoring multiple java processes on the same host via SNMP

心不动则不痛 提交于 2019-12-09 19:25:47

问题


I want to monitor JVM's via SNMP on Linux machine that run multiple java processes, each java process of course is independent and has different SNMP counters (num of active threads, free memory etc...),the configuration sample inside documentation assume that there is only one java process on the machine. I am searching a simple solution that my monitoring tool will ask the SNMP manager on that host without need to know port for each java process (if it will ask OID from remote machine - which java process will answer it...? how can he know...?)

Thanks!!!


回答1:


download Java MIB file: Java MIB File and put it in: /usr/share/snmp/mibs/JVM-MANAGEMENT-MIB.txt

  1. Because we want to ask the SNMP remotely, we need to set the network interface as well:

    -Dcom.sun.management.snmp.port=8161 -Dcom.sun.management.snmp.interface=0.0.0.0

  2. Because there is no default community we need to add (on top) to snmpd.conf:

    rocommunity public

  3. Because Java process listen to specific port and we want to eliminate the machine network topology outside - we need to forward specific OID prefix to proxy routing by configure the snmpd.conf:

    proxy -m /usr/share/snmp/mibs/JVM-MANAGEMENT-MIB.txt -v 2c -c public localhost:8161 .1.3.6.1.4.1.42.2.145

  4. Because we want to ask the same OID on the same machine, and that machine run multiple instances of the daemon - we need to map fictive OID for each instance to Java process OID in snmpd.conf:

    proxy -m /usr/share/snmp/mibs/JVM-MANAGEMENT-MIB.txt -v 2c -c public localhost:8161 .1.3.6.1.4.1.42.2.99 .1.3.6.1.4.1.42.2.145

    proxy -m /usr/share/snmp/mibs/JVM-MANAGEMENT-MIB.txt -v 2c -c public localhost:8162 .1.3.6.1.4.1.42.2.999 .1.3.6.1.4.1.42.2.145

  5. restart snmpd and test it with:

    snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.42.2.99

    snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.42.2.999




回答2:


NOTE: This solution is only applicable if remote JVM processes are known and managed by you(like start and stop).

To enable SNMP agent in JVM you need to define following system variables, for example on the JVM command line:

-Dcom.sun.management.snmp.interface=127.0.0.1
-Dcom.sun.management.snmp.port=16666
-Dcom.sun.management.snmp.acl=true
-Dcom.sun.management.snmp.acl.file=/path/to/your/snmp.acl  

Now, try running all JVM processes with different snmp port within some known range(say 5000 to 5100). So, you knows that remove JVM processes running can be managed via SNMP within your specified range. Try monitoring them using different SNMP client for every port.

I am not damn sure but it should work.



来源:https://stackoverflow.com/questions/6429089/monitoring-multiple-java-processes-on-the-same-host-via-snmp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!