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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>RRD Charts</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
body {
font-family: sans;
}
form div {
text-align: center;
}
h2 {
width: 750px;
padding: 0 0 0 50px;
margin: 20px auto 5px auto;
font-size: 14px;
}
.loading {
background-repeat: no-repeat;
background-position: 0 50%;
background-image: url(/assets/icons/loading.gif);
}
.range-preview {
width: 800px;
height:50px;
margin: 0 auto 0 auto;
position: relative;
}
.chart {
width:800px;
height:200px;
margin: 0 auto 0 auto;
}
.chart canvas {
}
.tickLabel {
width:50px;
overflow:hidden;
}
.legendColorBox, .legendLabel {
cursor: pointer;
}
.legend .disabled {
text-decoration: line-through;
}
input[type=checkbox] {
margin: 0;
padding: 0;
border: none;
}
</style>
<script type="text/javascript" src="assets/javascript/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="assets/javascript/flot/excanvas.min.js"></script>
<script type="text/javascript" src="assets/javascript/flot/jquery.flot.js"></script>
<script type="text/javascript" src="assets/javascript/flot/jquery.flot.stack.js"></script>
<script type="text/javascript" src="assets/javascript/flot/jquery.flot.selection.js"></script>
<script type="text/javascript" src="assets/javascript/javascriptrrd/binaryXHR.js"></script>
<script type="text/javascript" src="assets/javascript/javascriptrrd/rrdFile.js"></script>
<script type="text/javascript" src="assets/javascript/MochiKit/Base.js"></script>
<script type="text/javascript" src="assets/javascript/MochiKit/Async.js"></script>
<script type="text/javascript" src="jrrd.js"></script>
<script type="text/javascript">
var baseOptions = {
grid: {
clickable: false,
borderWidth: 1,
borderColor: "#000",
color: "#000",
backgroundColor: "#fff",
tickColor: "#eee"
},
selection: {
mode: 'x'
},
series: {
points: { show: false },
lines: {
show: true,
steps: false,
shadowSize: 0,
lineWidth: 1
},
shadowSize: 0
},
xaxis: {
mode: "time"
}
};
var stacked = {
series: {
stack: true,
lines: {
fill: 0.5
}
}
};
var recipes = [
{
title: 'CPU Usage',
data: [
['data/cpu-0/cpu-wait.rrd', 0, 'CPU-0 Wait', 'Jiffies'],
['data/cpu-1/cpu-wait.rrd', 0, 'CPU-1 Wait', 'Jiffies'],
['data/cpu-0/cpu-system.rrd', 0, 'CPU-0 System', 'Jiffies'],
['data/cpu-1/cpu-system.rrd', 0, 'CPU-1 System', 'Jiffies'],
['data/cpu-0/cpu-user.rrd', 0, 'CPU-0 User', 'Jiffies'],
['data/cpu-1/cpu-user.rrd', 0, 'CPU-1 User', 'Jiffies']
],
options: jQuery.extend(true, {}, baseOptions, stacked)
},
{
title: 'Memory',
data: [
['data/memory/memory-buffered.rrd', 0, 'Buffered', 'B'],
['data/memory/memory-used.rrd', 0, 'Used', 'B'],
['data/memory/memory-cached.rrd', 0, 'Cached', 'B'],
['data/memory/memory-free.rrd', 0, 'Free', 'B']
],
options: jQuery.extend(true, {}, baseOptions, stacked)
},
{
title: 'DNS Queries',
data: [
['data/dns/dns_opcode-Query.rrd', 0, 'Opcode Query', 'Q/sec'],
['data/dns/dns_qtype-A.rrd', 0, 'A Queries', 'Q/sec'],
['data/dns/dns_qtype-PTR.rrd', 0, 'PTR Queries', 'Q/sec'],
['data/dns/dns_rcode-NOERROR.rrd', 0, 'NOERROR', 'Q/sec']
],
options: jQuery.extend(true, {}, baseOptions)
},
{
title: 'Load Average',
data: [
['data/load/load.rrd', 'shortterm', 'Short Term', ''],
['data/load/load.rrd', 'midterm', 'Medium Term', ''],
['data/load/load.rrd', 'longterm', 'Long Term', '']
],
options: jQuery.extend(true, {}, baseOptions)
},
{
title: 'Wlan0 Throughput (B/sec)',
data: [
['data/interface/if_octets-wlan0.rrd', 'tx', 'Transmit', 'b/sec'],
['data/interface/if_octets-wlan0.rrd', 'rx', 'Receive', 'b/sec']
],
options: jQuery.extend(true, {}, baseOptions)
},
];
$(function() {
var chartTemplate = $('.chart-container').remove();
var cc = new jrrd.ChartCoordinator($('.chartRangeControl'));
cc.charts = jQuery.map(recipes, function(recipe, i) {
return jrrd.Chart.fromRecipe(
chartTemplate.clone().appendTo('.charts'), recipe);
});
$('.charts').bind("plotselected", function(event, ranges) {
cc.setTimeRange(new Date(ranges.xaxis.from),
new Date(ranges.xaxis.to));
});
$('.chart-container').live('chart_loading', function(e) {
$(this).find('.title').addClass('loading');
});
$('.chart-container').live('chart_loaded', function(e) {
$(this).find('.title').removeClass('loading');
});
cc.reset();
});
</script>
</head>
<body>
<form method="GET" class="chartRangeControl">
<div>
<label>Start: <input type="text" name="startTime" /></label>
<label>End: <input type="text" name="endTime" /></label>
<input type="submit" value="Update" />
<input type="reset" value="Reset" />
</div>
<div class="range-preview"></div>
</form>
<div class="charts">
<div class="chart-container">
<h2 class="title"></h2>
<div class="chart"></div>
</div>
</div>
</body>
</html>
|