开发者

Monitoring multiple java processes on the same host via SNMP

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!!!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