]> andersk Git - sql-web.git/blobdiff - cron/checkProcesses.php
signup exits rather than die'ing
[sql-web.git] / cron / checkProcesses.php
index b0ce0516536eda06a1f5c97938bdebe4e4d2de34..a33e9694adf1418f8b38d92350dcd95a303124d6 100755 (executable)
@@ -1,11 +1,11 @@
 <?php
 
-chdir('../');
+@chdir(dirname(__FILE__).'/../');
 require_once('mitsql.cfg.php');
 require_once('mitsql.lib.php');
-define('MAX_PROC_TIME', 10);
+isOffline() && exit;
 
-echo '<pre>';
+define('MAX_PROC_TIME', 10);
 
 $baddbs = $badusers = $bad = array();
 $result = mysql_query('SHOW FULL PROCESSLIST');
@@ -23,18 +23,19 @@ foreach($bad as $badproc) {
        $baddb = mysql_escape_string($badproc['db']);
        $badtime = $badproc['Time'];
        $badquery = $badproc['Info'];
-       mysql_query('KILL '.$badproc['Id']);
        if (empty($baddb)) continue;
        $sql = "SELECT User.UserId,User.Name,User.Email
                        FROM `User`
                        NATURAL JOIN DBOwner
                        NATURAL JOIN DB
-                       WHERE DB.Name = '$baddb'";
+                       WHERE DB.Name = '$baddb'
+                         AND User.UL < 10";
        $r = fetchRows(DBSelect($sql),'UserId');
        foreach($r as $addy) {
                $mailtos[] = $addy['Email'];
                $mailnames[] = $addy['Name'];
        }
+       if (empty($mailtos)) continue;
        $mailto = implode(', ',$mailtos);
        $mailname = implode(', ',$mailnames);
        $mailsubj = "[sql] Slow Query on $baddb";
@@ -43,18 +44,18 @@ foreach($bad as $badproc) {
 A slow query was found on your database: $baddb
 It took $badtime seconds and has been aborted.
 
-We do not allow inefficient SQL queries to run this long to conserve server
-resources. Your query has been appended to this message for your records.
-Please optimize your queries to avoid having your query killed in the
-future. If you have any questions, please contact sql@mit.edu.
+We do not allow inefficient SQL queries to run this long. Your query has
+been appended to this message for your records. Please optimize your
+queries to avoid having your queries killed in the future. If you have any
+questions, please contact sql@mit.edu.
 
-The SQL Service is available at http://sql.mit.edu/
+This SQL Service is available at sql.mit.edu.
 
 ---------------------------------------------------------------------------
 
 $badquery";
 
-       $mailto = 'jwp@mit.edu';
+       mysql_query('KILL '.$badproc['Id']);
        mail($mailto,$mailsubj,$mailbody,"From: SQL Service <sql@mit.edu>\r\nBcc: sql@mit.edu\r\n");
 }
 
This page took 0.287806 seconds and 4 git commands to generate.