ARTEMIS-2636: Add Disk Store Usage Metrics

ARTEMIS-2688: Check Arguments In FileStoreMonitor.calculateUsage
This commit is contained in:
Atri Sharma 2020-04-01 17:59:41 +05:30 committed by Clebert Suconic
parent a2696cd650
commit 505b3b0fdc
3 changed files with 14 additions and 2 deletions

View File

@ -136,6 +136,10 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent {
}
public static double calculateUsage(long usableSpace, long totalSpace) {
if (totalSpace == 0) {
return 0.0;
}
return 1.0 - (double) usableSpace / (double) totalSpace;
}

View File

@ -2996,11 +2996,18 @@ public class ActiveMQServerImpl implements ActiveMQServer {
builder.register(BrokerMetricNames.CONNECTION_COUNT, this, metrics -> Double.valueOf(getConnectionCount()), ActiveMQServerControl.CONNECTION_COUNT_DESCRIPTION);
builder.register(BrokerMetricNames.TOTAL_CONNECTION_COUNT, this, metrics -> Double.valueOf(getTotalConnectionCount()), ActiveMQServerControl.TOTAL_CONNECTION_COUNT_DESCRIPTION);
builder.register(BrokerMetricNames.ADDRESS_MEMORY_USAGE, this, metrics -> Double.valueOf(getPagingManager().getGlobalSize()), ActiveMQServerControl.ADDRESS_MEMORY_USAGE_DESCRIPTION);
builder.register(BrokerMetricNames.DISK_STORE_USAGE, this, metrics -> Double.valueOf(getPagingManager().getDiskTotalSpace() - getPagingManager().getDiskUsableSpace()), ActiveMQServerControl.DISK_STORE_USAGE_DESCRIPTION);
builder.register(BrokerMetricNames.DISK_STORE_USAGE, this, metrics -> Double.valueOf(calculateDiskStoreUsage()), ActiveMQServerControl.DISK_STORE_USAGE_DESCRIPTION);
});
}
}
private double calculateDiskStoreUsage() {
long usableSpace = getPagingManager().getDiskUsableSpace();
long totalSpace = getPagingManager().getDiskTotalSpace();
return FileStoreMonitor.calculateUsage(usableSpace, totalSpace);
}
private void unregisterMeters() {
MetricsManager metricsManager = this.metricsManager; // volatile load
if (metricsManager != null) {

View File

@ -116,13 +116,14 @@ public class MetricsPluginTest extends ActiveMQTestBase {
assertThat(artemisMetrics, containsInAnyOrder(
// artemis.(un)routed.message.count is present twice, because of activemq.notifications address
new Metric("artemis.address.memory.usage", "Memory used by all the addresses on broker for in-memory messages", 0.0),
new Metric("artemis.address.memory.usage", "Bytes used by all the addresses on broker for in-memory messages", 0.0),
new Metric("artemis.connection.count", "Number of clients connected to this server", 1.0),
new Metric("artemis.consumer.count", "number of consumers consuming messages from this queue", 0.0),
new Metric("artemis.delivering.durable.message.count", "number of durable messages that this queue is currently delivering to its consumers", 0.0),
new Metric("artemis.delivering.durable.persistent.size", "persistent size of durable messages that this queue is currently delivering to its consumers", 0.0),
new Metric("artemis.delivering.message.count", "number of messages that this queue is currently delivering to its consumers", 0.0),
new Metric("artemis.delivering.persistent_size", "persistent size of messages that this queue is currently delivering to its consumers", 0.0),
new Metric("artemis.disk.store.usage", "Memory used by the disk store", 0.0),
new Metric("artemis.durable.message.count", "number of durable messages currently in this queue (includes scheduled, paged, and in-delivery messages)", 0.0),
new Metric("artemis.durable.persistent.size", "persistent size of durable messages currently in this queue (includes scheduled, paged, and in-delivery messages)", 0.0),
new Metric("artemis.message.count", "number of messages currently in this queue (includes scheduled, paged, and in-delivery messages)", 0.0),