Ignore:
Timestamp:
Jun 12, 2009, 9:23:36 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Načítání log souborů mangosu do databáze.
  • Přidáno: Zobrazení ladících informací mangosu.
  • Opraveno: Správná cesta ke gdb souboru.
  • Opraveno: Chybně použit konfigurační soubor realmd.conf pro process mangos-worldd.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/mangos_debug.php

    r12 r17  
    44{
    55  var $ItemPerPage = 35;
     6  var $MaxMangosThreadCount = 12;
    67 
    7   function TimeToHumanTime($Value)
     8  function __construct($Database)
    89  {
    9     return(floor($Value / 3600 / 24).' days, '.date('H:i:s', $Value - 3600));
     10    $this->Database = $Database;
    1011  }
    11 
    12   function ShowPage()
     12 
     13  function Show($ServerId)
    1314  {
    1415    $Output = '<table width="100%"><tr><td width="10%" valign="top" style="">'.
     
    2021      else $Page = 0;
    2122
    22     $DbResult = $this->Database->query('SELECT COUNT(*) FROM Debug');
     23    $DbResult = $this->Database->query('SELECT COUNT(*) FROM Debug WHERE Server='.$ServerId);
    2324    $DbRow = $DbResult->fetch_array();
    2425    $Total = $DbRow[0];
    2526
    26     $DbResult = $Database->query('SELECT Id, Time FROM Debug WHERE 1 ORDER BY Time DESC LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage);
     27    $DbResult = $this->Database->query('SELECT Id, Time FROM Debug  WHERE Server='.$ServerId.' ORDER BY Time DESC LIMIT '.($Page * $this->ItemPerPage).','.$this->ItemPerPage);
    2728    while($DbRow = $DbResult->fetch_array())
    2829    {
    2930      if($DbRow['Id'] == $Id) $Output .= '<strong>';
    30       $Output .= '<a href="?Id='.$DbRow['Id'].'&amp;Page='.$Page.'&amp;Show=Backtrace">'.str_replace(' ', '&nbsp;', $DbRow['Time']).'</a>';
     31      $Output .= '<a href="?Action=ServerDebug&amp;Id='.$DbRow['Id'].'&amp;Page='.$Page.'&amp;Show=Backtrace">'.str_replace(' ', '&nbsp;', $DbRow['Time']).'</a>';
    3132      if($DbRow['Id'] == $Id) $Output .= '</strong>';
    3233      $Output .= '<br />';
    3334    }
    34     $Output .= PagesList('?Page=', $Page, $Total, $ItemPerPage, 2);
     35    $Output .= PagesList('?Page=', $Page, $Total, $this->ItemPerPage, 2);
    3536
    3637    $Output .= '</td><td valign="top" width="90%">';
     
    3839    if($Id > 0)
    3940    {
    40       $DbResult = $Database->query('SELECT * FROM Debug WHERE Id="'.$Id.'" ORDER BY Time');
     41      $DbResult = $this->Database->query('SELECT * FROM Debug WHERE Id="'.$Id.'" ORDER BY Time');
    4142      if($DbResult->num_rows > 0)
    4243      {
    4344        $DbRow = $DbResult->fetch_array();
    44         $Output .= '<strong>Time:</strong> '.$DbRow['Time'].'<br />';
    45         $Output .= '<strong>MaNGOS version:</strong> '.$DbRow['MangosVersion'].'<br />';
    46         $Output .= '<strong>Database version:</strong> '.$DbRow['DbVersion'].'<br />';
    47         $Output .= '<strong>Uptime:</strong> '.$this->TimeToHumanTime($DbRow['Uptime']).'<br />';
    48         $Output .= '<strong>MaxPlayerCount:</strong> '.$DbRow['MaxPlayerCount'].'<br /><br />';
    49         $Output .= '<a href="?Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Backtrace">Backtrace</a>'.
    50           '  <a href="?Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Log">Mangos log</a>'.
    51           '  <a href="?Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Error">Console error log</a>'.
    52           '  <a href="?Id='.$Id.'&amp;Page='.$Page.'&amp;Show=DbErrors">Database error log</a>'.
    53           '  <a href="?Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Configuration">Mangos configuration</a>'.
     45        $Output .= '<strong>Čas záznamu:</strong> '.$DbRow['Time'].'<br />';
     46        $Output .= '<strong>Verze MaNGOSu:</strong> '.$DbRow['MangosVersion'].'<br />';
     47        $Output .= '<strong>Verze databáze:</strong> '.$DbRow['DbVersion'].'<br />';
     48        $Output .= '<strong>Doba běhu:</strong> '.TimeToHumanTime($DbRow['Uptime']).'<br />';
     49        $Output .= '<strong>Maximum hráčů:</strong> '.$DbRow['MaxPlayerCount'].'<br /><br />';
     50        $Output .= '<a href="?Action=ServerDebug&amp;Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Backtrace">Backtrace</a>'.
     51          '  <a href="?Action=ServerDebug&amp;Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Log">Mangos log</a>'.
     52          '  <a href="?Action=ServerDebug&amp;Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Error">Console error log</a>'.
     53          '  <a href="?Action=ServerDebug&amp;Id='.$Id.'&amp;Page='.$Page.'&amp;Show=DbErrors">Database error log</a>'.
     54          '  <a href="?Action=ServerDebug&amp;Id='.$Id.'&amp;Page='.$Page.'&amp;Show=Configuration">Mangos configuration</a>'.
    5455          '<hr>';
    5556        if(array_key_exists('Show', $_GET))
     
    6061            case 'Backtrace':
    6162              $Content = htmlspecialchars($DbRow['Backtrace']);
    62               for($I = 1; $I < $MaxMangosThreadCount; $I++)
     63              for($I = 1; $I < $this->MaxMangosThreadCount; $I++)
    6364              {
    6465                $Content = str_replace('Thread '.$I.' ', '<hr><strong id="'.$I.'">Thread '.$I.'</strong>', $Content);
     
    8485    }
    8586    $Output .= '</td></tr></table>';
     87    return($Output);
    8688  }
    8789 
    8890  function ProcessLog()
    8991  {
     92    global $Config;
     93   
    9094    $Output = '';
    9195    // Read server Id from first parameter
     
    121125
    122126    // Get used database version from database
    123     $DbResult = $Database->query('SELECT * FROM `'.$Config['Mangos']['DatabaseMangos'].'`.`db_version`');
     127    $DbResult = $this->Database->query('SELECT * FROM `server'.$ServerId.'_mangos`.`db_version`');
    124128    $DbRow = $DbResult->fetch_array();
    125129    $DbVersion = $DbRow['version'];
    126130
    127131    // Get last uptime info
    128     $DbResult = $Database->query('SELECT * FROM `'.$Config['Mangos']['DatabaseRealmd'].'`.`uptime` ORDER BY `starttime` DESC LIMIT 1');
    129     $Output = $Database->error;
     132    $DbResult = $this->Database->query('SELECT * FROM `server'.$ServerId.'_realmd`.`uptime` ORDER BY `starttime` DESC LIMIT 1');
     133    //$Output = $this->Database->error;
    130134    $DbRow = $DbResult->fetch_array();
    131135    $MaxPlayerCount = $DbRow['maxplayers'];
     
    133137
    134138    // Insert data to database
    135     $Database->query('INSERT INTO `Debug` (`Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')');
    136     $InsertId = $Database->insert_id;
     139    $this->Database->query('INSERT INTO `Debug` (`Server`, `Time`, `MangosVersion`, `DbVersion`, `Uptime`, `MaxPlayerCount`) VALUES ('.$ServerId.', NOW(), "'.$MangosVersion.'", "'.$DbVersion.'", '.$Uptime.', '.$MaxPlayerCount.')');
     140    $InsertId = $this->Database->insert_id;
    137141
    138142    // Insert data in separate query to partly avoid too long query packet error
    139     $Database->query('UPDATE `Debug` SET Backtrace="'.$Backtrace.'" WHERE Id='.$InsertId);
     143    $this->Database->query('UPDATE `Debug` SET Backtrace="'.$Backtrace.'" WHERE Id='.$InsertId);
    140144    $Backtrace = '';
    141145   
     
    143147    {
    144148      $Log = addslashes(file_get_contents($MangosLogFile));
    145       $Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId);
     149      $this->Database->query('UPDATE `Debug` SET Log="'.$Log.'" WHERE Id='.$InsertId);
    146150      unlink($MangosLogFile);
    147151   
    148152    }
    149     if(file_exists($MangosDbErrorLogFile))
     153    if(file_exists($MangosDbErrorsLogFile))
    150154    {
    151155      $Log = addslashes(file_get_contents($MangosDbErrorsLogFile));
    152       $Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId);
     156      $this->Database->query('UPDATE `Debug` SET DbErrors="'.$Log.'" WHERE Id='.$InsertId);
    153157      unlink($MangosDbErrorsLogFile);
    154158    }
     
    163167        if(substr($LogLine, 0, 1) != '#') $Configuration[] = $LogLine;
    164168      }
    165       $Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId);
     169      $this->Database->query('UPDATE `Debug` SET Configuration="'.implode("\n", $Configuration).'" WHERE Id='.$InsertId);
    166170    }
    167171
     
    169173    {
    170174      $Log = addslashes(file_get_contents($ErrOutLogFile));
    171       $Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId);
     175      $this->Database->query('UPDATE `Debug` SET ErrorLog="'.$Log.'" WHERE Id='.$InsertId);
    172176      unlink($ErrOutLogFile);
    173177    }
Note: See TracChangeset for help on using the changeset viewer.