-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate-longrun.html
156 lines (142 loc) · 5.12 KB
/
template-longrun.html
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
<html>
<LINK REL=StyleSheet HREF="static/style.css" TYPE="text/css">
<head>
<title>gitw-http</title>
<style type="text/css">
body {
font-family: Monospace;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://localhost:12343/cv_graph.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.core.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.context.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.annotate.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.tooltips.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.zoom.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.effects.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.key.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.line.js" ></script>
<script src="http://localhost:12343/RGraph/libraries/RGraph.common.key.js" ></script>
<script type="text/javascript">
var ramUsage = 0
var ramHistory = []
d1 = [];
d2 = [];
// Pre-pad the arrays with 250 null values
for (var i=0; i< 250; ++i) {
d1.push(null);
ramHistory.push(null)
}
window.onload = function() {
setInterval ( "updateData()", 1000)
/*
g_graph = new Graph(
{
'id': "firstgraph",
'strokeStyle': "#819C58",
'fillStyle': "rgba(64,128,0,0.25)",
'call': function(){return (ramUsage) }
});
*/
drawGraph();
drawMemGraph();
}
function updateData() {
$.getJSON("http://192.168.101.196:12344/getlongtest/{{ .Name }}",
function(data){
$("#cpu").text(data["CpuUsage"]);
$("#mem").text(data["MemoryUsage"]);
$("#lsof").text(data["OpenFiles"]);
$("#memhistory").text(data["MemoryHistory"]);
ramUsage = parseInt(data["CpuUsage"], 10)
tmp = data["MemoryHistory"]
ramHistory = []
for (var i = 0; i < tmp.length; i++) {
ramHistory.push(parseInt(tmp[i], 10))
}
});
}
function getGraph(id, d1)
{
var graph = new RGraph.Line(id, d1);
graph.Set('chart.background.barcolor1', 'white');
graph.Set('chart.background.barcolor2', 'white');
graph.Set('chart.title.xaxis', 'Time');
graph.Set('chart.filled', false);
graph.Set('chart.fillstyle', ['#daf1fa', '#faa']);
graph.Set('chart.colors', ['rgb(169, 222, 244)', 'red']);
graph.Set('chart.linewidth', 2);
graph.Set('chart.ymax', 100);
graph.Set('chart.xticks', 50);
return graph;
}
function getMemGraph(id, arr)
{
var graph = new RGraph.Line(id, arr);
graph.Set('chart.background.barcolor1', 'white');
graph.Set('chart.background.barcolor2', 'white');
graph.Set('chart.title.xaxis', 'Time');
graph.Set('chart.filled', true);
graph.Set('chart.fillstyle', ['#daf1fa', '#faa']);
graph.Set('chart.colors', ['rgb(169, 222, 244)', 'red']);
graph.Set('chart.linewidth', 2);
//graph.Set('chart.ymax', 20);
graph.Set('chart.xticks', 25);
return graph;
}
function drawGraph (e)
{
// Clear the canvas and redraw the chart
RGraph.Clear(document.getElementById("cvs"));
var graph = getGraph('cvs', d1);
graph.Draw();
// Add some data to the data arrays
d1.push(ramUsage);
//d2.push(RGraph.random(5, 10));
// Get rid of the first values of the arrays
if (d1.length > 250) {
d1 = RGraph.array_shift(d1);
//d2 = RGraph.array_shift(d2);
}
setTimeout(drawGraph,50);
}
function drawMemGraph (e)
{
// Clear the canvas and redraw the chart
RGraph.Clear(document.getElementById("cvs1"));
var memgraph = getMemGraph('cvs1', ramHistory);
memgraph.Draw();
setTimeout(drawMemGraph,200);
}
</script>
</head>
<body>
<h1>System status snapshot for {{ .Name }}</h1>
<p><a href="/">Index</a></p>
<table border="0" bordercolor="#000000" style="background-color:#FFFFFF" cellpadding="2" cellspacing="2">
<tr>
<td width="300px">CPU utilization</a></td>
<td width="100px"><span id="cpu"></span>%</td>
</tr>
<tr>
<td>Memory usage - RSS </a></td>
<td width="100px"><span id="mem"></span> KiB</td>
</tr>
<tr>
<td>Open files</a></td>
<td width="100px"><span id="lsof"></span></td>
</tr>
<tr><td>
<br>CPU usage (%):<br>
<canvas id="cvs" width="400" height="150">[No canvas support]</canvas>
</td><td>
<br>Memory history (KiB)<br>
<canvas id="cvs1" width="400" height="150">[No canvas support]</canvas>
</td>
</tr>
</table>
<hr>Powered by gitw
</body>
</html>