Changeset 17


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.
Location:
trunk/www
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/emulator.php

    r16 r17  
    1010  {
    1111    $this->Database = $Database;
    12     $this->Task = new Task(&$Database);
     12    $this->Task = new Task($Database);
    1313    $this->Id = $Id;
    1414    $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$Id);
  • trunk/www/global.php

    r12 r17  
    258258}
    259259
     260function TimeToHumanTime($Value)
     261{
     262  return(floor($Value / 3600 / 24).' days, '.date('H:i:s', $Value - 3600));
     263}
     264
    260265// Zobrazení číselný seznamu stránek
    261266function PagesList($URL, $Page, $TotalCount, $CountPerPage, $Around = 10)
  • trunk/www/index.php

    r15 r17  
    334334        } else $Output .= $this->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id');
    335335      } else
     336      if($_GET['Action'] == 'ServerDebug')
     337      {
     338        if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
     339        {       
     340          $Output = '<div>Ladící informace serveru</div>';
     341          $DbResult = $this->Database->query('SELECT Id FROM Server WHERE User='.$this->System->Modules['User']->User['Id']);
     342          $Server = $DbResult->fetch_assoc();
     343          $MangosDebug = new MangosDebug($this->Database);
     344          $Output .= $MangosDebug->Show($Server['Id']);
     345        } else $Output .= USER_BAD_ROLE;
     346      } else
    336347      if($_GET['Action'] == 'Test')
    337348      {
  • 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    }
  • trunk/www/mangos_debug_process.php

    r12 r17  
    33include('global.php');
    44
    5 $MangosDebug = new MangosDebug();
     5$MangosDebug = new MangosDebug($Database);
    66echo($MangosDebug->ProcessLog());
    77
  • trunk/www/server.php

    r16 r17  
    1717  {
    1818    $this->Database = $Database;
    19     $this->Task = new Task(&$Database);
     19    $this->Task = new Task($Database);
    2020    $this->Id = $Id;
    2121    $DbResult = $this->Database->query('SELECT * FROM `Server` WHERE `Id`='.$Id);
     
    162162    $Content = array
    163163    (
    164       'run -c server/'.$this->Id.'/etc/realmd.conf',
     164      'run -c server/'.$this->Id.'/etc/mangosd.conf',
    165165      'info thread',
    166166    );
     
    176176      '#!/bin/sh',
    177177      'while [ 1=1 ] ; do',
    178       'gdb emulator/'.$this->Id.'/bin/mangos-worldd -x mangos.gdb --batch >>server/'.$this->Id.'/log/mangos-worldd.log 2>>server/'.$this->Id.'/log/mangos-worldd.err',
     178      'gdb emulator/'.$this->Id.'/bin/mangos-worldd -x emulator/'.$this->Id.'/bin/mangos.gdb --batch >>server/'.$this->Id.'/log/mangos-worldd.log 2>>server/'.$this->Id.'/log/mangos-worldd.err',
    179179      'cd www',
    180180      'php mangos_debug_process.php '.$this->Id.' >>server/'.$this->Id.'/log/mangos_debug.log 2>>server/'.$this->Id.'/log/mangos_debug.err',
     
    217217    $Config->ParameterList['DataDir'] = 'wowclient/'.$this->Server['Database']['Emulator']['ClientVersion']['Version'];
    218218    $Config->ParameterList['LogsDir'] = 'server/'.$this->Id.'/log';
     219    $Config->ParameterList['LogLevel'] = 1;
     220    $Config->ParameterList['LogSQL'] = 0;
    219221    $ServerTypes = array(0 => 0, 1 => 1, 2 => 6, 3 => 8);
    220222    $Config->ParameterList['GameType'] = $ServerTypes[$this->Server['Type']];
Note: See TracChangeset for help on using the changeset viewer.