forked from ganglia/ganglia-web
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaggregate_graphs.php
More file actions
168 lines (148 loc) · 4.9 KB
/
aggregate_graphs.php
File metadata and controls
168 lines (148 loc) · 4.9 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<style>
#aggregate_graph_table_form {
font-size: 12px;
}
#show_direct_link {
background-color: #eeeeee;
text-align: center;
padding: 5px;
}
</style>
<script>
function refreshAggregateGraph() {
$("#aggregate_graph_display img").each(function (index) {
var src = $(this).attr("src");
if (src.indexOf("graph.php") == 0) {
var d = new Date();
$(this).attr("src", jQuery.param.querystring(src, "&_=" + d.getTime()));
}
});
}
function createAggregateGraph() {
if ($('#hreg').val() == "" || $('#metric_chooser').val() == "") {
alert("Host regular expression and metric name can't be blank");
return false;
}
var params = $("#aggregate_graph_form").serialize() + "&aggregate=1";
$("#show_direct_link").html("<a href='graph_all_periods.php?" + params + "'>Direct Link to this aggregate graph</a>");
$("#aggregate_graph_display").html('<img src="img/spinner.gif">');
$.ajax({url: 'graph_all_periods.php',
cache: false,
data: params + "&embed=1" ,
success: function(data) {
$("#aggregate_graph_display").html(data);
}});
return false;
}
$(function() {
$( ".ag_buttons" ).button();
$( "#graph_type_menu" ).buttonset();
$( "#graph_legend_menu" ).buttonset();
$("#hreg").change(function() {
$.cookie("ganglia-aggregate-graph-hreg" + window.name,
$("#hreg").val());
});
$("#vl").change(function() {
$.cookie("ganglia-aggregate-graph-vl" + window.name,
$("#vl").val());
});
$("#x").change(function() {
$.cookie("ganglia-aggregate-graph-upper" + window.name,
$("#x").val());
});
$("#n").change(function() {
$.cookie("ganglia-aggregate-graph-lower" + window.name,
$("#n").val());
});
$("#title").change(function() {
$.cookie("ganglia-aggregate-graph-title" + window.name,
$("#title").val());
});
$("#aggregate_graph_table_form input[name=gtype]").change(function() {
$.cookie("ganglia-aggregate-graph-gtype" + window.name,
$("#aggregate_graph_table_form input[name=gtype]:checked").val());
});
function restoreAggregateGraph() {
var hreg = $.cookie("ganglia-aggregate-graph-hreg" + window.name);
if (hreg != null)
$("#hreg").val(hreg);
var gtype = $.cookie("ganglia-aggregate-graph-gtype" + window.name);
if (gtype != null)
$("#aggregate_graph_table_form input[name=gtype]").val([gtype]);
var metric = $.cookie("ganglia-aggregate-graph-metric" + window.name);
if (metric != null)
$("#metric_chooser").val(metric);
var title = $.cookie("ganglia-aggregate-graph-title" + window.name);
if (title != null)
$("#title").val(title);
var vl = $.cookie("ganglia-aggregate-graph-vl" + window.name);
if (vl != null)
$("#vl").val(vl);
var upper = $.cookie("ganglia-aggregate-graph-upper" + window.name);
if (upper != null)
$("#x").val(upper);
var lower = $.cookie("ganglia-aggregate-graph-lower" + window.name);
if (lower != null)
$("#n").val(lower);
if (hreg != null && metric != null)
return true;
else
return false;
}
$( "#metric_chooser" ).autocomplete({
source: availablemetrics,
change: function(event, ui) {
$.cookie("ganglia-aggregate-graph-metric" + window.name,
$("#metric_chooser").val());
}
});
if (restoreAggregateGraph())
createAggregateGraph();
});
</script>
<div id="aggregate_graph_header">
<h2>Create aggregate graphs</h2>
<form id="aggregate_graph_form">
<table id="aggregate_graph_table_form">
<tr>
<td>Title:</td>
<td colspan=2><input name="title" id="title" value="" size=60></td>
</tr>
<tr>
<td>Vertical (Y-Axis) label:</td>
<td colspan=2><input name="vl" id="vl" value="" size=60></td>
</tr>
<tr>
<td>Limits</td><td>Upper:<input name="x" id="x" value="" size=10></td><td>Lower:<input name="n" id="n" value="" size=10></td>
</tr>
<tr>
<td>Host Regular expression e.g. web-[0,4], web or (web|db):</td>
<td colspan=2><input name="hreg[]" id="hreg" size=60></td>
</tr>
<tr><td>Metric Regular expression (not a report e.g. load_one, bytes_(in|out)):</td>
<td colspan=2><input name="mreg[]" id="metric_chooser" size=60></td>
</tr>
<tr>
<td>Graph Type:</td><td>
<div id="graph_type_menu"><input type="radio" name="gtype" id="gtline" value="line" checked /><label for="gtline">Line</label>
<input type="radio" name="gtype" id="gtstack" value="stack" /><label for="gtstack">Stacked</label></div>
</td>
</tr>
<tr>
<td>Legend options:</td><td>
<div id="graph_legend_menu"><input type="radio" name="glegend" id="glshow" value="show" checked /><label for="glshow">Show legend</label>
<input type="radio" name="glegend" id="glhide" value="hide" /><label for="glhide">Hide legend</label></div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<button class="ag_buttons" onclick="createAggregateGraph(); return false">Create Graph</button></td>
</tr>
</table>
</form>
</div>
<div style="margin-bottom:5px;" id="show_direct_link"></div>
<div id="aggregate_graph_display">
</div>