Changeset 7150


Ignore:
Timestamp:
Apr 19, 2018, 11:33:20 AM (18 months ago)
Author:
mabarracus
Message:

Ltsp graph implementation

Location:
lliurex-analytics-server/trunk/fuentes/lliurex-analytics-server/usr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lliurex-analytics-server/trunk/fuentes/lliurex-analytics-server/usr/lib/analytics-server/analytics/db.php

    r7111 r7150  
    217217                    $ltsp_mode = $specs['subtype']['MODE'];
    218218                    $ltsp_mode = substr($ltsp_mode,0,4);
    219                     $use_name[]='mode';
    220                     $use_data[]="'$ltsp_mode'";
     219                    if (strtolower($ltsp_mode) != 'null'){
     220                        $use_name[]='mode';
     221                        $use_data[]="'$ltsp_mode'";
     222                    }
    221223                }
    222224            }
     
    396398        }
    397399        // memory
    398         //$sql_2G="select year(date) as year, month(date) as month, Releases_name, count(Client_uid) as count from Client_Versions where mem < 2048000 group by Releases_name, year, month order by year desc,month desc,Releases_name asc;";
    399400        $sql_2G = "select year(t1.date) as year, month(t1.date) as month, t1.Releases_name as rel, count(t2.uuid) as count from Client_Versions t1 left join (select * from Client_Versions where mem < 2048000 ) t2 on t1.uuid = t2.uuid group by year, month, rel order by year desc,month desc,rel asc;";
    400401        $cache_key='extended_memory_2G';
     
    421422            }
    422423        }
    423         //$sql_4G="select year(date) as year, month(date) as month, Releases_name, count(Client_uid) as count from Client_Versions where mem > 2048000 and mem < 4096000 group by Releases_name, year, month order by year desc,month desc,Releases_name asc;";
    424424        $sql_4G = "select year(t1.date) as year, month(t1.date) as month, t1.Releases_name as rel, count(t2.uuid) as count from Client_Versions t1 left join (select * from Client_Versions where mem > 2048000 and mem < 4096000 ) t2 on t1.uuid = t2.uuid group by year, month, rel order by year desc,month desc,rel asc;";
    425425        $cache_key='extended_memory_4G';
     
    446446            }
    447447        }
    448         //$sql_8G="select year(date) as year, month(date) as month, Releases_name, count(Client_uid) as count from Client_Versions where mem > 4096000 group by Releases_name, year, month order by year desc,month desc,Releases_name asc;";
    449448        $sql_8G = "select year(t1.date) as year, month(t1.date) as month, t1.Releases_name as rel, count(t2.uuid) as count from Client_Versions t1 left join (select * from Client_Versions where mem > 4096000 ) t2 on t1.uuid = t2.uuid group by year, month, rel order by year desc,month desc,rel asc;";
    450449        $cache_key='extended_memory_8G';
     
    472471        }
    473472        // cpu
    474         //$sql_mono = "select year(date) as year, month(date) as month, Releases_name, count(Client_uid) as count from Client_Versions where ncpu < 2 group by Releases_name, year, month order by year desc,month desc,Releases_name asc;";
    475473        $sql_mono = "select year(t1.date) as year, month(t1.date) as month, t1.Releases_name as rel, count(t2.uuid) as count from Client_Versions t1 left join (select * from Client_Versions where ncpu = 1 ) t2 on t1.uuid = t2.uuid group by year, month, rel order by year desc,month desc,rel asc;";
    476474        $cache_key='extended_memory_cpu_mono';
     
    601599            }
    602600
    603          
    604601         // CLIENT CHANGE FLAVOUR
    605602         $sql="select year,month,count(*) as cambio_sabor_en_mes from (select year,month,Client_uid as cliente_upgradeado from (select Client_uid,year(date) as year,month(date) as month from Client_Versions where date >= '$min_date' GROUP by Client_uid,Flavours_name,year,month)t group by month,year,Client_uid having(count(*))>1)t group by year,month order by year desc,month desc limit 12";
     
    627624
    628625
    629          $sql= "select ltsp,count(*) as total from Client_Versions group by ltsp";
    630          $count_ltsp=array('null'=>0,'true'=>0,'false'=>0);
     626         //$sql= "select ltsp,count(*) as total from Client_Versions group by ltsp";
     627         $sql="select compact.year as year,compact.month as month,if(compact.type='NONE',null,compact.type) as type,ifnull(results.total,0) as total from (select * from
     628( SELECT * FROM ( SELECT * FROM ( SELECT 1 AS month UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 ) t INNER JOIN ( SELECT YEAR(NOW()) AS year UNION ALL SELECT YEAR( DATE_SUB(NOW(), INTERVAL 1 YEAR)) ) t2 ) dates WHERE str_to_date(concat(year,'-',month,'-01'),'%Y-%m-%d') >= DATE_SUB(NOW(),INTERVAL 1 YEAR) and str_to_date(concat(year,'-',month,'-01'),'%Y-%m-%d') <= now() GROUP BY YEAR, MONTH ORDER BY YEAR DESC, MONTH DESC ) last_times inner join (select 'NONE' as type union all select 0 union all select 1) types) compact left join (select month(date) as month,year(date) as year,ifnull(ltsp,'NONE') as type,count(ifnull(ltsp,1)) as total from Client_Versions where Flavours_name = 'client' group by year(date),month(date),ltsp order by year(date) desc ,month(date) desc, ltsp desc ) results on compact.month = results.month and compact.year = results.year and compact.type = results.type";
     629         //$count_ltsp=array('null'=>0,'true'=>0,'false'=>0);
     630         $count_ltsp=array();
    631631         $cache_key='extended_5';
    632632         $data=$cache->get($cache_key);
     
    639639                $this->times+=microtime(true)-$stime;
    640640                while($row=$result->fetch_array(MYSQLI_ASSOC)){
    641                     switch($row['ltsp']){
    642                         case NULL:
    643                             $count_ltsp['null'] += intval($row['total']);
    644                             break;
    645                         case '0':
    646                             $count_ltsp['false'] += intval($row['total']);
    647                             break;
    648                         case '1':
    649                             $count_ltsp['true'] += intval($row['total']);
    650                             break;
     641                    if (isset($row['type']) and $row['type'] != NULL){
     642                        $count_ltsp[]=array($row['type'],$row['total']);
    651643                    }
    652644                }
     
    657649         }
    658650         $cache_key='extended_6';
    659          $sql = "select t1.mode,count(t2.uuid) as total from (select 'THIN' as mode union all select 'SEMI' UNION ALL select 'FAT') t1 left join (select uuid,mode from Client_Versions where Flavours_name = 'client') t2 on t1.mode = t2.mode group by t1.mode";
     651         //$sql = "select t1.mode,count(t2.uuid) as total from (select 'THIN' as mode union all select 'SEMI' UNION ALL select 'FAT') t1 left join (select uuid,mode from Client_Versions where Flavours_name = 'client') t2 on t1.mode = t2.mode group by t1.mode";
     652         $sql= "select compact.year as year,compact.month as month,if(compact.mode='NONE',null,compact.mode) as mode,ifnull(results.total,0) as total from (select * from ( SELECT * FROM ( SELECT * FROM ( SELECT 1 AS month UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 ) t INNER JOIN ( SELECT YEAR(NOW()) AS year UNION ALL SELECT YEAR( DATE_SUB(NOW(), INTERVAL 1 YEAR)) ) t2 ) dates WHERE str_to_date(concat(year,'-',month,'-01'),'%Y-%m-%d') >= DATE_SUB(NOW(),INTERVAL 1 YEAR) and str_to_date(concat(year,'-',month,'-01'),'%Y-%m-%d') <= now() GROUP BY YEAR, MONTH ORDER BY YEAR DESC, MONTH DESC ) last_times inner join (select 'NONE' as mode union all select 'THIN' union all select 'SEMI' union all select 'FAT') types) compact left join (select month(date) as month,year(date) as year,ifnull(mode,'NONE') as mode,count(ifnull(mode,1)) as total from Client_Versions where Flavours_name = 'client' group by year(date),month(date),mode order by year(date) desc ,month(date) desc, mode desc ) results on compact.month = results.month and compact.year = results.year and compact.mode = results.mode";
    660653         $data= $cache->get($cache_key);
    661654         $stime=microtime(true);
    662          $count_mode=array('thin'=>0,'semi'=>0,'fat'=>0);
     655         //$count_mode=array('thin'=>0,'semi'=>0,'fat'=>0);
     656         $count_mode=array();
    663657         if ($data != false){
    664658            $count_mode=$data;
     
    668662                $this->times+=microtime(true)-$stime;
    669663                while($row=$result->fetch_array(MYSQLI_ASSOC)){
    670                     switch($row['mode']){
    671                         case 'THIN':
    672                             $count_mode['thin']+=intval($row['total']);
    673                             break;
    674                         case 'SEMI':
    675                             $count_mode['semi']+=intval($row['total']);
    676                             break;
    677                         case 'FAT':
    678                             $count_mode['fat']+=intval($row['total']);
    679                             break;
     664                    if (isset($row['mode']) and $row['mode'] != NULL){
     665                        $count_mode[]=array(strtolower($row['mode']),$row['total']);
    680666                    }
    681667                }
     
    757743         }
    758744         if (isset($count_ltsp)){
    759              $stats['count_ltsp']=$count_ltsp;
     745             $stats['clients']['count_ltsp']=$count_ltsp;
    760746         }
    761747         if (isset($clients_more)){
    762              $stats['count_mode']=$count_mode;
     748             $stats['clients']['count_mode']=$count_mode;
    763749         }
    764750         $stats['debug_query_time']=strval(number_format($this->times,5));
  • lliurex-analytics-server/trunk/fuentes/lliurex-analytics-server/usr/lib/analytics-server/analytics/graph.js

    r6889 r7150  
    9696                    isStacked: false,
    9797                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
    98                     vAxis:{title:'Num hosts',viewWindow : {min:0}},
     98                    vAxis:{title:'Num hosts',viewWindow : {min:0},format:'#'},
    9999                    legend:{textStyle:{fontSize: 10}},
    100100                    chartArea:{left:'5%',right:'10%'},
     
    147147                    isStacked: false,
    148148                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
    149                     vAxis:{title:'Num hosts',viewWindow : {min:0}},
     149                    vAxis:{title:'Num hosts',viewWindow : {min:0},format:'#'},
    150150                    legend:{textStyle:{fontSize: 10}},
    151151                    chartArea:{left:'5%',right:'10%'},
     
    198198                    isStacked: false,
    199199                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
    200                     vAxis:{title:'Num hosts'},
     200                    vAxis:{title:'Num hosts',viewWindow : {min:0},format:'#'},
    201201                    legend:{textStyle:{fontSize: 10}},
    202202                    chartArea:{left:'5%',right:'10%'},
     
    253253                    isStacked: false,
    254254                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
    255                     vAxis:{title:'Num hosts'},
     255                    vAxis:{title:'Num hosts',viewWindow : {min:0},format:'#'},
    256256                    legend:{textStyle:{fontSize: 10}},
    257257                    chartArea:{left:'5%',right:'10%'},
     
    262262    return {data:data_table,options:options}
    263263}
    264 
     264function build_data_per_month_ltsp_usage(data,title){
     265    var total=[];
     266    var group_items=2
     267    for (var i=0 ; i < 12*group_items; i++){
     268        var item_no=Math.floor(i/group_items)
     269        if (! data[i]){
     270            continue;
     271        }
     272        if (! total[item_no]){
     273            total[item_no]={0:0,1:0}
     274        }
     275        total[item_no][parseInt(data[i][0])]=parseInt(data[i][1])
     276    }
     277    var dates_axis=[];
     278    var d= new Date();
     279    var data_table = new google.visualization.DataTable();
     280    data_table.addColumn({type:'date',role:'domain'},'Date');
     281    data_table.addColumn('number','Total normal clients');
     282    data_table.addColumn({type:'string',role:'style'},'Total normal clients style');
     283    data_table.addColumn('number','Total ltsp clients');
     284    data_table.addColumn({type:'string',role:'style'},'Total ltsp clients style');
     285
     286    date_values=[];
     287    for (i=1;i <= 12;i++){
     288        month=d.getMonth();
     289        year=d.getFullYear();
     290        date_to_add=new Date(year,month)
     291        dates_axis.push(date_to_add);
     292        date_values.push([date_to_add,total[i-1][0],'color:purple',total[i-1][1],'color:gold'])
     293        d.setMonth(month-1);
     294    }
     295    data_table.addRows(date_values);
     296    var options= {  title: title,
     297                    curveType: 'function',
     298                    isStacked: false,
     299                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
     300                    vAxis:{title:'Num hosts',viewWindow : {min:0},format:'#'},
     301                    legend:{textStyle:{fontSize: 10}},
     302                    chartArea:{left:'5%',right:'10%'},
     303                    focusTarget: 'category',
     304                    colors: ['purple','gold'],
     305                    lineWidth: 5,
     306                    };
     307    return {data:data_table,options:options}
     308
     309}
     310function build_data_per_month_ltsp_modes(data,title){
     311    var total=[];
     312    var group_items=3
     313    for (var i=0 ; i < 12*group_items; i++){
     314        var item_no=Math.floor(i/group_items)
     315        if (! data[i]){
     316            continue;
     317        }
     318        if (! total[item_no]){
     319            total[item_no]={'thin':0,'semi':0, 'fat':0}
     320        }
     321        total[item_no][data[i][0]]=parseInt(data[i][1])
     322    }
     323    var dates_axis=[];
     324    var d= new Date();
     325    var data_table = new google.visualization.DataTable();
     326    data_table.addColumn({type:'date',role:'domain'},'Date');
     327    data_table.addColumn('number','Total thin clients');
     328    data_table.addColumn({type:'string',role:'style'},'Total thin clients style');
     329    data_table.addColumn('number','Total semi clients');
     330    data_table.addColumn({type:'string',role:'style'},'Total semi clients style');
     331    data_table.addColumn('number','Total fat clients');
     332    data_table.addColumn({type:'string',role:'style'},'Total fat clients style');
     333
     334    date_values=[];
     335    for (i=1;i <= 12;i++){
     336        month=d.getMonth();
     337        year=d.getFullYear();
     338        date_to_add=new Date(year,month)
     339        dates_axis.push(date_to_add);
     340        date_values.push([date_to_add,total[i-1]['thin'],'color:purple',total[i-1]['semi'],'color:gold',total[i-1]['fat'],'color:olive'])
     341        d.setMonth(month-1);
     342    }
     343    data_table.addRows(date_values);
     344    var options= {  title: title,
     345                    curveType: 'function',
     346                    isStacked: false,
     347                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
     348                    vAxis:{title:'Num hosts',viewWindow : {min:0},format: '#'},
     349                    legend:{textStyle:{fontSize: 10}},
     350                    chartArea:{left:'5%',right:'10%'},
     351                    focusTarget: 'category',
     352                    colors: ['purple','gold','olive'],
     353                    lineWidth: 5,
     354                    };
     355    return {data:data_table,options:options}
     356
     357}
    265358function build_data_per_month_cpu(data,title){
    266359    var total=[];
     
    308401                    isStacked: false,
    309402                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
    310                     vAxis:{title:'Num hosts',viewWindow : {min:0}},
     403                    vAxis:{title:'Num hosts',viewWindow : {min:0},format:'#'},
    311404                    legend:{textStyle:{fontSize: 10}},
    312405                    chartArea:{left:'5%',right:'10%'},
     
    337430                    isStacked: false,
    338431                    hAxis:{title:'Months',ticks:dates_axis,format:'MMM'},
    339                     vAxis:{title:'Num hosts',minValue: 0,maxValue:'automatic',viewWindowMode:'pretty',viewWindow:{min:0,max:'auto'}},
     432                    vAxis:{title:'Num hosts',minValue: 0,maxValue:'automatic',viewWindowMode:'pretty',viewWindow:{min:0,max:'auto'},format:'#'},
    340433                    legend:{textStyle:{fontSize: 10}},
    341434                    chartArea:{left:'10%',right:'10%'},
     
    432525                        chart_data['cpu']['releases']['title']='Number CpuS distribution'
    433526                        break;
    434                    
     527                    case 'count_ltsp':
     528                    case 'count_mode':
     529                        if (! chart_data['ltsp']){
     530                            chart_data['ltsp']={}
     531                            chart_data['ltsp']['title']='LTSP Usage'
     532                        }
     533                        if (type == 'count_ltsp'){
     534                            if (! chart_data['ltsp']['usage']){
     535                                chart_data['ltsp']['usage']={}
     536                                chart_data['ltsp']['usage']['graph']=build_data_per_month_ltsp_usage(json[key][type],'LTSP usage per month')
     537                                chart_data['ltsp']['usage']['title']='LTSP Use'
     538                            }
     539                        }
     540                        if (type == 'count_mode'){
     541                            if (! chart_data['ltsp']['modes']){
     542                                chart_data['ltsp']['modes']={}
     543                                chart_data['ltsp']['modes']['graph']=build_data_per_month_ltsp_modes(json[key][type],'LTSP type by type per month')
     544                                chart_data['ltsp']['modes']['title']='Clients LTSP Mode'
     545                            }
     546                        }
     547                        break;
    435548                }
    436549            }
     
    467580    }
    468581
    469     for (chart_type in chart_data){
     582    for (var chart_type in chart_data){
    470583        if (! chart_data[chart_type]['title']){
    471584            continue;
    472585        }
    473 
    474         for (chart_variant in chart_data[chart_type]){
     586        for (var chart_variant in chart_data[chart_type]){
    475587            if (chart_variant == 'title'){
    476588                $('#accordion').append('<h3 class="'+chart_type+'">'+chart_data[chart_type]['title']+'</h3><div id="'+chart_type+'"></div>');
  • lliurex-analytics-server/trunk/fuentes/lliurex-analytics-server/usr/lib/analytics-server/analytics/graph_min.js

    r6889 r7150  
    1 function drawChart(c,a,b,g){var e=.95*$("#"+b).parent().width();g=10>g?$(window).height()/3*.75:20*g;a={title:a,width:e,height:g,fontSize:10,legend:"none",hAxis:{viewWindow:{min:0}},chartArea:{left:"10%",right:"5%"}};c=new google.visualization.DataView(c);c.setColumns([0,1,{calc:"stringify",sourceColumn:1,type:"string",role:"annotation"}]);b=new google.visualization.BarChart(document.getElementById(b));google.visualization.events.addListener(b,"ready",ready_charts);b.draw(c,a)}
    2 function get_sizes(c){c=.95*$("#"+c).parent().width();var a=.72*$(window).height()/2;return{width:c,height:a}}
    3 function build_data_per_month_releases(c,a){var b=[];for(i=0;12>i;i++)if(b[i]={15:0,16:0,all:0},c[i]){for(rel in c[i]){if("15"==rel)for(fla in c[i][rel])b[i][rel]+=c[i][rel][fla];if("16"==rel)for(fla in c[i][rel])b[i][rel]+=c[i][rel][fla]}b[i].all=b[i]["15"]+b[i]["16"]}var g=[],e=new Date,d=new google.visualization.DataTable;d.addColumn({type:"date",role:"domain"},"Release");d.addColumn("number","Total Release 15");d.addColumn({type:"string",role:"style"},"Style Release 15");d.addColumn("number",
    4 "Total Release 16");d.addColumn({type:"string",role:"style"},"Style Release 16");d.addColumn("number","Total ALL Releases");d.addColumn({type:"string",role:"style"},"Style ALL Releases");date_values=[];for(i=1;12>=i;i++)month=e.getMonth(),year=e.getFullYear(),date_to_add=new Date(year,month),g.push(date_to_add),date_values.push([date_to_add,b[i-1]["15"],"color:blue",b[i-1]["16"],"color:red",b[i-1].all,"color:grey"]),e.setMonth(month-1);d.addRows(date_values);return{data:d,options:{title:a,curveType:"function",
    5 isStacked:!1,hAxis:{title:"Months",ticks:g,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0}},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:["blue","red","grey"],lineWidth:5}}}
    6 function build_data_per_month_flavours(c,a){var b=[];for(i=0;12>i;i++)if(b[i]={server:0,client:0,desktop:0,other:0,all:0},c[i])for(rel in c[i])for(fla in c[i][rel])b[i][fla]+=c[i][rel][fla],b[i].all+=c[i][rel][fla];var g=[],e=new Date,d=new google.visualization.DataTable;d.addColumn({type:"date",role:"domain"},"Flavour");d.addColumn("number","Total Server");d.addColumn({type:"string",role:"style"},"Style Server");d.addColumn("number","Total Client");d.addColumn({type:"string",role:"style"},"Style Client");
    7 d.addColumn("number","Total Desktop");d.addColumn({type:"string",role:"style"},"Style Desktop");d.addColumn("number","Total Other");d.addColumn({type:"string",role:"style"},"Style Other");d.addColumn("number","Total ALL Flavours");d.addColumn({type:"string",role:"style"},"Style Total ALL Flavours");date_values=[];for(i=1;12>=i;i++)month=e.getMonth(),year=e.getFullYear(),date_to_add=new Date(year,month),g.push(date_to_add),date_values.push([date_to_add,b[i-1].server,"color:purple",b[i-1].client,"color:teal",
    8 b[i-1].desktop,"color:gold",b[i-1].other,"color:olive",b[i-1].all,"color:grey"]),e.setMonth(month-1);d.addRows(date_values);return{data:d,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:g,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0}},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:["purple","teal","gold","olive","grey"],lineWidth:5}}}
    9 function build_data_per_month_arch(c,a){var b=[];for(i=0;12>i;i++)if(b[i]={"15_i386":0,"15_x86_64":0,"16_i386":0,"16_x86_64":0},c[i])for(rel in c[i])for(arch in c[i][rel])b[i][rel+"_"+arch]+=c[i][rel][arch];var g=[],e=new Date,d=new google.visualization.DataTable;d.addColumn({type:"date",role:"domain"},"Date");d.addColumn("number","Total 15 x86");d.addColumn({type:"string",role:"style"},"Style 15 x86");d.addColumn("number","Total 15 x86_64");d.addColumn({type:"string",role:"style"},"Style 15 x86_64");
    10 d.addColumn("number","Total 16 x86");d.addColumn({type:"string",role:"style"},"Style 16 x86");d.addColumn("number","Total 16 x86_64");d.addColumn({type:"string",role:"style"},"Style 16 x86_64");date_values=[];for(i=1;12>=i;i++)month=e.getMonth(),year=e.getFullYear(),date_to_add=new Date(year,month),g.push(date_to_add),date_values.push([date_to_add,b[i-1]["15_i386"],"color:purple",b[i-1]["15_x86_64"],"color:gold",b[i-1]["16_i386"],"color:teal",b[i-1]["16_x86_64"],"color:olive"]),e.setMonth(month-1);
    11 d.addRows(date_values);return{data:d,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:g,format:"MMM"},vAxis:{title:"Num hosts"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:["purple","gold","teal","olive"],lineWidth:5}}}
    12 function build_data_per_month_mem(c,a){for(var b=[],g=["2G","4G","8G"],e=0;12>e;e++){b[e]={"15_2G":0,"15_4G":0,"15_8G":0,"16_2G":0,"16_4G":0,"16_8G":0};for(var d in g)if(c[g[d]][e])for(var f in c[g[d]][e])b[e][f+"_"+g[d]]+=c[g[d]][e][f]}g=[];d=new Date;f=new google.visualization.DataTable;f.addColumn({type:"date",role:"domain"},"Date");f.addColumn("number","Total 15 < 2G");f.addColumn({type:"string",role:"style"},"Style 15 < 2G");f.addColumn("number","Total 15 < 4G");f.addColumn({type:"string",role:"style"},
    13 "Style 15 < 4G");f.addColumn("number","Total 15 > 4G");f.addColumn({type:"string",role:"style"},"Style 15 > 4G");f.addColumn("number","Total 16 < 2G");f.addColumn({type:"string",role:"style"},"Style 16 < 2G");f.addColumn("number","Total 16 < 4G");f.addColumn({type:"string",role:"style"},"Style 16 < 4G");f.addColumn("number","Total 16 > 4G");f.addColumn({type:"string",role:"style"},"Style 16 > 4G");date_values=[];for(e=1;12>=e;e++)month=d.getMonth(),year=d.getFullYear(),date_to_add=new Date(year,month),
    14 g.push(date_to_add),date_values.push([date_to_add,b[e-1]["15_2G"],"color:purple",b[e-1]["15_4G"],"color:gold",b[e-1]["15_8G"],"color:teal",b[e-1]["16_2G"],"color:olive",b[e-1]["16_4G"],"color:red",b[e-1]["16_8G"],"color:pink"]),d.setMonth(month-1);f.addRows(date_values);return{data:f,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:g,format:"MMM"},vAxis:{title:"Num hosts"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:"purple gold teal olive red pink".split(" "),
    15 lineWidth:5}}}
    16 function build_data_per_month_cpu(c,a){for(var b=[],g=["mono","dualquad","more"],e=0;12>e;e++){b[e]={"15_mono":0,"15_dualquad":0,"15_more":0,"16_mono":0,"16_dualquad":0,"16_more":0};for(var d in g)if(c[g[d]][e])for(var f in c[g[d]][e])b[e][f+"_"+g[d]]+=c[g[d]][e][f]}g=[];d=new Date;f=new google.visualization.DataTable;f.addColumn({type:"date",role:"domain"},"Date");f.addColumn("number","Total 15 mono processor");f.addColumn({type:"string",role:"style"},"Style 15 mono processor");f.addColumn("number","Total 15 dual or quad processor");
    17 f.addColumn({type:"string",role:"style"},"Style 15 dual or quad processor");f.addColumn("number","Total 15 more than quad processor");f.addColumn({type:"string",role:"style"},"Style 15 more than quad processor");f.addColumn("number","Total 16 mono processor");f.addColumn({type:"string",role:"style"},"Style 16 mono processor");f.addColumn("number","Total 16 dual or quad processor");f.addColumn({type:"string",role:"style"},"Style 16 dual or quad processor");f.addColumn("number","Total 16 more than quad processor");
    18 f.addColumn({type:"string",role:"style"},"Style 16 more than quad processor");date_values=[];for(e=1;12>=e;e++)month=d.getMonth(),year=d.getFullYear(),date_to_add=new Date(year,month),g.push(date_to_add),date_values.push([date_to_add,b[e-1]["15_mono"],"color:purple",b[e-1]["15_dualquad"],"color:gold",b[e-1]["15_more"],"color:teal",b[e-1]["16_mono"],"color:olive",b[e-1]["16_dualquad"],"color:red",b[e-1]["16_more"],"color:pink"]),d.setMonth(month-1);f.addRows(date_values);return{data:f,options:{title:a,
    19 curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:g,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0}},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:"purple gold teal olive red pink".split(" "),lineWidth:5}}}
    20 function build_data_from_array(c,a){var b=[],g=new Date,e=new google.visualization.DataTable;e.addColumn({type:"date",role:"domain"},"Nhosts");e.addColumn("number",a);date_values=[];for(i=1;12>=i;i++)month=g.getMonth(),year=g.getFullYear(),date_to_add=new Date(year,month),b.push(date_to_add),date_values.push([date_to_add,c[i-1]]),g.setMonth(month-1);e.addRows(date_values);return{data:e,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:b,format:"MMM"},vAxis:{title:"Num hosts",
    21 minValue:0,maxValue:"automatic",viewWindowMode:"pretty",viewWindow:{min:0,max:"auto"}},legend:{textStyle:{fontSize:10}},chartArea:{left:"10%",right:"10%"},focusTarget:"category",lineWidth:5}}}
    22 function doExtendedChart(){end_load_time=get_time();var c=window.location.search.substr(1);""!=c&&(c="?"+c);var a={};start_get_time=get_time();$("#accordion").append('<div id="loading"></div>');$.getJSON("./GetExtendedStats"+c,function(b){start_graph_time=end_get_time=get_time();var c=null;for(key in b){if("clients"==key)for(type in b[key])switch(type){case "clients_per_month":a[type]={};a[type].title="Machines";a[type].releases={};a[type].releases.graph=build_data_per_month_releases(b[key][type],
     1function drawChart(f,a,b,e){var c=.95*$("#"+b).parent().width();e=10>e?$(window).height()/3*.75:20*e;a={title:a,width:c,height:e,fontSize:10,legend:"none",hAxis:{viewWindow:{min:0}},chartArea:{left:"10%",right:"5%"}};f=new google.visualization.DataView(f);f.setColumns([0,1,{calc:"stringify",sourceColumn:1,type:"string",role:"annotation"}]);b=new google.visualization.BarChart(document.getElementById(b));google.visualization.events.addListener(b,"ready",ready_charts);b.draw(f,a)}
     2function get_sizes(f){f=.95*$("#"+f).parent().width();var a=.72*$(window).height()/2;return{width:f,height:a}}
     3function build_data_per_month_releases(f,a){var b=[];for(i=0;12>i;i++)if(b[i]={15:0,16:0,all:0},f[i]){for(rel in f[i]){if("15"==rel)for(fla in f[i][rel])b[i][rel]+=f[i][rel][fla];if("16"==rel)for(fla in f[i][rel])b[i][rel]+=f[i][rel][fla]}b[i].all=b[i]["15"]+b[i]["16"]}var e=[],c=new Date,d=new google.visualization.DataTable;d.addColumn({type:"date",role:"domain"},"Release");d.addColumn("number","Total Release 15");d.addColumn({type:"string",role:"style"},"Style Release 15");d.addColumn("number",
     4"Total Release 16");d.addColumn({type:"string",role:"style"},"Style Release 16");d.addColumn("number","Total ALL Releases");d.addColumn({type:"string",role:"style"},"Style ALL Releases");date_values=[];for(i=1;12>=i;i++)month=c.getMonth(),year=c.getFullYear(),date_to_add=new Date(year,month),e.push(date_to_add),date_values.push([date_to_add,b[i-1]["15"],"color:blue",b[i-1]["16"],"color:red",b[i-1].all,"color:grey"]),c.setMonth(month-1);d.addRows(date_values);return{data:d,options:{title:a,curveType:"function",
     5isStacked:!1,hAxis:{title:"Months",ticks:e,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:["blue","red","grey"],lineWidth:5}}}
     6function build_data_per_month_flavours(f,a){var b=[];for(i=0;12>i;i++)if(b[i]={server:0,client:0,desktop:0,other:0,all:0},f[i])for(rel in f[i])for(fla in f[i][rel])b[i][fla]+=f[i][rel][fla],b[i].all+=f[i][rel][fla];var e=[],c=new Date,d=new google.visualization.DataTable;d.addColumn({type:"date",role:"domain"},"Flavour");d.addColumn("number","Total Server");d.addColumn({type:"string",role:"style"},"Style Server");d.addColumn("number","Total Client");d.addColumn({type:"string",role:"style"},"Style Client");
     7d.addColumn("number","Total Desktop");d.addColumn({type:"string",role:"style"},"Style Desktop");d.addColumn("number","Total Other");d.addColumn({type:"string",role:"style"},"Style Other");d.addColumn("number","Total ALL Flavours");d.addColumn({type:"string",role:"style"},"Style Total ALL Flavours");date_values=[];for(i=1;12>=i;i++)month=c.getMonth(),year=c.getFullYear(),date_to_add=new Date(year,month),e.push(date_to_add),date_values.push([date_to_add,b[i-1].server,"color:purple",b[i-1].client,"color:teal",
     8b[i-1].desktop,"color:gold",b[i-1].other,"color:olive",b[i-1].all,"color:grey"]),c.setMonth(month-1);d.addRows(date_values);return{data:d,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:e,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:["purple","teal","gold","olive","grey"],lineWidth:5}}}
     9function build_data_per_month_arch(f,a){var b=[];for(i=0;12>i;i++)if(b[i]={"15_i386":0,"15_x86_64":0,"16_i386":0,"16_x86_64":0},f[i])for(rel in f[i])for(arch in f[i][rel])b[i][rel+"_"+arch]+=f[i][rel][arch];var e=[],c=new Date,d=new google.visualization.DataTable;d.addColumn({type:"date",role:"domain"},"Date");d.addColumn("number","Total 15 x86");d.addColumn({type:"string",role:"style"},"Style 15 x86");d.addColumn("number","Total 15 x86_64");d.addColumn({type:"string",role:"style"},"Style 15 x86_64");
     10d.addColumn("number","Total 16 x86");d.addColumn({type:"string",role:"style"},"Style 16 x86");d.addColumn("number","Total 16 x86_64");d.addColumn({type:"string",role:"style"},"Style 16 x86_64");date_values=[];for(i=1;12>=i;i++)month=c.getMonth(),year=c.getFullYear(),date_to_add=new Date(year,month),e.push(date_to_add),date_values.push([date_to_add,b[i-1]["15_i386"],"color:purple",b[i-1]["15_x86_64"],"color:gold",b[i-1]["16_i386"],"color:teal",b[i-1]["16_x86_64"],"color:olive"]),c.setMonth(month-1);
     11d.addRows(date_values);return{data:d,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:e,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:["purple","gold","teal","olive"],lineWidth:5}}}
     12function build_data_per_month_mem(f,a){for(var b=[],e=["2G","4G","8G"],c=0;12>c;c++){b[c]={"15_2G":0,"15_4G":0,"15_8G":0,"16_2G":0,"16_4G":0,"16_8G":0};for(var d in e)if(f[e[d]][c])for(var g in f[e[d]][c])b[c][g+"_"+e[d]]+=f[e[d]][c][g]}e=[];d=new Date;g=new google.visualization.DataTable;g.addColumn({type:"date",role:"domain"},"Date");g.addColumn("number","Total 15 < 2G");g.addColumn({type:"string",role:"style"},"Style 15 < 2G");g.addColumn("number","Total 15 < 4G");g.addColumn({type:"string",role:"style"},
     13"Style 15 < 4G");g.addColumn("number","Total 15 > 4G");g.addColumn({type:"string",role:"style"},"Style 15 > 4G");g.addColumn("number","Total 16 < 2G");g.addColumn({type:"string",role:"style"},"Style 16 < 2G");g.addColumn("number","Total 16 < 4G");g.addColumn({type:"string",role:"style"},"Style 16 < 4G");g.addColumn("number","Total 16 > 4G");g.addColumn({type:"string",role:"style"},"Style 16 > 4G");date_values=[];for(c=1;12>=c;c++)month=d.getMonth(),year=d.getFullYear(),date_to_add=new Date(year,month),
     14e.push(date_to_add),date_values.push([date_to_add,b[c-1]["15_2G"],"color:purple",b[c-1]["15_4G"],"color:gold",b[c-1]["15_8G"],"color:teal",b[c-1]["16_2G"],"color:olive",b[c-1]["16_4G"],"color:red",b[c-1]["16_8G"],"color:pink"]),d.setMonth(month-1);g.addRows(date_values);return{data:g,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:e,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},
     15focusTarget:"category",colors:"purple gold teal olive red pink".split(" "),lineWidth:5}}}
     16function build_data_per_month_ltsp_usage(f,a){for(var b=[],e=0;24>e;e++){var c=Math.floor(e/2);f[e]&&(b[c]||(b[c]={0:0,1:0}),b[c][parseInt(f[e][0])]=parseInt(f[e][1]))}c=[];var d=new Date,g=new google.visualization.DataTable;g.addColumn({type:"date",role:"domain"},"Date");g.addColumn("number","Total normal clients");g.addColumn({type:"string",role:"style"},"Total normal clients style");g.addColumn("number","Total ltsp clients");g.addColumn({type:"string",role:"style"},"Total ltsp clients style");
     17date_values=[];for(e=1;12>=e;e++)month=d.getMonth(),year=d.getFullYear(),date_to_add=new Date(year,month),c.push(date_to_add),date_values.push([date_to_add,b[e-1][0],"color:purple",b[e-1][1],"color:gold"]),d.setMonth(month-1);g.addRows(date_values);return{data:g,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:c,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",
     18colors:["purple","gold"],lineWidth:5}}}
     19function build_data_per_month_ltsp_modes(f,a){for(var b=[],e=0;36>e;e++){var c=Math.floor(e/3);f[e]&&(b[c]||(b[c]={thin:0,semi:0,fat:0}),b[c][f[e][0]]=parseInt(f[e][1]))}c=[];var d=new Date,g=new google.visualization.DataTable;g.addColumn({type:"date",role:"domain"},"Date");g.addColumn("number","Total thin clients");g.addColumn({type:"string",role:"style"},"Total thin clients style");g.addColumn("number","Total semi clients");g.addColumn({type:"string",role:"style"},"Total semi clients style");g.addColumn("number",
     20"Total fat clients");g.addColumn({type:"string",role:"style"},"Total fat clients style");date_values=[];for(e=1;12>=e;e++)month=d.getMonth(),year=d.getFullYear(),date_to_add=new Date(year,month),c.push(date_to_add),date_values.push([date_to_add,b[e-1].thin,"color:purple",b[e-1].semi,"color:gold",b[e-1].fat,"color:olive"]),d.setMonth(month-1);g.addRows(date_values);return{data:g,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:c,format:"MMM"},vAxis:{title:"Num hosts",
     21viewWindow:{min:0},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:["purple","gold","olive"],lineWidth:5}}}
     22function build_data_per_month_cpu(f,a){for(var b=[],e=["mono","dualquad","more"],c=0;12>c;c++){b[c]={"15_mono":0,"15_dualquad":0,"15_more":0,"16_mono":0,"16_dualquad":0,"16_more":0};for(var d in e)if(f[e[d]][c])for(var g in f[e[d]][c])b[c][g+"_"+e[d]]+=f[e[d]][c][g]}e=[];d=new Date;g=new google.visualization.DataTable;g.addColumn({type:"date",role:"domain"},"Date");g.addColumn("number","Total 15 mono processor");g.addColumn({type:"string",role:"style"},"Style 15 mono processor");g.addColumn("number",
     23"Total 15 dual or quad processor");g.addColumn({type:"string",role:"style"},"Style 15 dual or quad processor");g.addColumn("number","Total 15 more than quad processor");g.addColumn({type:"string",role:"style"},"Style 15 more than quad processor");g.addColumn("number","Total 16 mono processor");g.addColumn({type:"string",role:"style"},"Style 16 mono processor");g.addColumn("number","Total 16 dual or quad processor");g.addColumn({type:"string",role:"style"},"Style 16 dual or quad processor");g.addColumn("number",
     24"Total 16 more than quad processor");g.addColumn({type:"string",role:"style"},"Style 16 more than quad processor");date_values=[];for(c=1;12>=c;c++)month=d.getMonth(),year=d.getFullYear(),date_to_add=new Date(year,month),e.push(date_to_add),date_values.push([date_to_add,b[c-1]["15_mono"],"color:purple",b[c-1]["15_dualquad"],"color:gold",b[c-1]["15_more"],"color:teal",b[c-1]["16_mono"],"color:olive",b[c-1]["16_dualquad"],"color:red",b[c-1]["16_more"],"color:pink"]),d.setMonth(month-1);g.addRows(date_values);
     25return{data:g,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:e,format:"MMM"},vAxis:{title:"Num hosts",viewWindow:{min:0},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"5%",right:"10%"},focusTarget:"category",colors:"purple gold teal olive red pink".split(" "),lineWidth:5}}}
     26function build_data_from_array(f,a){var b=[],e=new Date,c=new google.visualization.DataTable;c.addColumn({type:"date",role:"domain"},"Nhosts");c.addColumn("number",a);date_values=[];for(i=1;12>=i;i++)month=e.getMonth(),year=e.getFullYear(),date_to_add=new Date(year,month),b.push(date_to_add),date_values.push([date_to_add,f[i-1]]),e.setMonth(month-1);c.addRows(date_values);return{data:c,options:{title:a,curveType:"function",isStacked:!1,hAxis:{title:"Months",ticks:b,format:"MMM"},vAxis:{title:"Num hosts",
     27minValue:0,maxValue:"automatic",viewWindowMode:"pretty",viewWindow:{min:0,max:"auto"},format:"#"},legend:{textStyle:{fontSize:10}},chartArea:{left:"10%",right:"10%"},focusTarget:"category",lineWidth:5}}}
     28function doExtendedChart(){end_load_time=get_time();var f=window.location.search.substr(1);""!=f&&(f="?"+f);var a={};start_get_time=get_time();$("#accordion").append('<div id="loading"></div>');$.getJSON("./GetExtendedStats"+f,function(b){start_graph_time=end_get_time=get_time();var e=null;for(key in b){if("clients"==key)for(type in b[key])switch(type){case "clients_per_month":a[type]={};a[type].title="Machines";a[type].releases={};a[type].releases.graph=build_data_per_month_releases(b[key][type],
    2329"Number machines by release per month");a[type].releases.title="Number machines by release per month";a[type].flavours={};a[type].flavours.graph=build_data_per_month_flavours(b[key][type],"Number machines by flavour per month");a[type].flavours.title="Number machines by flavour per month";break;case "freq_updates_per_month":a[type]={};a[type].title="Updates";a[type].releases={};a[type].releases.graph=build_data_per_month_releases(b[key][type],"Number updates by release per month");a[type].releases.title=
    2430"Number updates by release per month";a[type].flavours={};a[type].flavours.graph=build_data_per_month_flavours(b[key][type],"Number updates by flavour per month");a[type].flavours.title="Number updates by flavour per month";break;case "change_releases":a.changes||(a.changes={},a.changes.title="Changes");a.changes.releases||(a.changes.releases={});a.changes.releases.graph=build_data_from_array(b[key][type],"Change releases per month");a.changes.releases.title="Change releases per month";break;case "change_flavours":a.changes||
    2531(a.changes={},a.changes.title="Changes");a.changes.flavours||(a.changes.flavours={});a.changes.flavours.graph=build_data_from_array(b[key][type],"Change flavours per month");a.changes.flavours.title="Change flavours per month";break;case "architectures":a.architectures||(a.architectures={},a.architectures.title="Architectures");a.architectures.releases||(a.architectures.releases={});a.architectures.releases.graph=build_data_per_month_arch(b[key][type],"Architectures by release per month");a.architectures.releases.title=
    26 "Architectures distribution";break;case "mem":a.mem||(a.mem={},a.mem.title="Memory");a.mem.releases||(a.mem.releases={});a.mem.releases.graph=build_data_per_month_mem(b[key][type],"Memory by release per month");a.mem.releases.title="Memory distribution";break;case "cpu":a.cpu||(a.cpu={},a.cpu.title="CpuS"),a.cpu.releases||(a.cpu.releases={}),a.cpu.releases.graph=build_data_per_month_cpu(b[key][type],"Number CpuS by release per month"),a.cpu.releases.title="Number CpuS distribution"}if("apps"==key)for(type in b.apps)switch(type){case "app":c=
    27 b.apps[type];break;case "app_use":b[key][type]&&(a[type]={},a[type].title="Application usage",a[type].releases={},a[type].releases.graph=build_data_per_month_releases(b[key][type],"Application use by release per month ("+c+")"),a[type].releases.title="Use per month for application "+c,a[type].flavours={},a[type].flavours.graph=build_data_per_month_flavours(b[key][type],"Application use by flavour per month ("+c+")"),a[type].flavours.title="Use per month for application "+c)}key.startsWith("debug")&&
    28 ("debug_query_time"==key&&(query_time=b[key]),"debug_keep_alive"==key&&(keep_alive=b[key]))}for(chart_type in a)if(a[chart_type].title)for(chart_variant in a[chart_type])"title"==chart_variant?$("#accordion").append('<h3 class="'+chart_type+'">'+a[chart_type].title+'</h3><div id="'+chart_type+'"></div>'):a[chart_type][chart_variant].graph&&($("#"+chart_type).append("<div id="+chart_type+"_"+chart_variant+"></div>"),b=get_sizes(chart_type),a[chart_type][chart_variant].graph.options.width=b.width,a[chart_type][chart_variant].graph.options.height=
    29 b.height,(new google.visualization.LineChart(document.getElementById(chart_type+"_"+chart_variant))).draw(a[chart_type][chart_variant].graph.data,a[chart_type][chart_variant].graph.options));$("#loading").remove();$("#accordion").accordion({active:!1,collapsible:!0});null!=c&&$(".app_use").click();end_graph_time=get_time();print_stats(end_graph_time,query_time)})}
    30 function doChart(c){c=void 0===c?"":c;end_load_time=get_time();var a=new google.visualization.DataTable;a.addColumn("string","App");a.addColumn("number","Count");a=new google.visualization.DataTable;a.addColumn("string","App");a.addColumn("number","Count");a=new google.visualization.DataTable;a.addColumn("string","App");a.addColumn("number","Count");start_get_time=get_time();$("#accordion").append('<div id="loading"></div>');console.log(c);""==c?(url="./GetStats",limit=10):(url="./GetLliurexStats",
     32"Architectures distribution";break;case "mem":a.mem||(a.mem={},a.mem.title="Memory");a.mem.releases||(a.mem.releases={});a.mem.releases.graph=build_data_per_month_mem(b[key][type],"Memory by release per month");a.mem.releases.title="Memory distribution";break;case "cpu":a.cpu||(a.cpu={},a.cpu.title="CpuS");a.cpu.releases||(a.cpu.releases={});a.cpu.releases.graph=build_data_per_month_cpu(b[key][type],"Number CpuS by release per month");a.cpu.releases.title="Number CpuS distribution";break;case "count_ltsp":case "count_mode":a.ltsp||
     33(a.ltsp={},a.ltsp.title="LTSP Usage"),"count_ltsp"!=type||a.ltsp.usage||(a.ltsp.usage={},a.ltsp.usage.graph=build_data_per_month_ltsp_usage(b[key][type],"LTSP usage per month"),a.ltsp.usage.title="LTSP Use"),"count_mode"!=type||a.ltsp.modes||(a.ltsp.modes={},a.ltsp.modes.graph=build_data_per_month_ltsp_modes(b[key][type],"LTSP type by type per month"),a.ltsp.modes.title="Clients LTSP Mode")}if("apps"==key)for(type in b.apps)switch(type){case "app":e=b.apps[type];break;case "app_use":b[key][type]&&
     34(a[type]={},a[type].title="Application usage",a[type].releases={},a[type].releases.graph=build_data_per_month_releases(b[key][type],"Application use by release per month ("+e+")"),a[type].releases.title="Use per month for application "+e,a[type].flavours={},a[type].flavours.graph=build_data_per_month_flavours(b[key][type],"Application use by flavour per month ("+e+")"),a[type].flavours.title="Use per month for application "+e)}key.startsWith("debug")&&("debug_query_time"==key&&(query_time=b[key]),
     35"debug_keep_alive"==key&&(keep_alive=b[key]))}for(var c in a)if(a[c].title)for(var d in a[c])"title"==d?$("#accordion").append('<h3 class="'+c+'">'+a[c].title+'</h3><div id="'+c+'"></div>'):a[c][d].graph&&($("#"+c).append("<div id="+c+"_"+d+"></div>"),b=get_sizes(c),a[c][d].graph.options.width=b.width,a[c][d].graph.options.height=b.height,(new google.visualization.LineChart(document.getElementById(c+"_"+d))).draw(a[c][d].graph.data,a[c][d].graph.options));$("#loading").remove();$("#accordion").accordion({active:!1,
     36collapsible:!0});null!=e&&$(".app_use").click();end_graph_time=get_time();print_stats(end_graph_time,query_time)})}
     37function doChart(f){f=void 0===f?"":f;end_load_time=get_time();var a=new google.visualization.DataTable;a.addColumn("string","App");a.addColumn("number","Count");a=new google.visualization.DataTable;a.addColumn("string","App");a.addColumn("number","Count");a=new google.visualization.DataTable;a.addColumn("string","App");a.addColumn("number","Count");start_get_time=get_time();$("#accordion").append('<div id="loading"></div>');console.log(f);""==f?(url="./GetStats",limit=10):(url="./GetLliurexStats",
    3138limit=1E3);$.getJSON(url,function(a){start_graph_time=end_get_time=get_time();count=0;for(key in a)if(!key.startsWith("debug"))for(key2 in a[key])count++;max_graph=3*count;obj=[];for(distro in a)if(distro.startsWith("debug"))"debug_query_time"==distro&&(query_time=a[distro]),"debug_keep_alive"==distro&&(keep_alive=a[distro]);else for(sabor in a[distro])for(titles=["Top apps este mes","Top apps ultimo mes","Top apps penultimo mes"],divname="chart_"+distro+"_"+sabor,$("#accordion").append("<h3>Distro "+
    32 distro+"("+sabor+")</h3>"),$("#accordion").append('<div class="'+divname+'"></h3>'),i=0;3>i;i++){$("div."+divname).append('<div id="'+divname+i+'"></div>');k=0;var b=new google.visualization.DataTable;b.addColumn("string","App");b.addColumn("number","Count");for($.each(a[distro][sabor][i][0],function(a,c){b.addRow([a,parseInt(c)]);k++});10>k;)b.addRow(["",0]),k++;obj.push(b);titles[i]=titles[i]+" (Total clients: "+a[distro][sabor][i][1].nclients+")";drawChart(obj[obj.length-1],titles[i],divname+i,
     39distro+"("+sabor+")</h3>"),$("#accordion").append('<div class="'+divname+'"></h3>'),i=0;3>i;i++){$("div."+divname).append('<div id="'+divname+i+'"></div>');k=0;var b=new google.visualization.DataTable;b.addColumn("string","App");b.addColumn("number","Count");for($.each(a[distro][sabor][i][0],function(a,d){b.addRow([a,parseInt(d)]);k++});10>k;)b.addRow(["",0]),k++;obj.push(b);titles[i]=titles[i]+" (Total clients: "+a[distro][sabor][i][1].nclients+")";drawChart(obj[obj.length-1],titles[i],divname+i,
    3340k)}end_graph_time=get_time();print_stats(end_graph_time,query_time)})}num_ready=0;function ready_charts(){num_ready++;num_ready==max_graph&&($("#accordion>#loading").remove(),$("#accordion").accordion({active:!1,collapsible:!0}))}
    34 function print_stats(c,a){c=void 0===c?0:c;a=void 0===a?0:a;$("#stats_box").append('<span class="stats">Load time: '+((end_load_time-start_load_time)/1E3).toString()+" sec</span>");$("#stats_box").append('<span class="stats">Get time: '+parseFloat((end_get_time-start_get_time)/1E3-a).toFixed(3).toString()+" sec</span>");$("#stats_box").append('<span class="stats">Graph time: '+((c-start_graph_time)/1E3).toString()+" sec</span>");$("#stats_box").append('<span class="stats">Query time: '+parseFloat(a).toFixed(3).toString()+
     41function print_stats(f,a){f=void 0===f?0:f;a=void 0===a?0:a;$("#stats_box").append('<span class="stats">Load time: '+((end_load_time-start_load_time)/1E3).toString()+" sec</span>");$("#stats_box").append('<span class="stats">Get time: '+parseFloat((end_get_time-start_get_time)/1E3-a).toFixed(3).toString()+" sec</span>");$("#stats_box").append('<span class="stats">Graph time: '+((f-start_graph_time)/1E3).toString()+" sec</span>");$("#stats_box").append('<span class="stats">Query time: '+parseFloat(a).toFixed(3).toString()+
    3542" sec</span>");$("#stats_box").append('<span class="stats">Updated: '+keep_alive.toString()+"</span>")}function get_time(){return Date.now?Date.now():(new Date).getTime()}var start_graph_time=0,end_graph_time=0,start_load_time=get_time(),end_load_time=0,start_get_time=0,end_get_time=0,query_time="",keep_alive="";
  • lliurex-analytics-server/trunk/fuentes/lliurex-analytics-server/usr/sbin/analyticsd

    r7114 r7150  
    376376                    if not v_mode:
    377377                        v_mode='NULL'
     378                    else:
     379                        v_mode="'"+v_mode+"'"
    378380
    379381                    ret.append({'uuid':uuid,'id':v_id,'date':v_date,'uid':v_user,'version':version,'flavour':flavour,'rversion':v_version,'rflavour':v_flavour,'arch':v_arch,'mem':v_mem,'vga':v_vga,'cpu':v_cpu,'ncpu':v_ncpu,'ltsp':v_ltsp,'mode':v_mode})
     
    421423        values= []
    422424        for cli in kwargs['client_list']:
    423             values.append("({},'{}','{}','{}','{}','{}','{}','{}',{},'{}','{}',{},{},'{}')".format(cli['uuid'],cli['date'].strftime('%Y-%m-%d'),cli['uid'],cli['rversion'],cli['rflavour'],cli['version'],cli['flavour'],cli['arch'],cli['mem'],cli['vga'],cli['cpu'],cli['ncpu'],cli['ltsp'],cli['mode']))
     425            values.append("({},'{}','{}','{}','{}','{}','{}','{}',{},'{}','{}',{},{},{})".format(cli['uuid'],cli['date'].strftime('%Y-%m-%d'),cli['uid'],cli['rversion'],cli['rflavour'],cli['version'],cli['flavour'],cli['arch'],cli['mem'],cli['vga'],cli['cpu'],cli['ncpu'],cli['ltsp'],cli['mode']))
    424426        query = "INSERT INTO Client_Versions(`uuid`,`date`,`Client_uid`,`string_release`,`string_flavour`,`Releases_name`,`Flavours_name`,`arch`,`mem`,`vga`,`cpu`,`ncpu`,`ltsp`,`mode`) VALUES {} on duplicate key update uuid=uuid".format(','.join(map(str,values)))
    425427        self.execute(query=query)
Note: See TracChangeset for help on using the changeset viewer.