You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ma...@apache.org on 2013/11/08 12:08:54 UTC

git commit: STRATOS-161 - Send health stats periodically to CEP

Updated Branches:
  refs/heads/master 11d8cbe5d -> 6772f9ac8


STRATOS-161 - Send health stats periodically to CEP


Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/6772f9ac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/6772f9ac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/6772f9ac

Branch: refs/heads/master
Commit: 6772f9ac812a322c90798c7944349cd544ee8256
Parents: 11d8cbe
Author: Manula Thantriwatte <ma...@wso2.com>
Authored: Fri Nov 8 16:36:28 2013 +0530
Committer: Manula Thantriwatte <ma...@wso2.com>
Committed: Fri Nov 8 16:36:28 2013 +0530

----------------------------------------------------------------------
 .../modules/health-stats/pom.xml                | 145 +++++++++++++++++++
 .../health-stats/src/main/assembly/bin.xml      |  62 ++++++++
 .../src/main/bin/health-publisher.sh            |  30 ++++
 .../agent/health/publisher/HealthPublisher.java | 122 ++++++++++++++++
 .../health/publisher/HealthPublisherClient.java |  62 ++++++++
 .../cartridge/agent/health/publisher/Main.java  |  53 +++++++
 .../src/main/resources/jndi.properties          |  22 +++
 .../src/main/resources/log4j.properties         |  37 +++++
 .../src/main/security/client-truststore.jks     | Bin 0 -> 35240 bytes
 products/cartridge-agent/pom.xml                |   1 +
 10 files changed, 534 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/pom.xml
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/pom.xml b/products/cartridge-agent/modules/health-stats/pom.xml
new file mode 100644
index 0000000..16a8179
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/pom.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.apache.stratos</groupId>
+        <artifactId>cartidge-agent</artifactId>
+        <version>4.0.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>apache-stratos-health-publisher</artifactId>
+    <name>Apache Stratos - Health Publisher</name>
+
+    <repositories>
+        <repository>
+            <id>wso2-nexus</id>
+            <name>WSO2 internal Repository</name>
+            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>ignore</checksumPolicy>
+            </releases>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.wso2.andes.wso2</groupId>
+            <artifactId>andes-client</artifactId>
+            <version>0.13.wso2v8</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs.wso2</groupId>
+            <artifactId>geronimo-jms_1.1_spec</artifactId>
+            <version>1.1.0.wso2v1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.messaging</artifactId>
+            <version>4.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.0</version>
+        </dependency>
+                <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.messaging</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>0.9.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.databridge.agent.thrift</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.databridge.commons.thrift</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.databridge.commons</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.apache.stratos.cartridge.agent.event.publisher.Main</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <plugin>
+            <artifactId>maven-assembly-plugin</artifactId>
+            <version>2.2.1</version>
+            <configuration>
+                <descriptors>
+                    <descriptor>src/main/assembly/bin.xml</descriptor>
+                </descriptors>
+                <archiverConfig>
+                    <fileMode>420</fileMode>
+                    <directoryMode>493</directoryMode>
+                    <defaultDirectoryMode>493</defaultDirectoryMode>
+                </archiverConfig>
+            </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attached</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/assembly/bin.xml b/products/cartridge-agent/modules/health-stats/src/main/assembly/bin.xml
new file mode 100644
index 0000000..99a9dae
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/src/main/assembly/bin.xml
@@ -0,0 +1,62 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+    <id>bin</id>
+    <formats>
+        <format>zip</format>
+    </formats>
+    <fileSets>
+        <fileSet>
+            <directory>${project.basedir}/src/main/bin</directory>
+            <outputDirectory>/bin</outputDirectory>
+            <fileMode>0755</fileMode>
+            <includes>
+                <include>health-publisher.sh</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>${project.basedir}/src/main/security</directory>
+            <outputDirectory>/security</outputDirectory>
+            <fileMode>0600</fileMode>
+            <includes>
+                <include>client-truststore.jks</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>${project.basedir}</directory>
+            <outputDirectory>/</outputDirectory>
+            <fileMode>0600</fileMode>
+            <includes>
+                <include>README*</include>
+                <include>LICENSE*</include>
+                <include>NOTICE*</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <scope>runtime</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/bin/health-publisher.sh
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/bin/health-publisher.sh b/products/cartridge-agent/modules/health-stats/src/main/bin/health-publisher.sh
new file mode 100755
index 0000000..ce3e36d
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/src/main/bin/health-publisher.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# --------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# --------------------------------------------------------------
+
+echo "Starting health publisher..."
+lib_path=./../lib/
+class_path=${lib_path}andes-client-0.13.wso2v8.jar:${lib_path}ant-1.7.0.jar:${lib_path}ant-1.7.0.wso2v1.jar:${lib_path}ant-launcher-1.7.0.jar:${lib_path}apache-stratos-health-publisher-4.0.0-SNAPSHOT.jar:${lib_path}axiom-1.2.11.wso2v4.jar:${lib_path}axiom-api-1.2.11.jar:${lib_path}axiom-impl-1.2.11.jar:${lib_path}axis2-1.6.1.wso2v10.jar:${lib_path}commons-cli-1.0.jar:${lib_path}commons-codec-1.8.jar:${lib_path}commons-fileupload-1.2.0.wso2v1.jar:${lib_path}commons-fileupload-1.2.jar:${lib_path}commons-httpclient-3.1.0.wso2v2.jar:${lib_path}commons-httpclient-3.1.jar:${lib_path}commons-io-2.0.jar:${lib_path}commons-lang-1.0.jar:${lib_path}commons-lang3-3.1.jar:${lib_path}commons-logging-1.1.1.jar:${lib_path}commons-pool-1.5.0.wso2v1.jar:${lib_path}commons-pool-1.5.jar:${lib_path}dom4j-1.6.1.jar:${lib_path}geronimo-activation_1.1_spec-1.0.2.jar:${lib_path}geronimo-javamail_1.4_spec-1.6.jar:${lib_path}geronimo-jms_1.1_spec-1.1.0.wso2v1.jar:${lib_path}geronimo-jms_1.1_spec-1.1.jar:${lib
 _path}geronimo-stax-api_1.0_spec-1.0.1.jar:${lib_path}gson-2.2.4.jar:${lib_path}httpclient-4.1.1-wso2v1.jar:${lib_path}httpclient-4.2.5.jar:${lib_path}httpcore-4.1.0-wso2v1.jar:${lib_path}httpcore-4.2.4.jar:${lib_path}icu4j-2.6.1.jar:${lib_path}javax.servlet-3.0.0.v201112011016.jar:${lib_path}jaxen-1.1.1.jar:${lib_path}jdom-1.0.jar:${lib_path}jline-0.9.94.jar:${lib_path}json-2.0.0.wso2v1.jar:${lib_path}junit-3.8.1.jar:${lib_path}libthrift-0.7.wso2v1.jar:${lib_path}libthrift-0.9.1.jar:${lib_path}log4j-1.2.13.jar:${lib_path}not-yet-commons-ssl-0.3.9.jar:${lib_path}org.apache.log4j-1.2.13.v200706111418.jar:${lib_path}org.apache.stratos.messaging-4.0.0-SNAPSHOT.jar:${lib_path}org.eclipse.osgi-3.8.1.v20120830-144521.jar:${lib_path}org.eclipse.osgi.services-3.3.100.v20120522-1822.jar:${lib_path}org.wso2.carbon.base-4.2.0.jar:${lib_path}org.wso2.carbon.core.common-4.2.0.jar:${lib_path}org.wso2.carbon.databridge.agent.thrift-4.2.0.jar:${lib_path}org.wso2.carbon.databridge.commons-4.2.0.jar:
 ${lib_path}org.wso2.carbon.databridge.commons.thrift-4.2.0.jar:${lib_path}org.wso2.carbon.logging-4.1.0.jar:${lib_path}org.wso2.carbon.queuing-4.2.0.jar:${lib_path}org.wso2.carbon.registry.api-4.2.0.jar:${lib_path}org.wso2.carbon.securevault-4.2.0.jar:${lib_path}org.wso2.carbon.user.api-4.2.0.jar:${lib_path}org.wso2.carbon.utils-4.2.0.jar:${lib_path}org.wso2.securevault-1.0.0-wso2v2.jar:${lib_path}slf4j-1.5.10.wso2v1.jar:${lib_path}slf4j-api-1.7.5.jar:${lib_path}slf4j-log4j12-1.7.5.jar:${lib_path}smack-3.0.4.wso2v1.jar:${lib_path}smackx-3.0.4.wso2v1.jar:${lib_path}wstx-asl-3.2.9.jar:${lib_path}xalan-2.6.0.jar:${lib_path}xercesImpl-2.6.2.jar:${lib_path}xml-apis-1.3.02.jar:${lib_path}xmlParserAPIs-2.6.2.jar:${lib_path}xom-1.0.jar
