cat /srv/http-monitoring/http-monitoring.py #!/usr/bin/python import commands,os,subprocess from flask import Flask from flask import Response app = Flask(__name__) frontends = [ 'domain1.com:2080', 'domain2.com:2080', 'domain3.com:2080', 'domain4.com:2080', ] o = "" @app.route('/') def hello_world(): o = "" for frontend in frontends: output = subprocess.check_output('curl -s -w "%{time_total}\n" -o /dev/null http://' + frontend, shell=True) output = output.replace('\n', '') output = repr(output) output = output.replace('\'', '') output = output.replace(',', '.') output = 'responce_time_http {point="' + frontend +'"} ' + output global o o = o + output + "\n" resp = Response(o) resp.headers['Content-Type'] = 'text/plain; charset=utf-8' resp.headers['Connection'] = 'keep-alive' return resp if __name__ == '__main__': app.run(host='0.0.0.0',port=26743)