查询监控项
select * from endpoint e inner join endpoint_counter c on e.id = c.endpoint_id where c.counter = "mysql_alive_local/port=3306,type=mysql" and endpoint = "host_name"
模拟登录获取Cookie,Postman选form-data
login()在/static/js/uic.js
# POST FORM, curl可以通过-b 将cookie输出到文件 curl -d "name=user&password=passwd" http://falconhost:port/auth/login
从接口获取监控数据
curl -H "Cookie:session=eyJvcGVuLWZhbGNvbi1jayI6ImppYW5neHU6NGUwOGM0YjM3ZjAwMTFlYTlmM2NlY2Y0YmJmMWFhAAQifQ.XpfQVQ._-QAoxYM--Xf7BKHfi64CU2hgwE" -X GET "http://falconhost:port/chart/h?cf=AVERAGE&end=1586943404&graph_type=h&id=8095&start=1586939864&sum=off&sumonly=off" | jq { "units": "", "series": [ { "counter": "mysql_alive_local/port=3306,type=mysql", "endpoint": "monitored_host", "data": [ [ 1586940000000, 1 ],... ], "name": "monitored_host", "cf": "AVERAGE" } ], "title": "mysql_alive_local/port=3306,type=mysql" }
从chart接口获取数据需要一个id,id是在dashboard.tmp_graph表中的主键
不是所有主机(endpoint)的metric(counter)在tmp_graph都有数据
<a href="javascript:void(0);" onclick="fn_show_chart('mysql_alive_local/port=3306,type=mysql')">mysql_alive_local/port=3306,type=mysql</a>
/static/js/dashboard.js
function fn_show_chart(counter) { var checked_hosts = new Array(); $("#tbody-endpoints input:checked").each(function(i, o){ if($(o).is(":visible")){ var hostfullname = $(o).attr("data-fullname"); checked_hosts.push(hostfullname); } }); if(checked_hosts.length === 0){ err_message_quietly("鍏堥€塭ndpoint锛氾級"); return false; } checked_items = new Array(); checked_items.push(counter); var w = window.open(); $.ajax({ url: "/chart", dataType: "json", method: "POST", data: {"endpoints": checked_hosts, "counters": checked_items, "graph_type": "h", "_r": Math.random()}, success: function(ret) { if (ret.ok) { setTimeout(function(){w.location='/chart/big?id='+ret.id;}, 0); } else { err_message_quietly("璇锋眰鍑洪敊浜�"); } }, error: function(){ err_message_quietly("璇锋眰鍑洪敊浜�"); } }); return false; }