+current_path=`pwd`
+java -cp $class_path -Dkey.file.path=$current_path/../security/client-truststore.jks -Dthrift.receiver.ip=localhost -Dthrift.receiver.port=7615 org.apache.stratos.cartridge.agent.health.publisher.Main $*
+
+echo "Health publisher completed" 
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisher.java
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisher.java b/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisher.java
new file mode 100644
index 0000000..d5bb4e9
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisher.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one 
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+ * KIND, either express or implied.  See the License for the 
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cartridge.agent.health.publisher;
+
+import java.io.File;
+import java.lang.NullPointerException;
+import java.lang.String;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.databridge.agent.thrift.Agent;
+import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
+import org.wso2.carbon.databridge.agent.thrift.conf.AgentConfiguration;
+import org.wso2.carbon.databridge.agent.thrift.exception.AgentException;
+import org.wso2.carbon.databridge.commons.Event;
+import org.wso2.carbon.utils.CarbonUtils;
+
+public class HealthPublisher implements Observer {
+
+    private static final Log log = LogFactory.getLog(HealthPublisher.class);
+    private static final String CALL_CENTER_DATA_STREAM = "stratos.agent.health.stats";
+    private static final String VERSION = "1.0.0";
+    private AsyncDataPublisher asyncDataPublisher;
+
+    public HealthPublisher() {
+        try {
+            //TODO read following from a config file
+            String ip = System.getProperty("thrift.receiver.ip");
+            String port = System.getProperty("thrift.receiver.port");
+            String keyFilePath = System.getProperty("key.file.path");
+
+            AgentConfiguration agentConfiguration = new AgentConfiguration();
+
+            // TODO get following from somewhere, without hard-coding.
+            System.setProperty("javax.net.ssl.trustStore", keyFilePath);
+            System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
+
+            Agent agent = new Agent(agentConfiguration);
+
+            //Using Asynchronous data publisher
+            asyncDataPublisher = new AsyncDataPublisher("tcp://" + ip + ":" + port + "", "admin", "admin", agent);
+            String streamDefinition = "{" +
+                    " 'name':'" + CALL_CENTER_DATA_STREAM + "'," +
+                    " 'version':'" + VERSION + "'," +
+                    " 'nickName': 'health stats'," +
+                    " 'description': 'health stats'," +
+                    " 'metaData':[]," +
+                    " 'payloadData':[" +
+                    " {'name':'health_description','type':'STRING'}," +
+                    " {'name':'value','type':'INT'}" +
+                    " ]" +
+                    "}";
+            asyncDataPublisher.addStreamDefinition(streamDefinition, CALL_CENTER_DATA_STREAM, VERSION);
+
+        } catch (NullPointerException e) {
+            if (log.isErrorEnabled()) {
+                log.error("Get null values", e);
+            }
+        }
+    }
+
+    public void update(Observable arg0, Object arg1) {
+        if (arg1 != null && arg1 instanceof Map<?, ?>) {
+            Map<String, Integer> stats = (Map<String, Integer>) arg1;
+            publishEvents(stats);
+        }
+    }
+
+    public void update(Object healthStatObj) {
+        if (healthStatObj != null && healthStatObj instanceof Map<?, ?>) {
+            Map<String, Integer> stats = (Map<String, Integer>) healthStatObj;
+            publishEvents(stats);
+        }
+    }
+
+    private void publishEvents(Map<String, Integer> stats) {
+
+        for (Map.Entry<String, Integer> entry : stats.entrySet()) {
+
+            Object[] payload = new Object[]{entry.getKey(), entry.getValue()};
+            Event event = eventObject(null, null, payload, new HashMap<String, String>());
+            try {
+                asyncDataPublisher.publish(CALL_CENTER_DATA_STREAM, VERSION, event);
+            } catch (AgentException e) {
+                log.error("Failed to publish health stats. ", e);
+            }
+
+        }
+        stats = null;
+    }
+
+    private static Event eventObject(Object[] correlationData, Object[] metaData,
+                                     Object[] payLoadData, HashMap<String, String> map) {
+        Event event = new Event();
+        event.setCorrelationData(correlationData);
+        event.setMetaData(metaData);
+        event.setPayloadData(payLoadData);
+        event.setArbitraryDataMap(map);
+        return event;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisherClient.java
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisherClient.java b/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisherClient.java
new file mode 100644
index 0000000..1cf488c
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/HealthPublisherClient.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cartridge.agent.health.publisher;
+
+import java.io.*;
+import java.lang.Runtime;
+import java.util.HashMap;
+import java.util.Map;
+
+public class HealthPublisherClient {
+
+    private static final int MB = 1024 * 1024;
+
+	public Object getHealthStats() {
+
+        Runtime runtime = Runtime.getRuntime();
+
+		Map<String, Integer> statsMap = new HashMap<String, Integer>();
+
+        statsMap.put("Available Processors", (int)runtime.availableProcessors());
+        statsMap.put("Total Memory", (int)(runtime.totalMemory() / MB));
+		statsMap.put("Max Memory", (int)(runtime.maxMemory() / MB));
+        statsMap.put("Used Memory", (int)((runtime.totalMemory() - runtime.freeMemory()) / MB));
+        statsMap.put("Free Memory", (int)(runtime.freeMemory() / MB));
+		
+		Object statObj = (Object)statsMap;
+		
+		return statObj;
+	}
+	
+	public void run() {
+		try {
+			HealthPublisher publisher = new HealthPublisher();
+			
+			while (true) {
+				Object healthStatObj = getHealthStats();
+				publisher.update(healthStatObj);
+			
+				Thread.sleep(10000);
+			}
+		} catch(InterruptedException ex) {
+		    Thread.currentThread().interrupt();
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/Main.java
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/Main.java b/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/Main.java
new file mode 100644
index 0000000..13a8e67
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/src/main/java/org/apache/stratos/cartridge/agent/health/publisher/Main.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cartridge.agent.health.publisher;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Health publisher main class.
+ */
+
+public class Main {
+	private static final Log log = LogFactory.getLog(Main.class);
+	
+	public static void main (String args[]) {
+		try {
+            if (log.isInfoEnabled()) {
+                log.info("Health publisher started");
+            }
+            
+            System.out.println("This is health stat publisher module");
+            
+            HealthPublisherClient client = new HealthPublisherClient();
+            client.run();
+            
+            System.exit(0);
+			
+		} catch (Exception e) {
+            if (log.isErrorEnabled()) {
+                log.error("Could not publish health stats", e);
+            }
+		}
+		
+		System.exit(-1);
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/resources/jndi.properties b/products/cartridge-agent/modules/health-stats/src/main/resources/jndi.properties
new file mode 100644
index 0000000..d3b29bc
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/src/main/resources/jndi.properties
@@ -0,0 +1,22 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+connectionfactoryName=topicConnectionfactory
+connectionfactory.topicConnectionfactory=amqp://admin:admin@carbon/carbon?brokerlist='tcp://MB-IP-ADDRESS:MB-PORT'
+java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/resources/log4j.properties b/products/cartridge-agent/modules/health-stats/src/main/resources/log4j.properties
new file mode 100644
index 0000000..4c4e610
--- /dev/null
+++ b/products/cartridge-agent/modules/health-stats/src/main/resources/log4j.properties
@@ -0,0 +1,37 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Set root logger level and appenders
+log4j.rootLogger=INFO, CONSOLE_APPENDER, FILE_APPENDER
+
+# CONSOLE_APPENDER is set to be a ConsoleAppender.
+log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender
+
+# The standard error log where all the warnings, errors and fatal errors will be logged
+log4j.appender.FILE_APPENDER=org.apache.log4j.FileAppender
+log4j.appender.FILE_APPENDER.File=/var/log/apache-stratos/cartridge-agent-event-publisher.log
+log4j.appender.FILE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%n
+log4j.appender.FILE_APPENDER.threshold=DEBUG
+
+# CONSOLE_APPENDER uses PatternLayout.
+log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=[%d{ISO8601}] %5p - [%c{1}] %m%n
+
+log4j.logger.org.apache.stratos.cartridge.agent.event.publisher=DEBUG
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/modules/health-stats/src/main/security/client-truststore.jks
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/modules/health-stats/src/main/security/client-truststore.jks b/products/cartridge-agent/modules/health-stats/src/main/security/client-truststore.jks
new file mode 100644
index 0000000..be441f3
Binary files /dev/null and b/products/cartridge-agent/modules/health-stats/src/main/security/client-truststore.jks differ

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6772f9ac/products/cartridge-agent/pom.xml
----------------------------------------------------------------------
diff --git a/products/cartridge-agent/pom.xml b/products/cartridge-agent/pom.xml
index 69efb78..f84f332 100644
--- a/products/cartridge-agent/pom.xml
+++ b/products/cartridge-agent/pom.xml
@@ -35,6 +35,7 @@
 
     <modules>
         <module>modules/event-publisher</module>
+	<module>modules/health-stats</module>
     </modules>
 </project>