Skip to content

Instantly share code, notes, and snippets.

@aristus
Last active January 4, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aristus/8660397 to your computer and use it in GitHub Desktop.
Save aristus/8660397 to your computer and use it in GitHub Desktop.
MemSQL healthcheck server
from flask import Flask
import torndb
## NB: this default query does not exercise leaf connectivity or
## partition health. For best results, use a query that selects
## a record from an actual data table.
SQL = "select count(1) from information_schema.processlist"
## SQL = "select * from dashboard.analytics limit 1"
## SQL = "show databases extended"
app = Flask(__name__)
@app.route("/memsql-healthcheck")
def ping():
try:
conn = torndb.Connection(host="127.0.0.1:3306", user = "root", database = 'information_schema')
rows = conn.query(SQL)
return str(rows)
if rows:
return "OK"
else:
return ":("
except:
return ":("
if __name__ == "__main__":
app.run(port=6033, host="0.0.0.0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment