aboutsummaryrefslogtreecommitdiffstats
path: root/charms/trusty/cassandra/files
diff options
context:
space:
mode:
authorStuart Mackie <wsmackie@juniper.net>2016-11-22 14:00:39 -0800
committerStuart Mackie <wsmackie@juniper.net>2016-11-22 14:00:39 -0800
commit5de4c9f0c126b984da72128a3ca084eda6b4087a (patch)
tree0be55aa0809cc395e45baeae63db660b4e72fe83 /charms/trusty/cassandra/files
parentf02da72993eb8e5a34ed049bad442c6d6db4701a (diff)
Add local cassandra charm from Tony Liu's machine
Change-Id: I56478233f7498861f95a0c12be983f9a1307853e Signed-off-by: Stuart Mackie <wsmackie@juniper.net>
Diffstat (limited to 'charms/trusty/cassandra/files')
-rw-r--r--charms/trusty/cassandra/files/check_cassandra_heap.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/charms/trusty/cassandra/files/check_cassandra_heap.sh b/charms/trusty/cassandra/files/check_cassandra_heap.sh
new file mode 100644
index 0000000..395aa06
--- /dev/null
+++ b/charms/trusty/cassandra/files/check_cassandra_heap.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#---------------------------------------------------
+# This file is Juju managed
+#---------------------------------------------------
+
+# Copyright (C) 2012 Canonical Ltd.
+# Author: Liam Young
+#
+# Script used to check Cassandra is alive and that it has space left in the heap
+
+set -u
+
+if [[ $# -lt 3 ]]; then
+ echo "$0 <jmx-ipadress> <warnpct> <criticalpct>"
+ exit 1
+fi
+WARN_PCT=$2
+CRIT_PCT=$3
+
+NODE_INF0="$(nodetool -h $1 info 2>/dev/null)"
+if [[ $? -ne 0 ]]; then
+ echo "ERROR: Failed to connect to Cassandra"
+ exit 2
+fi
+PCT_USED=$(echo "$NODE_INF0" | awk 'BEGIN {FS=":"} $1 ~ /^Heap Memory/ {print $2}' | awk '{ printf("%i\n", $1*100/$3) }')
+USAGE_INFO="${PCT_USED}% of heap memory used"
+if [[ $PCT_USED -lt $WARN_PCT ]]; then
+ echo "OK: ${USAGE_INFO}"
+ exit 0
+elif [[ $PCT_USED -lt $CRIT_PCT ]]; then
+ echo "WARNING: ${USAGE_INFO}"
+ exit 1
+else
+ echo "CRITICAL: ${USAGE_INFO}"
+ exit 1
+fi