Thread: Administrative and Maintenance Tools - Suppress-o-matic - Stop database error spam
View Single Post
  #58  
Old 07-27-2016, 06:49 PM
Islamic Board Islamic Board is offline
 
Join Date: May 2016
Location: www.IslamicBoard.com
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery View Post
Do you have the errors or notes regarding it? I don't have a test bed for this right now but if you let me know we can look into fixing it.
We have modified it slightly to work with SQLite3. There doesn't seem to be any errors thrown by this script at the moment but when we tested it, we still receive multiple db error emails of the same error message, even within 1 second.

Below is the modified script for SQLite3.
Code:
/**********************************************\ 
|* DB Error Mail Suppressomatic (squall14716) *|
\**********************************************/
if ($sqlitedb = new SQLite3(DIR.'/sqlite3dberrors.sqlite', 0666, $sqliteerror)) {
    // Time between errors. 1800 (30 minutes) by default.
    // Modify config.php for easy changing of this. For example:
    // $config['dbems']['timebetweenerrors'] = 1800;
    //($vbulletin->config['dbems']['timebetweenerrors'] ? $timebetweenerrors = $vbulletin->config['dbems']['timebetweenerrors'] : $timebetweenerrors = 60);
    $timebetweenerrors = 60; // seconds

    // Database opened and ready. Let's check to see if there are recent errors of this type.
    $sqlitequery = $sqlitedb->query("SELECT * FROM dberrors WHERE time > ".(TIMENOW - $timebetweenerrors).
        " AND errorcode = '".$this->errno."' ORDER BY time DESC");
    $suppresserrormail = false;
    while ($sqliteresult = $sqlitequery->fetchArray(SQLITE3_ASSOC)) {
        if ($sqliteresult['script'] == $scriptpath) {
            if ($sqliteresult['errorcode'] == $this->errno) {
                // Script is the same and the errorcode is the same. Let's supress this error e-mail.
                $suppresserrormail = true;
            }
        }
        if ($sqliteresult['error'] == $this->error) {
            // Error message is the same. Supress this error e-mail.
            $suppresserrormail = true;
        }
    }

    if ($suppresserrormail == false) {
        $sqlitedb->exec("INSERT INTO dberrors (time, error, errorcode, ipaddress, script) VALUES (".TIMENOW.
            ", '".SQLite3::escapeString($this->error)."', '".$this->errno."', '$ipaddress', '$scriptpath')");
    } else {
        $technicalemail = "";
    }

    // Clean the SQLite table of all irrelevant data.
    $sqlitedb->exec("DELETE FROM dberrors WHERE time < ".(TIMENOW - $timebetweenerrors));

}
/**************************************************\ 
|* End DB Error Mail Suppressomatic (squall14716) *|
\**************************************************/

Using the dumpdberror script given in this thread, we can see that there was a single db error written in the database file, only once. It has not updated after that in subsequent tests.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01201 seconds
  • Memory Usage 1,773KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete