/[gentoo-src]/gentoo-stats/cpus.php
Gentoo

Contents of /gentoo-stats/cpus.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Fri May 9 10:01:08 2003 UTC (11 years, 3 months ago) by mksoft
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +22 -1 lines
intital cards page/template

1 mksoft 1.1 <?php
2     /**
3     * Gentoo stats
4     * Written by Meir Kriheli <mksoft@gentoo.org>
5     * Based on gentoo-stats by Maik Schreiber <blizzy@gentoo.org>
6     *
7 mksoft 1.2 * $Id: cpus.php,v 1.1 2003/04/29 23:00:41 mksoft Exp $
8 mksoft 1.1 *
9     * vim: set tabstop=4 shiftwidth=4:
10     */
11    
12     require_once('stats.inc.php');
13    
14     $total_cpus = getTotalCPUs();
15    
16     if ($total_cpus) {
17     $sql = "SELECT count(cv.cv_id) as cv_count, cv.cv_name " .
18     "FROM t_cpu_vendors cv, t_users2cpus uc, t_users u " .
19     "WHERE (cv.cv_id = uc.cv_id) AND (u.u_id = uc.u_id) " .
20     "AND (u_last_update IS NOT NULL) " .
21     "AND (TO_DAYS(NOW()) - TO_DAYS(u_last_update) <= $active_days) " .
22     "GROUP BY cv.cv_id " .
23     "ORDER BY cv.cv_name ";
24    
25     $cpu_vendors = $db->getAll($sql,DB_FETCHMODE_ASSOC);
26     if (!DB::isError($cpu_vendors)) {
27     for ($i=0;$i<count($cpu_vendors);$i++) {
28     $count = $cpu_vendors[$i]['cv_count'];
29     $cpu_vendors[$i]['cv_name'] = htmlspecialchars($cpu_vendors[$i]['cv_name']);
30     $cpu_vendors[$i]['cv_count'] = number_format($count);
31     $cpu_vendors[$i]['cv_percent'] = number_format($count * 100 / $total_cpus,2);
32     $cpu_vendors[$i]['bar_width'] = (int)($count * $bar_width/$total_cpus);
33     $cpu_vendors[$i]['bar_empty_width'] = $bar_width - $cpu_vendors[$i]['bar_width'];
34     }
35     $smarty->assign('cpu_vendors',$cpu_vendors);
36 mksoft 1.2 }
37    
38     $sql = "SELECT count(cm.cm_id) as cm_count, cm.cm_name " .
39     "FROM t_cpu_modelnames cm, t_users2cpus uc, t_users u " .
40     "WHERE (cm.cm_id = uc.cv_id) AND (u.u_id = uc.u_id) " .
41     "AND (u_last_update IS NOT NULL) " .
42     "AND (TO_DAYS(NOW()) - TO_DAYS(u_last_update) <= $active_days) " .
43     "GROUP BY cm.cm_id " .
44     "ORDER BY cm.cm_name ";
45     $cpu_models = $db->getAll($sql,DB_FETCHMODE_ASSOC);
46    
47     if (!DB::isError($cpu_models)) {
48     for ($i=0;$i<count($cpu_vendors);$i++) {
49     $count = $cpu_models[$i]['cm_count'];
50     $cpu_models[$i]['cm_name'] = htmlspecialchars($cpu_models[$i]['cm_name']);
51     $cpu_models[$i]['cm_count'] = number_format($count);
52     $cpu_models[$i]['cm_percent'] = number_format($count * 100 / $total_cpus,3);
53     $cpu_models[$i]['bar_width'] = (int)($count * $bar_width/$total_cpus);
54     $cpu_models[$i]['bar_empty_width'] = $bar_width - $cpu_models[$i]['bar_width'];
55     }
56     $smarty->assign('cpu_models',$cpu_models);
57 mksoft 1.1 }
58     }
59    
60     $smarty->assign('page_title','CPUs');
61     $smarty->assign('total_cpus',number_format($total_cpus));
62     $smarty->display('cpus.tpl');
63     ?>

  ViewVC Help
Powered by ViewVC 1.1.20