mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Added graph scale for instance
This commit is contained in:
parent
02570cd826
commit
4a17f08740
5 changed files with 302 additions and 16 deletions
|
@ -38,43 +38,43 @@
|
|||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-pills" role="tablist">
|
||||
<li role="presentation" class="active">
|
||||
<a href="#power" id="action-button" aria-controls="power" role="tab" data-toggle="tab">
|
||||
<a href="#power" class="action-button" aria-controls="power" role="tab" data-toggle="tab">
|
||||
<span id="action-block" class="glyphicon glyphicon-off" aria-hidden="true"></span>
|
||||
{% trans "Power" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#access" id="action-button" aria-controls="access" role="tab" data-toggle="tab">
|
||||
<a href="#access" class="action-button" aria-controls="access" role="tab" data-toggle="tab">
|
||||
<span id="action-block" class="glyphicon glyphicon-lock" aria-hidden="true"></span>
|
||||
{% trans "Access" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#resize" id="action-button" aria-controls="resize" role="tab" data-toggle="tab">
|
||||
<a href="#resize" class="action-button" aria-controls="resize" role="tab" data-toggle="tab">
|
||||
<span id="action-block" class="glyphicon glyphicon-resize-full" aria-hidden="true"></span>
|
||||
{% trans "Resize" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#snapshots" id="action-button" aria-controls="snapshots" role="tab" data-toggle="tab">
|
||||
<a href="#snapshots" class="action-button" aria-controls="snapshots" role="tab" data-toggle="tab">
|
||||
<span id="action-block" class="glyphicon glyphicon-camera" aria-hidden="true"></span>
|
||||
{% trans "Snapshots" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#settings" id="action-button" aria-controls="settings" role="tab" data-toggle="tab">
|
||||
<a href="#settings" class="action-button" aria-controls="settings" role="tab" data-toggle="tab">
|
||||
<span id="action-block" class="glyphicon glyphicon-cog" aria-hidden="true"></span>
|
||||
{% trans "Settings" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#graphics" id="action-button" aria-controls="graphics" role="tab" data-toggle="tab">
|
||||
<a href="#graphics" id="chartgraphs" class="action-button" aria-controls="graphics" role="tab" data-toggle="tab">
|
||||
<span id="action-block" class="glyphicon glyphicon-signal" aria-hidden="true"></span>
|
||||
{% trans "Graphs" %}
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="#undefine" id="action-button" aria-controls="undefine" role="tab" data-toggle="tab">
|
||||
<a href="#undefine" class="action-button" aria-controls="undefine" role="tab" data-toggle="tab">
|
||||
<span id="action-block" class="glyphicon glyphicon-trash" aria-hidden="true"></span>
|
||||
{% trans "Destroy" %}
|
||||
</a>
|
||||
|
@ -689,15 +689,55 @@
|
|||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active">
|
||||
<a href="#graps" aria-controls="graps" role="tab" data-toggle="tab">
|
||||
<a href="#graphs" aria-controls="graphs" role="tab" data-toggle="tab">
|
||||
{% trans "Real Time" %}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="graps">
|
||||
<p>Graphics</p>
|
||||
<div role="tabpanel" class="tab-pane tab-pane-bordered active" id="graphs">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "CPU usage" %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="flot-chart">
|
||||
<div class="flot-chart-content" id="flot-moving-line-chart" style="padding: 0px; position: relative;">
|
||||
<canvas id="cpuChart" width="735" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% for net in networks %}
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "Bandwidth device:" %} eth{{ forloop.counter0 }}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="flot-chart">
|
||||
<div class="flot-chart-content" id="flot-moving-line-chart" style="padding: 0px; position: relative;">
|
||||
<canvas id="netEth{{ forloop.counter0 }}Chart" width="735" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for disk in disks %}
|
||||
<div class="panel panel-warning">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> {% trans "Disk I/O device:" %} {{ disk.dev }}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="flot-chart">
|
||||
<div class="flot-chart-content" id="flot-moving-line-chart" style="padding: 0px; position: relative;">
|
||||
<canvas id="blk{{ disk.dev }}Chart" width="735" height="250"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -828,4 +868,126 @@
|
|||
});
|
||||
});
|
||||
</script>
|
||||
<script src="{{ STATIC_URL }}js/Chart.min.js"></script>
|
||||
<script>
|
||||
$( "#graphics" ).click();
|
||||
</script>
|
||||
<script>
|
||||
$('#chartgraphs').on('shown.bs.tab', function (e) {
|
||||
var cpuLineData = {
|
||||
labels : [0, 0, 0, 0, 0],
|
||||
datasets : [
|
||||
{
|
||||
fillColor: "rgba(241,72,70,0.5)",
|
||||
strokeColor: "rgba(241,72,70,1)",
|
||||
pointColor : "rgba(241,72,70,1)",
|
||||
pointStrokeColor : "#fff",
|
||||
pointHighlightFill : "#fff",
|
||||
pointHighlightStroke : "rgba(220,220,220,1)",
|
||||
data : [0, 0, 0, 0, 0]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var diskLineData = {
|
||||
labels : [0, 0, 0, 0, 0],
|
||||
datasets : [
|
||||
{
|
||||
"fillColor": "rgba(83,191,189,0.5)",
|
||||
"strokeColor": "rgba(83,191,189,1)",
|
||||
"pointColor": "rgba(83,191,189,1)",
|
||||
"pointStrokeColor": "#fff",
|
||||
"data": [0, 0, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"fillColor": "rgba(249,134,33,0.5)",
|
||||
"strokeColor": "rgba(249,134,33,1)",
|
||||
"pointColor": "rgba(249,134,33,1)",
|
||||
"pointStrokeColor": "#fff",
|
||||
"data": [0, 0, 0, 0, 0]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
var netLineData = {
|
||||
labels : [0, 0, 0, 0, 0],
|
||||
datasets : [
|
||||
{
|
||||
"fillColor": "rgba(83,191,189,0.5)",
|
||||
"strokeColor": "rgba(83,191,189,1)",
|
||||
"pointColor": "rgba(83,191,189,1)",
|
||||
"pointStrokeColor": "#fff",
|
||||
"data": [0, 0, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"fillColor": "rgba(151,187,205,0.5)",
|
||||
"strokeColor": "rgba(151,187,205,1)",
|
||||
"pointColor": "rgba(151,187,205,1)",
|
||||
"pointStrokeColor": "#fff",
|
||||
"data": [0, 0, 0, 0, 0]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
var cpuOpt = {
|
||||
animation: false,
|
||||
pointDotRadius: 2,
|
||||
scaleLabel: "<%=value%> %",
|
||||
scaleOverride: true,
|
||||
scaleSteps: 10,
|
||||
scaleStepWidth: 10,
|
||||
scaleStartValue: 0,
|
||||
responsive: true
|
||||
};
|
||||
|
||||
var diskOpt = {
|
||||
animation: false,
|
||||
pointDotRadius: 2,
|
||||
scaleLabel: "<%=value%> Mb/s",
|
||||
responsive: true
|
||||
};
|
||||
|
||||
var netOpt = {
|
||||
animation: false,
|
||||
pointDotRadius: 2,
|
||||
scaleLabel: "<%=value%> Mbps",
|
||||
responsive: true
|
||||
};
|
||||
|
||||
var cpu_ctx = $("#cpuChart").get(0).getContext("2d");
|
||||
var cpuChart = new Chart(cpu_ctx).Line(cpuLineData, cpuOpt);
|
||||
|
||||
var diskChart = {};
|
||||
{% for disk in disks %}
|
||||
var disk_ctx_{{ disk.dev }} = $("#blk{{ disk.dev }}Chart").get(0).getContext("2d");
|
||||
diskChart['{{ disk.dev }}'] = new Chart(disk_ctx_{{ disk.dev }}).Line(diskLineData, diskOpt);
|
||||
{% endfor %}
|
||||
|
||||
var netChart = {};
|
||||
{% for net in networks %}
|
||||
var net_ctx_{{ forloop.counter0 }} = $("#netEth{{ forloop.counter0 }}Chart").get(0).getContext("2d");
|
||||
netChart['{{ forloop.counter0 }}'] = new Chart(net_ctx_{{ forloop.counter0 }}).Line(netLineData, netOpt);
|
||||
{% endfor %}
|
||||
|
||||
function graph_usage() {
|
||||
$.getJSON('{% url 'inst_graph' compute_id vname %}', function (data) {
|
||||
cpuChart.scale.xLabels = data.timeline;
|
||||
for (var i = 0; i < 5; i++) {
|
||||
cpuChart.datasets[0].points[i].value = data.cpudata[i];
|
||||
}
|
||||
cpuChart.update();
|
||||
});
|
||||
}
|
||||
|
||||
{##}
|
||||
{# $(function(f) {#}
|
||||
{# window.setInterval('graph_usage()', 2000);#}
|
||||
{# });#}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue