1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

add host status checking for statistic request

This commit is contained in:
catborise 2020-05-19 00:38:20 +03:00
parent 94d6da598a
commit 3f09104980
2 changed files with 24 additions and 22 deletions

View file

@ -226,29 +226,30 @@
} }
} }
}); });
if (Boolean({{ status }}) === true) {
window.setInterval(function graph_usage() {
$.getJSON('{% url 'compute_graph' compute_id %}', function (data) {
cpuChart.data.labels.push(data.timeline);
memChart.data.labels.push(data.timeline);
window.setInterval(function graph_usage() { cpuChart.data.datasets[0].data.push(data.cpudata);
$.getJSON('{% url 'compute_graph' compute_id %}', function (data) { if (cpuChart.data.datasets[0].data.length > 10){
cpuChart.data.labels.push(data.timeline); cpuChart.data.labels.shift();
memChart.data.labels.push(data.timeline); cpuChart.data.datasets[0].data.shift();
}
memChart.options.scales.yAxes[0].ticks.max = parseInt(data.memdata.total / 1048576);
memChart.options.scales.yAxes[0].ticks.stepSize = parseInt(data.memdata.total / (1048576 * 5));
memChart.data.datasets[0].data.push(parseInt(data.memdata.usage / 1048576));
cpuChart.data.datasets[0].data.push(data.cpudata); if (memChart.data.datasets[0].data.length > 10){
if (cpuChart.data.datasets[0].data.length > 10){ memChart.data.labels.shift();
cpuChart.data.labels.shift(); memChart.data.datasets[0].data.shift();
cpuChart.data.datasets[0].data.shift(); }
}
memChart.options.scales.yAxes[0].ticks.max = parseInt(data.memdata.total / 1048576);
memChart.options.scales.yAxes[0].ticks.stepSize = parseInt(data.memdata.total / (1048576 * 5));
memChart.data.datasets[0].data.push(parseInt(data.memdata.usage / 1048576));
if (memChart.data.datasets[0].data.length > 10){ cpuChart.update();
memChart.data.labels.shift(); memChart.update();
memChart.data.datasets[0].data.shift(); });
} }, 5000);
}
cpuChart.update();
memChart.update();
});
}, 5000);
</script> </script>
{% endblock %} {% endblock %}

View file

@ -148,7 +148,8 @@ def overview(request, compute_id):
error_messages = [] error_messages = []
compute = get_object_or_404(Compute, pk=compute_id) compute = get_object_or_404(Compute, pk=compute_id)
status = 'true' if connection_manager.host_is_up(compute.type, compute.hostname) else 'false'
try: try:
conn = wvmHostDetails(compute.hostname, conn = wvmHostDetails(compute.hostname,
compute.login, compute.login,