]> andersk Git - sql-web.git/blobdiff - tpl/index.php
minor portability fixes
[sql-web.git] / tpl / index.php
index 9b940f18a0e907abcdd3f5ccda2084599a0eba24..e7cb30f173e9bd23f601014f8dd55d1bcdc67b12 100644 (file)
@@ -16,11 +16,40 @@ All uses of this service must comply with the <a target="_blank" href="http://we
 </p>
 
 <p>
-Although this service has been designed with reliability in mind, the SIPB MySQL service should not be used to host critical applications that cannot tolerate downtime.
-We perform no query logging, schema or data backups, or any other backups otherwise generally available. You are solely responsible for performing backups of your data.
-We maintain general usage statistics of this service by the MIT community at large.
+This service has been designed with reliability in mind; we utilize RAID, live server mirroring and periodic offline backups to ensure data reliability.
+However, the SIPB MySQL service should not be used to host critical applications that cannot tolerate downtime.
+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(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);
+}
+$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.026077 seconds and 4 git commands to generate.