Last active
January 4, 2016 18:28
-
-
Save aristus/8660397 to your computer and use it in GitHub Desktop.
MemSQL healthcheck server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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