https://github.com/arkanosis/jpdh
Windows Performance Data Helper for Java
https://github.com/arkanosis/jpdh
counter java pdh performance windows
Last synced: 2 months ago
JSON representation
Windows Performance Data Helper for Java
- Host: GitHub
- URL: https://github.com/arkanosis/jpdh
- Owner: Arkanosis
- License: bsd-2-clause
- Created: 2016-04-12T15:35:18.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-09-23T17:08:41.000Z (almost 7 years ago)
- Last Synced: 2025-02-09T01:44:00.046Z (over 1 year ago)
- Topics: counter, java, pdh, performance, windows
- Language: C++
- Homepage: https://jpdh.arkanosis.com
- Size: 63.5 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JPDH — Windows Performance Data Helper for Java [](https://search.maven.org/search?q=g:%22com.arkanosis%22%20AND%20a:%22jpdh%22) [](/LICENSE)
JPDH is a Java library to retrieve performance counter values on Microsoft
Windows using the PDH (Performance Data Helper) API and some additional features built on top of it.
## Installation
### Manually
Add jpdh.jar to your CLASSPATH.
### With Maven
```xml
com.arkanosis
jpdh
1.1.4
```
### With Gradle
```kotlin
compile("com.arkanosis:jpdh:1.1.4")
```
## Usage
```java
import com.arkanosis.jpdh.Counter;
import com.arkanosis.jpdh.JPDH;
import com.arkanosis.jpdh.Query;
try (Query query = JPDH.openQuery()) {
Counter diskCounter = query.addCounter("\\PhysicalDisk(_Total)\\Disk Read Bytes/sec");
Counter cpuCounter = query.addCounter("\\PID(8584)\\% User Time");
query.collectData();
System.out.println(diskCounter.getDoubleValue());
System.out.println(cpuCounter.getIntegerValue());
query.removeCounter(diskCounter);
}
```
Any valid PDH counter path can be used, and additional counter path using the non-PDH “PID” object can be used as well:
```
\\computer\Process(parent/instance#index)\counter
\\computer\PID(pid)\counter
```
## Build
Run `make`.
If you don't have a POSIX environment under Windows, you might want to have
a look at [MSYS2](https://msys2.github.io/).
Additionally, you may run the test suite using `make runtest`.
## History
* 2019-09-20: version 1.1.4 — Bugfix release. Counters based on the virtual “PID” object sometimes couldn't be initialized while lots of processes were started of stopped.
* 2017-09-14: version 1.1.3 — Bugfix release. The virtual “PID” object didn't work on localized (eg. German) versions of Windows.
* 2016-06-08: version 1.1.2 — Bugfix release. Calling Query.removeCounter(counter) on counters associated with dead processes was throwing an exception.
* 2016-06-01: version 1.1.1 — Bugfix release. Calling Query.removeCounter(counter) on counters associated with dead processes was throwing an exception.
* 2016-04-19: version 1.1 — Additional “PID” object which maps to the “Process” object for the right process instance and index
* 2016-04-01: version 1.0 — Initial version exposing PDH features in Java
## Contact
Send an email to Jérémie Roquet .
## License
JPDH is distributed under the BSD license, see the LICENSE file.