You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/16 20:06:25 UTC
[34/50] incubator-usergrid git commit: Added graphite json
generation. Until auto set works, you have to manually get
Added graphite json generation. Until auto set works, you have to manually get
[LB name]/porta/graphite.json
and set that into the graphite dashboard
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6b975aa3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6b975aa3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6b975aa3
Branch: refs/heads/USERGRID-273
Commit: 6b975aa39b946e773c6c4d140b7da25e2f3855a1
Parents: 3e2604a
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 12 12:37:07 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 12 12:37:07 2015 -0700
----------------------------------------------------------------------
.../main/dist/init_instance/init_rest_server.sh | 21 +++++-
.../main/dist/init_instance/install_collectd.sh | 5 +-
.../src/main/groovy/NodeRegistry.groovy | 26 +++++++
.../src/main/groovy/create_dashboard.groovy | 79 ++++++++++++++++++++
.../src/main/groovy/wait_for_instances.groovy | 20 +----
stack/awscluster/ugcluster-cf.json | 3 +-
6 files changed, 131 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b975aa3/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
index 6581226..3860cd4 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
@@ -207,12 +207,19 @@ sh /etc/init.d/tomcat7 start
until curl -m 1 -I -X GET http://localhost:8080/status | grep "200 OK"; do sleep 5; done
+#Install collectd client to report to graphite
+cd /usr/share/usergrid/init_instance
+./install_collectd.sh
+
+
#If we're the first rest server, run the migration, the database setup, then run the Cassanda keyspace updates
cd /usr/share/usergrid/scripts
groovy registry_register.groovy rest
FIRSTHOST="$(groovy get_first_instance.groovy rest)"
+GRAPHITE_SERVER="$(groovy get_first_instance.groovy graphite )"
+#First host run the migration and setup
if [ "$FIRSTHOST"=="$PUBLIC_HOSTNAME" ]; then
#Run the migration
@@ -230,9 +237,19 @@ cd /usr/share/usergrid/init_instance
fi
+#Always create our graphite dashboard. Last to write will implicity win, since they will have the most recent cluster state
+cd /usr/share/usergrid/scripts
+JSON_PAYLOAD="$(groovy create_dashboard.groovy rest)"
+
+echo ${JSON_PAYLOAD} > /var/lib/tomcat7/webapps/portal/graphite.json
+
+
+#Post the JSON graphite payload to graphite
+## The json is correct, but this doens't work yet. To get the generated data to save, just hit ELB/portal/graphite.json to set into graphite manually
+##curl -X POST -d "${JSON_PAYLOAD}" "http://${GRAPHITE_SERVER}/dashboard/save/Tomcats"
+
+
-cd /usr/share/usergrid/init_instance
-./install_collectd.sh
# tag last so we can see in the console that the script ran to completion
cd /usr/share/usergrid/scripts
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b975aa3/stack/awscluster/src/main/dist/init_instance/install_collectd.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_collectd.sh b/stack/awscluster/src/main/dist/init_instance/install_collectd.sh
index b06cb94..20abbf9 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_collectd.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_collectd.sh
@@ -330,10 +330,13 @@ LoadPlugin java
Host "${PUBLIC_HOSTNAME}"
Collect "classes"
Collect "compilation"
- Collect "garbage_collector"
Collect "memory_pool"
Collect "memory_heap"
Collect "memory_nonheap"
+ Collect "garbage_collector"
+ Collect "catalina/global_request_processor"
+ Collect "catalina/detailed_request_processor"
+ Collect "catalina/thread_pool"
</Connection>
</Plugin>
</Plugin>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b975aa3/stack/awscluster/src/main/groovy/NodeRegistry.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/NodeRegistry.groovy b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
index 8d695e2..2cd70ef 100644
--- a/stack/awscluster/src/main/groovy/NodeRegistry.groovy
+++ b/stack/awscluster/src/main/groovy/NodeRegistry.groovy
@@ -156,6 +156,32 @@ class NodeRegistry {
}
+ /**
+ * Wait until the number of servers are available with the type specified
+ * @param nodeType
+ * @param count
+ */
+ def waitUntilAvailable(def nodeType, def numberOfServers){
+
+ while (true) {
+ try {
+ def selectResult = searchNode(nodeType)
+
+ def count = selectResult.size();
+
+ if (count >= numberOfServers) {
+ println("count = ${count}, total number of servers is ${numberOfServers}. Breaking")
+ break
+ }
+
+ println("Found ${count} nodes but need at least ${numberOfServers}. Waiting...")
+ } catch (Exception e) {
+ println "ERROR waiting for ${nodeType} ${e.getMessage()}, will continue waiting"
+ }
+ Thread.sleep(2000)
+ }
+ }
+
class ServerEntry implements Comparable<ServerEntry> {
private final Date launchDate;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b975aa3/stack/awscluster/src/main/groovy/create_dashboard.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/create_dashboard.groovy b/stack/awscluster/src/main/groovy/create_dashboard.groovy
new file mode 100644
index 0000000..af6b68d
--- /dev/null
+++ b/stack/awscluster/src/main/groovy/create_dashboard.groovy
@@ -0,0 +1,79 @@
+import groovy.json.JsonOutput
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+//
+// wait_for_instances.groovy
+//
+// Wait for enough Cassandra servers are up before proceding,
+// Enough means count greater than or equal to replication factor.
+//
+def createMetric(def title, def collectdMetric, def servers, def array) {
+
+ def serversJson = []
+
+ for (server in servers) {
+
+ def normalizedServer = server.replaceAll("\\.", "_")
+
+ serversJson.add("collectd.${normalizedServer}.${collectdMetric}")
+
+ }
+
+
+ def metric = ["target": serversJson, "title": title]
+
+ array.add(metric)
+
+}
+
+
+NodeRegistry registry = new NodeRegistry();
+
+
+def servers = registry.searchNode("rest")
+
+
+
+def json = []
+
+createMetric("Used Memory", "memory.memory-used", servers, json)
+
+createMetric("Free Memory", "memory.memory-free", servers, json)
+
+createMetric("Load Short Term", "load.load.shortterm", servers, json)
+
+createMetric("Network Received", "interface-eth0.if_octets.rx", servers, json)
+
+createMetric("Network Sent", "interface-eth0.if_packets.tx", servers, json)
+
+createMetric("Tomcat Heap", "GenericJMX-memory-heap.memory-used", servers, json)
+
+createMetric("Tomcat Non Heap", "GenericJMX-memory-nonheap.memory-used", servers, json)
+
+createMetric("Tomcat Old Gen", "GenericJMX-memory_pool-CMS_Old_Gen.memory-used", servers, json)
+
+createMetric("Tomcat Permgen", "GenericJMX-memory_pool-CMS_Perm_Gen.memory-used", servers, json)
+
+
+
+def jsonString = JsonOutput.toJson(json)
+println JsonOutput.prettyPrint(jsonString)
+
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b975aa3/stack/awscluster/src/main/groovy/wait_for_instances.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/wait_for_instances.groovy b/stack/awscluster/src/main/groovy/wait_for_instances.groovy
index e9ef2dc..fcd77b1 100644
--- a/stack/awscluster/src/main/groovy/wait_for_instances.groovy
+++ b/stack/awscluster/src/main/groovy/wait_for_instances.groovy
@@ -42,24 +42,6 @@ NodeRegistry registry = new NodeRegistry();
println "Waiting for ${numberOfServers} nodes of type ${nodetype} to register..."
-def count = 0
-
-while (true) {
- try {
- def selectResult = registry.searchNode(nodetype)
-
- count = selectResult.size();
-
- if (count >= numberOfServers) {
- println("count = ${count}, total number of servers is ${numberOfServers}. Breaking")
- break
- }
-
- println("Found ${count} nodes but need at least ${numberOfServers}. Waiting...")
- } catch (Exception e) {
- println "ERROR waiting for Casasndra ${e.getMessage()}, will continue waiting"
- }
- Thread.sleep(2000)
-}
+registry.waitUntilAvailable(nodetype, numberOfServers)
println "Waiting done."
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b975aa3/stack/awscluster/ugcluster-cf.json
----------------------------------------------------------------------
diff --git a/stack/awscluster/ugcluster-cf.json b/stack/awscluster/ugcluster-cf.json
index 5c0b98c..9bce545 100644
--- a/stack/awscluster/ugcluster-cf.json
+++ b/stack/awscluster/ugcluster-cf.json
@@ -1156,7 +1156,8 @@
"export CASSANDRA_CLUSTER_NAME=", { "Ref":"CassClusterName" }, "\n",
"export CASSANDRA_KEYSPACE_NAME=usergrid", "\n",
"export CASSANDRA_NUM_SERVERS=", { "Ref":"CassNumServers" }, "\n",
- "export GRAPHITE_NUM_SERVERS=", { "Ref":"GraphiteNumServers" }, "\n",
+ "export GRAPHITE_NUM_SERVERS=", { "Ref":"GraphiteNumServers" }, "\n",
+ "export TOMCAT_NUM_SERVERS=", { "Ref":"RestMinServers" }, "\n",
"\n",
"export CASSANDRA_REPLICATION_FACTOR=", { "Ref":"CassReplicationFactor" }, "\n",
"\n",