Commit ddcd9122 authored by Nicolas Herbaut's avatar Nicolas Herbaut
Browse files

hooking the flowmatrix queries

parent 6b4a3f57
......@@ -4,6 +4,8 @@
from flask import Flask, request, Response
from jinja2 import Environment, PackageLoader, Template
from flowmatrix.flowlib import *
from flask import Flask, jsonify
from flask_swagger import swagger
import argparse
import yaml
import os
......@@ -25,6 +27,11 @@ args = parser.parse_args()
e = Environment(loader=PackageLoader("flowmatrix", "../flowmatrix/templates/"))
@app.route("/spec")
def spec():
return jsonify(swagger(app))
@app.route("/api/app_param/<param>")
def get_antiaffinity_rules(param):
res = []
......@@ -51,7 +58,7 @@ def get_containers_data():
pillar = yaml.load(f.read())
for name, conf in pillar["placement"].items():
for i in conf.get("instances", []):
res.append((i["name"], name))
res.append((i["name"], name))
res = "\n".join(["%s\t%s" % item for item in res])
return Response(res, mimetype='text/yaml')
......
......@@ -6,7 +6,7 @@ import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from hook import *
import io
from colour import Color
......@@ -14,9 +14,6 @@ white = Color("white")
to_blue = list(white.range_to(Color("blue"), 10))
to_red = list(white.range_to(Color("red"), 10))
query_template = """SELECT last("bytes") as value FROM "telegraf"."autogen"."nftables" WHERE time > now() - 1h AND "host_app_dst"='%s' AND "host_app_src"='%s' GROUP BY time(10w) FILL(null)"""
query_template_full = """SELECT last("bytes") as value FROM "telegraf"."autogen"."nftables" WHERE time > now() - 1h AND "host_app_dst_port"='%s' AND "host_app_src"='%s' GROUP BY time(10w) FILL(null)"""
def sizeof_get_color(num, matrix_mean=0, std_dev=999999999999):
try:
......
query_template = """SELECT last("bytes") as value FROM "telegraf"."autogen"."nftables" WHERE time > now() - 1h AND "host_app_dst"='%s' AND "host_app_src"='%s' GROUP BY time(10w) FILL(null)"""
query_template_full = """SELECT last("bytes") as value FROM "telegraf"."autogen"."nftables" WHERE time > now() - 1h AND "host_app_dst_port"='%s' AND "host_app_src"='%s' GROUP BY time(10w) FILL(null)"""
......@@ -23,4 +23,4 @@ six==1.11.0
urllib3==1.22
Werkzeug==0.12.2
PyYAML==3.12
flask-swagger==0.2.13
monitoring:
- host: h0
placement:
cassandra:
instances:
- name: cassa
host: h1
- name: cassb
host: h2
- name: cassc
host: h3
version: 3.11.1
first_cqlsh_instance: cassa
antiaffinity: True
client:
instances:
- name: clia
host: h1
configuration:
target: h2
- name: clib
host: h2
configuration:
target: h3
- name: clic
host: h3
configuration:
target: h1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment