~ubuntu-branches/ubuntu/saucy/munin/saucy

« back to all changes in this revision

Viewing changes to plugins/javalib/org/munin/plugin/jmx/ThreadsPeak.java

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 12:54:28 UTC
  • mfrom: (8.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120611125428-k8z25s77rp755vxe
Tags: 2.0.0-1ubuntu1
* Resync with Debian unstable.
* d/munin-node.upstart,munin.upstart: Add upstart configurations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package org.munin.plugin.jmx;
 
2
 
 
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 {
8
 
 
9
 
    public static void main(String args[])throws FileNotFoundException,IOException {
10
 
        String[] connectionInfo = ConfReader.GetConnectionInfo();
11
 
 
12
 
        if (args.length == 1) {
13
 
            if (args[0].equals("config")) {
14
 
                System.out.println(
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" 
20
 
                );
21
 
            }
22
 
         else {
23
 
 
24
 
           try{
25
 
            MBeanServerConnection connection = BasicMBeanConnection.get();
26
 
            ThreadMXBean threadmxbean=ManagementFactory.newPlatformMXBeanProxy(connection, ManagementFactory.THREAD_MXBEAN_NAME, ThreadMXBean.class);
27
 
            
28
 
            System.out.println("ThreadsPeak.value "+threadmxbean.getPeakThreadCount());
29
 
 
30
 
            } catch (Exception e) {
31
 
                System.out.print(e);
32
 
            }
33
 
        }
34
 
 
35
 
    }
36
 
}
37
 
 
 
6
 
 
7
import org.munin.plugin.jmx.AbstractAnnotationGraphsProvider.Graph;
 
8
 
 
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 {
 
11
 
 
12
        public ThreadsPeak(Config config) {
 
13
                super(config);
 
14
        }
 
15
 
 
16
        @Field
 
17
        public int threadsPeak() throws IOException {
 
18
                ThreadMXBean threadmxbean = ManagementFactory.newPlatformMXBeanProxy(
 
19
                                getConnection(), ManagementFactory.THREAD_MXBEAN_NAME,
 
20
                                ThreadMXBean.class);
 
21
 
 
22
                return threadmxbean.getPeakThreadCount();
 
23
        }
 
24
 
 
25
        public static void main(String args[]) {
 
26
                runGraph(args);
 
27
        }
38
28
}