File: //lib/python2.7/site-packages/lap/active_xtradb.py
# This plugin differs from xtradb_cluster because it's active:
# it's checked outside machines
import random
import urllib2
# This check is based on https://github.com/olafz/percona-clustercheck
#
# All clusters installed here have an tiny script listening on port 9200
# that returns 200 OK if the cluster is OK and 503 otherwise.
#
# To make sure that the cluster is up, we need to receive at least a 200
def __run__(params):
nodes = params.get('nodes').split()
random.shuffle(nodes)
url_template = 'http://{0}:9200/'
for node in nodes:
try:
url = urllib2.urlopen(url_template.format(node))
if url.getcode() == 200:
return [0, 'OK']
except:
continue
return [2, "CRITICAL: cluster is offline"]