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

Contents of /gentoo-stats/cpus.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Tue Apr 29 23:00:41 2003 UTC (11 years, 7 months ago) by mksoft
Branch: MAIN
added cpu page and template

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 * $Id$
8 *
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 }
37 }
38
39 $smarty->assign('page_title','CPUs');
40 $smarty->assign('total_cpus',number_format($total_cpus));
41 $smarty->display('cpus.tpl');
42 ?>

  ViewVC Help
Powered by ViewVC 1.1.20