问题
I'm looking for a way to get performance counters from Windows Performance monitor in Java program. I know it's pretty easy to get this counters in .NET or PowerShell. Who knows is it possible in Java?
回答1:
See Access Windows Performance Monitor counters from Java:
"For those running Java applications or services, the Windows Performance Monitor (WPM) contains a treasure trove of valuable information—see Figure 1. There are hundreds (or thousands) of performance statistics called counters that are available in real time and measure critical system performance factors. This article outlines a simple way to access those performance statistics from Java."
Three options are presented:
- Configure WPM to log specific performance counters: WPM can take a configurable set of counters and log them to a file on a configured frequency. Windows XP and Windows 2003 also allow WPM data to be logged directly to an ODBC (Open Database Connectivity) datasource. Once this data has been logged to its final destination, it should be trivial enough to read the logging file using the java.io or java.nio packages.
- Native (Java Native Interface) interface to WPM
- NSClient4j is a pure Java client that provides a simple API for accessing WPM performance counter data. It uses a Windows service called NSClient.
The recommended approach appears to be option 3 ...
来源:https://stackoverflow.com/questions/25035543/windows-performance-counters-from-java