1
1
package org.munin.plugin.jmx;
3
import java.io.IOException;
2
4
import java.lang.management.ManagementFactory;
3
5
import java.lang.management.ThreadMXBean;
4
import javax.management.MBeanServerConnection;
5
import java.io.FileNotFoundException;
6
import java.io.IOException;
7
public class ThreadsPeak {
9
public static void main(String args[])throws FileNotFoundException,IOException {
10
String[] connectionInfo = ConfReader.GetConnectionInfo();
12
if (args.length == 1) {
13
if (args[0].equals("config")) {
15
"graph_title JVM (port " + connectionInfo[1] + ") ThreadsPeak\n" +
16
"graph_vlabel threads\n" +
17
"graph_category " + connectionInfo[2] + "\n" +
18
"graph_info Returns the peak live thread count since the Java virtual machine started or peak was reset.\n" +
19
"ThreadsPeak.label ThreadsPeak"
25
MBeanServerConnection connection = BasicMBeanConnection.get();
26
ThreadMXBean threadmxbean=ManagementFactory.newPlatformMXBeanProxy(connection, ManagementFactory.THREAD_MXBEAN_NAME, ThreadMXBean.class);
28
System.out.println("ThreadsPeak.value "+threadmxbean.getPeakThreadCount());
30
} catch (Exception e) {
7
import org.munin.plugin.jmx.AbstractAnnotationGraphsProvider.Graph;
9
@Graph(title = "ThreadsPeak", vlabel = "threads", info = "Returns the peak live thread count since the Java virtual machine started or peak was reset.")
10
public class ThreadsPeak extends AbstractAnnotationGraphsProvider {
12
public ThreadsPeak(Config config) {
17
public int threadsPeak() throws IOException {
18
ThreadMXBean threadmxbean = ManagementFactory.newPlatformMXBeanProxy(
19
getConnection(), ManagementFactory.THREAD_MXBEAN_NAME,
22
return threadmxbean.getPeakThreadCount();
25
public static void main(String args[]) {