Skip to content
zhenya edited this page Aug 8, 2025 · 10 revisions

Overview

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

Project specifications

  • 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.

Utility Classes

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 SystemMonitor interface for basic system information

Platform Support

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.

Clone this wiki locally