activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r1424367 - in /activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx: HealthStatus.java HealthView.java
Date Thu, 20 Dec 2012 08:38:02 GMT
Author: rajdavies
Date: Thu Dec 20 08:38:01 2012
New Revision: 1424367

URL: http://svn.apache.org/viewvc?rev=1424367&view=rev
Log:
Added additional health checks

Modified:
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java
    activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java?rev=1424367&r1=1424366&r2=1424367&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthStatus.java
Thu Dec 20 08:38:01 2012
@@ -46,4 +46,8 @@ public class HealthStatus implements Ser
     public String getResource() {
         return resource;
     }
+
+    public String toString(){
+        return healthId + ": " + level + " " + message + " from " + resource;
+    }
 }

Modified: activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java?rev=1424367&r1=1424366&r2=1424367&view=diff
==============================================================================
--- activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
(original)
+++ activemq/trunk/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/HealthView.java
Thu Dec 20 08:38:01 2012
@@ -16,15 +16,21 @@
  */
 package org.apache.activemq.broker.jmx;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 import javax.management.ObjectName;
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.TabularData;
 import javax.management.openmbean.TabularDataSupport;
 import javax.management.openmbean.TabularType;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.scheduler.JobSchedulerStore;
+import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.usage.SystemUsage;
 
 public class HealthView implements HealthViewMBean {
 
@@ -60,6 +66,112 @@ public class HealthView implements Healt
                 answer.add(new HealthStatus("org.apache.activemq.noConsumer", "WARNING",
message, key.toString()));
             }
         }
+
+        /**
+         * Check persistence store directory limits
+         *
+         */
+        BrokerService brokerService = broker.getBrokerService();
+        if (brokerService != null && brokerService.getPersistenceAdapter() != null)
{
+            PersistenceAdapter adapter = brokerService.getPersistenceAdapter();
+            File dir = adapter.getDirectory();
+            if (brokerService.isPersistent()) {
+                SystemUsage usage = brokerService.getSystemUsage();
+                if (dir != null && usage != null) {
+                    String dirPath = dir.getAbsolutePath();
+                    if (!dir.isAbsolute()) {
+                        dir = new File(dirPath);
+                    }
+
+
+                    while (dir != null && !dir.isDirectory()) {
+                        dir = dir.getParentFile();
+                    }
+                    long storeSize = adapter.size();
+                    long storeLimit = usage.getStoreUsage().getLimit();
+                    long dirFreeSpace = dir.getUsableSpace();
+
+                    if (storeSize != 0) {
+                        int val = (int) ((storeSize * 100) / storeLimit);
+                        if (val > 90) {
+                            answer.add(new HealthStatus("org.apache.activemq.StoreLimit",
"WARNING", "Message Store size is within " + val + "% of its limit", adapter.toString()));
+                        }
+                    }
+
+
+                    if ((storeLimit - storeSize) > dirFreeSpace) {
+                        String message = "Store limit is " + storeLimit / (1024 * 1024) +
+                                " mb, whilst the data directory: " + dir.getAbsolutePath()
+
+                                " only has " + dirFreeSpace / (1024 * 1024) + " mb of usable
space";
+                        answer.add(new HealthStatus("org.apache.activemq.FreeDiskSpaceLeft",
"WARNING", message, adapter.toString()));
+                    }
+
+
+                }
+                File tmpDir = brokerService.getTmpDataDirectory();
+                if (tmpDir != null) {
+
+                    String tmpDirPath = tmpDir.getAbsolutePath();
+                    if (!tmpDir.isAbsolute()) {
+                        tmpDir = new File(tmpDirPath);
+                    }
+
+                    long storeSize = usage.getTempUsage().getUsage();
+                    long storeLimit = usage.getTempUsage().getLimit();
+                    while (tmpDir != null && !tmpDir.isDirectory()) {
+                        tmpDir = tmpDir.getParentFile();
+                    }
+
+                    int val = (int) ((storeSize * 100) / storeLimit);
+                    if (val > 90) {
+                        answer.add(new HealthStatus("org.apache.activemq.TempStoreLimit",
"WARNING", "TempMessage Store size is within " + val + "% of its limit", adapter.toString()));
+                    }
+
+
+                }
+
+
+            }
+        }
+
+        if (brokerService != null && brokerService.getJobSchedulerStore() != null)
{
+            JobSchedulerStore scheduler = brokerService.getJobSchedulerStore();
+            File dir = scheduler.getDirectory();
+            if (brokerService.isPersistent()) {
+                SystemUsage usage = brokerService.getSystemUsage();
+                if (dir != null && usage != null) {
+                    String dirPath = dir.getAbsolutePath();
+                    if (!dir.isAbsolute()) {
+                        dir = new File(dirPath);
+                    }
+
+
+                    while (dir != null && !dir.isDirectory()) {
+                        dir = dir.getParentFile();
+                    }
+                    long storeSize = scheduler.size();
+                    long storeLimit = usage.getJobSchedulerUsage().getLimit();
+                    long dirFreeSpace = dir.getUsableSpace();
+
+                    if (storeSize != 0) {
+                        int val = (int) ((storeSize * 100) / storeLimit);
+                        if (val > 90) {
+                            answer.add(new HealthStatus("org.apache.activemq.JobSchedulerLimit",
"WARNING", "JobSchedulerMessage Store size is within " + val + "% of its limit", scheduler.toString()));
+                        }
+                    }
+
+
+                    if ((storeLimit - storeSize) > dirFreeSpace) {
+                        String message = "JobSchedulerStore limit is " + storeLimit / (1024
* 1024) +
+                                " mb, whilst the data directory: " + dir.getAbsolutePath()
+
+                                " only has " + dirFreeSpace / (1024 * 1024) + " mb of usable
space";
+                        answer.add(new HealthStatus("org.apache.activemq.FreeDiskSpaceLeft",
"WARNING", message, scheduler.toString()));
+                    }
+
+                }
+            }
+        }
+
         return answer;
     }
 



Mime
View raw message