1

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
  • This question is as relevant in 2020 as when it was written in 2014. I have just added a comment to the current single answer, explaining why it seems not the current "right" answer. So I'd love to hear if anyone else may have any other solutions. Commented Jan 21, 2020 at 20:03

1 Answer 1

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:

  1. 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.
  2. Native (Java Native Interface) interface to WPM
  3. 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 ...

Sign up to request clarification or add additional context in comments.

1 Comment

FWIW, as for the "recommended approach" (from the referenced 2004 article), to use the NSClient4j library, that (nsclient.ready2run.nl) is no longer available (as I write in 2020). And while we may find the site and code via archive.org, etc., I can't help thinking it would be WAY outdated. Would love to hear if there are better options. (The JNI mention is not elaborated in the referenced article, and using logging is of course not a direct connection from Java to obtain perfmon counters.)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.