~ubuntu-branches/ubuntu/lucid/munin/lucid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Holger Levsen, Stig Sandbeck Mathisen, Tom Feiner
  • Date: 2010-01-14 12:10:51 UTC
  • mfrom: (8.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20100114121051-6xovy6hqfh1wrl0u
Tags: 1.4.3-2
[ Stig Sandbeck Mathisen ]
* Add versioned dependency for librrds-perl.
  If used with librrds-perl 1.2 or older, the font path is wrong.

[ Tom Feiner ]
* Update watch file.
* Add patch from munin ticket #828, to suppress "occasional" unknown 
  states to avoid alerts. Thanks to Steve Wilson for the patch!
* Removed asterisks from NEWS.Debian and rewrite as non bulleted list, as
  advised by the developers reference.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.munin.plugin.jmx;
 
2
import java.lang.management.ManagementFactory;
 
3
import java.lang.management.OperatingSystemMXBean;
 
4
import javax.management.MBeanServerConnection;
 
5
 
 
6
public class ProcessorsAvailable  {
 
7
 
 
8
    public static void main(String args[]) {
 
9
        String[] connectionInfo= ConfReader.GetConnectionInfo();
 
10
 
 
11
        if (args.length == 1) {
 
12
            if (args[0].equals("config")) {
 
13
                System.out.println("graph_title JVM (port " + connectionInfo[1] + ") ProcessorsAvailable\n" +
 
14
                "graph_vlabel processors\n" +
 
15
                "graph_category " + connectionInfo[2] + "\n" +
 
16
                "graph_info Returns the number of processors available to the Java virtual machine. This value may change during a particular invocation of the virtual machine.\n" +
 
17
                "ProcessorsAvailable.label ProcessorsAvailable");
 
18
            }
 
19
        else {
 
20
            try {
 
21
                MBeanServerConnection connection = BasicMBeanConnection.get();
 
22
                OperatingSystemMXBean osmxbean = ManagementFactory.newPlatformMXBeanProxy(connection, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class);
 
23
 
 
24
                System.out.println("ProcessorsAvailable.value " + osmxbean.getAvailableProcessors());
 
25
 
 
26
            } catch (Exception e) {
 
27
                System.out.print(e);
 
28
            }
 
29
        }
 
30
}
 
31
}
 
32
}