stat.html 2.28 KB
Newer Older
tarokkk committed
1 2
{% load l10n %}
<html>
Bence Dányi committed
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
    <head>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            google.load('visualization', '1.0', {'packages':['corechart']});
            google.setOnLoadCallback(drawChart);
            function drawChart() {
                var data_cpu = new google.visualization.DataTable();
                data_cpu.addColumn('string', 'Topping');
                data_cpu.addColumn('number', 'Free');
                data_cpu.addColumn('number', 'Allocated');
                data_cpu.addColumn('number', 'Used');
                data_cpu.addRows([
                    ['CPU %', {{STAT.CPU.FREE_CPU}},{{STAT.CPU.ALLOC_CPU}},{{STAT.CPU.USED_CPU}}],
                ]);
                var cpu_options = {
                    'title':'Cloud CPU usage percent (100/CPU)',
                    'width':900,
                    'height':50,
                    isStacked: true
                };
                var data_mem = new google.visualization.DataTable();
                data_mem.addColumn('string', 'Topping');
                data_mem.addColumn('number', 'Slices');
                data_mem.addRows([
                    ['Free Memory', {{STAT.MEM.FREE_MEM|unlocalize}}],
                    ['Allocated Memory', {{STAT.MEM.ALLOC_MEM|unlocalize}}],
                    ['Used Memory', {{STAT.MEM.USED_MEM|unlocalize}}],
                ]);
                var mem_options = {
                    'title':'Cloud Memory usage in {{STAT.DIMENSION}}',
                    'width':400,
                    'height':300,
                    slices: {
                        0: {color: 'blue'},
                        1:{color: 'orange'},
                        2:{color: 'red'}
                    },
                };
                var chart = new google.visualization.BarChart(document.getElementById('chart_cpu_div'));
                chart.draw(data_cpu, cpu_options);
                var chart = new google.visualization.PieChart(document.getElementById('chart_mem_div'));
                chart.draw(data_mem, mem_options);
            }
        </script>
    </head>
    <body>
        <div>Running VMs: {{STAT.VMS}}</div>
        <div id="chart_cpu_div"></div>
        <div id="chart_mem_div"></div>
    </body>
tarokkk committed
53
</html>