]> andersk Git - sql-web.git/commitdiff
move question stats to database
authorJoe Presbrey <presbrey@mit.edu>
Sun, 18 May 2008 22:14:34 +0000 (22:14 +0000)
committerJoe Presbrey <presbrey@mit.edu>
Sun, 18 May 2008 22:14:34 +0000 (22:14 +0000)
git-svn-id: svn://presbrey.mit.edu/sql/web/dev@158 a142d4bd-2cfb-0310-9673-cb33a7e74f58

tpl/index.php

index e7cb30f173e9bd23f601014f8dd55d1bcdc67b12..f235d5618b768095b42575113b9ded2b3994304a 100644 (file)
@@ -23,30 +23,24 @@ One nightly backup is available for your locker at <code>/mit/sql/backup/LOCKER_
 
 <div style="text-align:center; font-style: italic;">
 <?php
-if (!file_exists(TEMP_PATH.'/stat') || filemtime(TEMP_PATH.'/stat')+3600<time()) {
-       $x = fetchRows(DBSelect("SHOW STATUS WHERE Variable_name IN ('Questions','Uptime')"),'Variable_name');
-       $v = $x['Questions']['Value'];
-       $t = $x['Uptime']['Value'];
-       file_put_contents(TEMP_PATH.'/stat',implode("\n",array($v,$t)));
-} else {
-       $x = file_get_contents(TEMP_PATH.'/stat');
-       list($v, $t) = explode("\n", $x);
+if (file_exists('/afs/athena.mit.edu/contrib/sql/stat/questions')) {
+       $x = file_get_contents('/afs/athena.mit.edu/contrib/sql/stat/questions');
+       list($t, $v) = explode("\n", $x);
+       $qavg = $v/$t;
+       $qunits = array('','k','M','G','T','P','E','Z','Y');
+       while (count($qunits) && $v/1000>1) {
+               array_shift($qunits);
+               $v /= 1000;
+       }
+       printf('sql.mit.edu has served %.3f%s queries', $v, array_shift($qunits));
+       $qunits = array('minutes', 'hours', 'days');
+       $qdiv = array(60, 60, 24);
+       while (count($qdiv) && $t/$qdiv[0]>0) {
+               $t /= array_shift($qdiv);
+               $tunits = array_shift($qunits);
+       }
+       printf(' in the last %.2f %s (%.2f qps)', $t, $tunits, $qavg);
 }
-$qavg = $v/$t;
-$qunits = array('','k','M','G','T','P','E','Z','Y');
-while (count($qunits) && $v/1000>1) {
-       array_shift($qunits);
-       $v /= 1000;
-}
-printf('sql.mit.edu has served %.3f%s queries', $v, array_shift($qunits));
-
-$qunits = array('minutes', 'hours', 'days');
-$qdiv = array(60, 60, 24);
-while (count($qdiv) && $t/$qdiv[0]>0) {
-       $t /= array_shift($qdiv);
-       $tunits = array_shift($qunits);
-}
-printf(' in the last %.2f %s (%.2f qps)', $t, $tunits, $qavg);
 ?>
 </div>
 
This page took 0.048719 seconds and 5 git commands to generate.