]> andersk Git - sql-web.git/blobdiff - tpl/index.php
move question stats to database
[sql-web.git] / tpl / index.php
index 56e4e823d7d516b77e5961162bcef3aeb55fdeca..f235d5618b768095b42575113b9ded2b3994304a 100644 (file)
@@ -21,6 +21,29 @@ However, the SIPB MySQL service should not be used to host critical applications
 One nightly backup is available for your locker at <code>/mit/sql/backup/LOCKER_NAME</code>.  You should perform additional backups of your data using the <a href="http://scripts.mit.edu/cron">shortjobs service</a> or <a href="http://scripts.mit.edu/faq/10/how-can-i-back-up-or-restore-my-sql-data">phpMyAdmin</a>.
 </p>
 
+<div style="text-align:center; font-style: italic;">
+<?php
+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);
+}
+?>
+</div>
+
 <?php
 include 'foot.php';
 ?>
This page took 0.030697 seconds and 4 git commands to generate.