|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
from flask import Flask
from flask import Response, request, abort
import urlparse
import requests
import json
app = Flask(__name__)
esUrl = "http://176.31.137.145:9200/"
@app.route("/, methods=["GET","POST"])
def index(app):
params = "?format=json&pretty"
data = {}
error = ""
req = getattr(requests, request.method.lower())
if app == "es":
arg = request.args["api"]
if "search" in arg:
params = params + "&size=0"
url = urlparse.urljoin(esUrl, arg + params)
# print url
page = req(url) if request.method == "GET" else req(url, request.data)
if page.ok:
try:
ret = page.json()
except Exception as e:
ret = page.content
error = str(e)
else:
ret = "The url:%s request faild" % url
error = "request faild"
elif app == "zab":
ret = [{"status":"ok"}]
else:
ret = ""
error = "incorrect url"
data["data"] = ret
data["error"] = error
resp = Response(json.dumps(data))
if error:
abort(500)
resp.headers["Content-Type"] = "application/json; charset=UTF-8"
resp.headers["access-control-allow-origin"] = "*"
return resp
if __name__ == "__main__":
app.run(port=80,debug=True,host="0.0.0.0")
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<body ng-app="myops">
<ion-pane>
<ion-nav-bar class="bar-positive">
<ion-nav-back-button>ion-nav-back-button>
ion-nav-bar>
<ion-tabs class="tabs-icon-top">
<ion-tab title="Home" icon="ion-home" href="#/home">
<ion-nav-view name="tab-home">ion-nav-view>
ion-tab>
<ion-tab title="es" icon="ion-ionic" href="#/es">
<ion-nav-view name="tab-es">ion-nav-view>
ion-tab>
<ion-tab title="zabbix" icon="ion-ionic" href="#/zabbix">
<ion-nav-view name="tab-zabbix">ion-nav-view>
ion-tab>
ion-tabs>
ion-pane>
body>
|
|
1
2
3
4
5
|
<ion-view view-title="{YOUR TITLE}">
<ion-content>
{YOUR CONTENT} ion-content>
ion-view>
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
app.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom');
$stateProvider
.state("home", {
url:"/home",
views:{
"tab-home":{
controller:"homeCtrl",
templateUrl: "tpls/home.html"
}
}
});
$stateProvider
.state("detail", {
url:"/detail/:name",
views:{
"tab-es":{
controller:"detailCtrl",
templateUrl: "tpls/detail.html"
}
}
});
$stateProvider
.state("perf", {
url:"/perf/:name",
views:{
"tab-home":{
controller:"perfCtrl",
templateUrl: "tpls/perf.html"
}
}
});
$stateProvider
.state("es", {
url:"/es",
views:{
"tab-es":{
controller:"esCtrl",
templateUrl: "tpls/es.html"
}
}
});
$stateProvider
.state("zabbix", {
url:"/zabbix",
views:{
"tab-zabbix":{
controller:"zabbixCtrl",
templateUrl: "tpls/zabbix.html"
}
}
});
$urlRouterProvider.otherwise("/home");
}) |
|
1
2
3
4
5
|
$http.get(esUrl, {params:{api: "_cat/health"}}).then(function(resp){
$scope.data.status = resp.data.data[0].status;
}, function(resp) {
$scope.data.status = "something wrong";
});
|
|
1
2
3
4
5
6
7
8
9
10
11
|
<ion-view view-title="Performance for {{name | uppercase}}">
<ion-content>
<ion-list class="cards">
<ion-item>how many nodes: {{data.nodes}}ion-item>
<ion-item>how many shards: {{data.shards}}ion-item>
<ion-item>status:{{data.status}}ion-item>
<ion-item>how many indices: {{data.indices}}ion-item>
<ion-item>how many documnet:{{data.counts}}ion-item>
ion-list>
ion-content>
ion-view>
|
1 |
bower install angular-chart.js
|
|
1
2
|
<script src="lib/chart.js/dist/Chart.min.js">script>
<script src="lib/angular-chart.js/dist/angular-chart.min.js">script>
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
$http.post(esUrl, setData($scope.name), {params:{api:"_search"}}).then(function(resp) {
var ret = resp.data.data.aggregations.top_tags.buckets;
console.log(ret);
$scope.labels = [];
$scope.series = [$scope.name];
$scope.data = [];
for (var i=0;i
$scope.labels.push(ret[i]["key"]);
$scope.data.push(ret[i]["doc_count"]);
}
},function(resp) {
// console.log(resp.config);
})
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<ion-view view-title="Detail for {{name}}">
<ion-content>
<ion-list >
<ion-item>
<canvas id="bar" class="chart chart-bar"
chart-data="data" chart-labels="labels"> chart-series="series"
canvas>
ion-item>
<ion-item ng-repeat="label in labels">
<h2>{{label}}h2>
<p>{{data[$index]}}p>
ion-item>
ion-list>
ion-content>
ion-view>
|
本文出自 “又耳笔记” 博客













