Interface SystemUsageMetrics
- All Known Implementing Classes:
SystemUsageMonitor
public interface SystemUsageMetrics
Interface to define system usage metrics.
Provides methods to retrieve various system usage statistics such as CPU usage,
heap memory usage, and disk space information.
Implementation classes should provide concrete definitions for how to obtain these metrics from the underlying system.
This interface also provides a default method for formatting double values to two decimal places.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the current disk usage as a percentage of the total disk space.default DoubleformatDouble(double value) Formats a double value to two decimal places.longRetrieves the maximum JVM heap memory in bytes.Retrieves the current JVM heap memory usage as a percentage of the maximum available.longRetrieves the current JVM heap memory usage in bytes.longRetrieves the maximum JVM non-heap memory in bytes.Retrieves the current JVM non-heap memory usage as a percentage of the maximum available.longRetrieves the current JVM non-heap memory usage in bytes.longRetrieves the total maximum JVM memory (heap + non-heap) in bytes.Retrieves the total current JVM memory usage as a percentage of the total maximum available.longRetrieves the total current JVM memory usage (heap + non-heap) in bytes.longRetrieves the total network input bytes.longRetrieves the total network output bytes.Retrieves the current system memory usage as a percentage of the maximum available.Retrieves the current system CPU usage as a percentage.
-
Field Details
-
DECIMAL_FORMAT
-
-
Method Details
-
systemCpuUsagePercent
Double systemCpuUsagePercent()Retrieves the current system CPU usage as a percentage.- Returns:
- the system CPU usage as a percentage, or 0.0 if not available
-
getSystemMemoryUsagePercent
Double getSystemMemoryUsagePercent()Retrieves the current system memory usage as a percentage of the maximum available.- Returns:
- the used system memory as a percentage, or -1 if not available
-
diskUsagePercent
Double diskUsagePercent()Retrieves the current disk usage as a percentage of the total disk space.- Returns:
- the disk usage as a percentage, or -1 if not available
-
getJvmHeapUsed
long getJvmHeapUsed()Retrieves the current JVM heap memory usage in bytes.- Returns:
- the used JVM heap memory in bytes
-
getJvmHeapMax
long getJvmHeapMax()Retrieves the maximum JVM heap memory in bytes.- Returns:
- the maximum JVM heap memory in bytes
-
getJvmHeapUsagePercent
Double getJvmHeapUsagePercent()Retrieves the current JVM heap memory usage as a percentage of the maximum available.- Returns:
- the JVM heap memory usage as a percentage
-
getJvmNonHeapUsed
long getJvmNonHeapUsed()Retrieves the current JVM non-heap memory usage in bytes.- Returns:
- the used JVM non-heap memory in bytes
-
getJvmNonHeapMax
long getJvmNonHeapMax()Retrieves the maximum JVM non-heap memory in bytes.- Returns:
- the maximum JVM non-heap memory in bytes, or -1 if not defined
-
getJvmNonHeapUsagePercent
Double getJvmNonHeapUsagePercent()Retrieves the current JVM non-heap memory usage as a percentage of the maximum available.- Returns:
- the JVM non-heap memory usage as a percentage, or -1 if maximum is not defined
-
getJvmTotalMemoryUsed
long getJvmTotalMemoryUsed()Retrieves the total current JVM memory usage (heap + non-heap) in bytes.- Returns:
- the total used JVM memory in bytes
-
getJvmTotalMemoryMax
long getJvmTotalMemoryMax()Retrieves the total maximum JVM memory (heap + non-heap) in bytes.- Returns:
- the total maximum JVM memory in bytes
-
getJvmTotalMemoryUsagePercent
Double getJvmTotalMemoryUsagePercent()Retrieves the total current JVM memory usage as a percentage of the total maximum available.- Returns:
- the total JVM memory usage as a percentage
-
getNetworkInBytes
long getNetworkInBytes()Retrieves the total network input bytes.- Returns:
- the total network input bytes
-
getNetworkOutBytes
long getNetworkOutBytes()Retrieves the total network output bytes.- Returns:
- the total network output bytes
-
formatDouble
Formats a double value to two decimal places.- Parameters:
value- the value to format- Returns:
- the formatted value as a double
-