-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Java System Monitor is a lightweight library for monitoring Java Virtual Machine (JVM) and system-level resource usage such as CPU and memory in Java.
The library is designed to be lightweight, easy to use, and performant, making it suitable for both development and production environments. It provides several monitoring strategies to suit different use cases, from background monitoring to on-demand resource checks.
Key features:
- CPU usage monitoring (process and system-wide)
- Memory usage monitoring with historical tracking
- Multiple monitoring strategies (lazy, background, unsupported)
- Minimal overhead and thread-safe implementations
- 100% pure Java, no external dependencies
- Automatic resource management with try-with-resources support
- Java 8 or higher is required
- No external dependencies
- Thread-safe implementations for concurrent use
- Lightweight design with minimal performance impact
The library provides three main monitoring implementations:
| Monitor Type | Use Case | Resource Usage | Thread Safety |
|---|---|---|---|
LazySystemMonitor |
On-demand monitoring with configurable refresh thresholds | Low | Thread-safe |
BackgroundSystemMonitor |
Continuous monitoring with background refresh thread | Medium | Thread-safe |
UnsupportedSystemMonitor |
Fallback implementation returning -1 values | Minimal | Thread-safe |
All monitors implement the SystemMonitor interface and can be used interchangeably depending on your application's monitoring requirements.
The library also provides utility classes for common tasks:
-
Formatter- Format CPU percentages and memory values in human-readable formats (binary/decimal bytes) - Static utility methods in
SystemMonitorinterface for basic system information
The monitoring capabilities depend on the underlying JVM and operating system. When certain metrics are unavailable, the library returns -1 to indicate unsupported operations rather than throwing exceptions.