adodb_perf Klassenreferenz

Klassendiagramm für adodb_perf:
Inheritance graph
[Legende]

Öffentliche Methoden

 _CPULoad ()
 MemInfo ()
 CPULoad ()
 Tracer ($sql)
 Explain ($sql, $partial=false)
 InvalidSQL ($numsql=10)
 _SuspiciousSQL ($numsql=10)
 CheckMemory ()
 SuspiciousSQL ($numsql=10)
 ExpensiveSQL ($numsql=10)
 _ExpensiveSQL ($numsql=10)
 DBParameter ($param)
 PollParameters ()
 _DBParameter ($sql)
 WarnCacheRatio ($val)
 clearsql ()
 UI ($pollsecs=5)
 Poll ($secs=5)
 HealthCheckCLI ()
 HealthCheck ($cli=false)
 Tables ($orderby='1')
 CreateLogTable ()
 DoSQLForm ()
 SplitSQL ($sql)
 undomq ($m)
 OptimizeTables ()
 OptimizeTable ($table, $mode=ADODB_OPT_LOW)
 optimizeDatabase ()

Öffentliche, statische Methoden

static table ($newtable=false)

Datenfelder

 $conn
 $color = '#F0F0F0'
 $table = '<table border=1 bgcolor=white>'
 $titles = '<tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr>'
 $warnRatio = 90
 $tablesSQL = false
 $cliFormat = "%32s => %s \r\n"
 $sql1 = 'sql1'
 $explain = true
 $helpurl = "<a href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL help</a>"
 $createTableSQL = false
 $maxLength = 2000
 $_lastLoad

Ausführliche Beschreibung

Definiert in Zeile 217 der Datei adodb-perf.inc.php.


Dokumentation der Elementfunktionen

_CPULoad (  ) 

Definiert in Zeile 242 der Datei adodb-perf.inc.php.

00243         {
00244 /*
00245 
00246 cpu  524152 2662 2515228 336057010
00247 cpu0 264339 1408 1257951 168025827
00248 cpu1 259813 1254 1257277 168031181
00249 page 622307 25475680
00250 swap 24 1891
00251 intr 890153570 868093576 6 0 4 4 0 6 1 2 0 0 0 124 0 8098760 2 13961053 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00252 disk_io: (3,0):(3144904,54369,610378,3090535,50936192) (3,1):(3630212,54097,633016,3576115,50951320)
00253 ctxt 66155838
00254 btime 1062315585
00255 processes 69293
00256 
00257 */
00258                 // Algorithm is taken from
00259                 // http://social.technet.microsoft.com/Forums/en-US/winservergen/thread/414b0e1b-499c-411e-8a02-6a12e339c0f1/
00260                 if (strncmp(PHP_OS,'WIN',3)==0) {
00261                         if (PHP_VERSION == '5.0.0') return false;
00262                         if (PHP_VERSION == '5.0.1') return false;
00263                         if (PHP_VERSION == '5.0.2') return false;
00264                         if (PHP_VERSION == '5.0.3') return false;
00265                         if (PHP_VERSION == '4.3.10') return false; # see http://bugs.php.net/bug.php?id=31737
00266                         
00267                         static $FAIL = false;
00268                         if ($FAIL) return false;
00269                         
00270                         $objName = "winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\CIMV2";      
00271                         $myQuery = "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'";
00272                         
00273                         try {
00274                                 @$objWMIService = new COM($objName);
00275                                 if (!$objWMIService) {
00276                                         $FAIL = true;
00277                                         return false;
00278                                 }
00279                 
00280                                 $info[0] = -1;
00281                                 $info[1] = 0;
00282                                 $info[2] = 0;
00283                                 $info[3] = 0;
00284                                 foreach($objWMIService->ExecQuery($myQuery) as $objItem)  {
00285                                                 $info[0] = $objItem->PercentProcessorTime();
00286                                 }
00287                         
00288                         } catch(Exception $e) {
00289                                 $FAIL = true;
00290                                 echo $e->getMessage();
00291                                 return false;
00292                         }
00293                         
00294                         return $info;
00295                 }
00296                 
00297                 // Algorithm - Steve Blinch (BlitzAffe Online, http://www.blitzaffe.com)
00298                 $statfile = '/proc/stat';
00299                 if (!file_exists($statfile)) return false;
00300                 
00301                 $fd = fopen($statfile,"r");
00302                 if (!$fd) return false;
00303                 
00304                 $statinfo = explode("\n",fgets($fd, 1024));
00305                 fclose($fd);
00306                 foreach($statinfo as $line) {
00307                         $info = explode(" ",$line);
00308                         if($info[0]=="cpu") {
00309                                 array_shift($info);  // pop off "cpu"
00310                                 if(!$info[0]) array_shift($info); // pop off blank space (if any)
00311                                 return $info;
00312                         }
00313                 }
00314                 
00315                 return false;
00316                 
00317         }

_DBParameter ( sql  ) 

Definiert in Zeile 605 der Datei adodb-perf.inc.php.

00606         {
00607                 $savelog = $this->conn->LogSQL(false);
00608                 if (is_array($sql)) {
00609                 global $ADODB_FETCH_MODE;
00610                 
00611                         $sql1 = $sql[0];
00612                         $key = $sql[1];
00613                         if (sizeof($sql)>2) $pos = $sql[2];
00614                         else $pos = 1;
00615                         if (sizeof($sql)>3) $coef = $sql[3];
00616                         else $coef = false;
00617                         $ret = false;
00618                         $save = $ADODB_FETCH_MODE;
00619                         $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
00620                         if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
00621                         
00622                         $rs = $this->conn->Execute($sql1);
00623                         
00624                         if (isset($savem)) $this->conn->SetFetchMode($savem);
00625                         $ADODB_FETCH_MODE = $save;
00626                         if ($rs) {
00627                                 while (!$rs->EOF) {
00628                                         $keyf = reset($rs->fields);
00629                                         if (trim($keyf) == $key) {
00630                                                 $ret = $rs->fields[$pos];
00631                                                 if ($coef) $ret *= $coef;
00632                                                 break;
00633                                         }
00634                                         $rs->MoveNext();
00635                                 }
00636                                 $rs->Close();
00637                         }
00638                         $this->conn->LogSQL($savelog);
00639                         return $ret;
00640                 } else {
00641                         if (strncmp($sql,'=',1) == 0) {
00642                                 $fn = substr($sql,1);
00643                                 return $this->$fn();
00644                         }
00645                         $sql = str_replace('$DATABASE',$this->conn->database,$sql);
00646                         $ret = $this->conn->GetOne($sql);
00647                         $this->conn->LogSQL($savelog);
00648                         
00649                         return $ret;
00650                 }
00651         }

_ExpensiveSQL ( numsql = 10  ) 

Definiert in Zeile 524 der Datei adodb-perf.inc.php.

00525         {
00526                 global $ADODB_FETCH_MODE;
00527                 
00528             $perf_table = adodb_perf::table();
00529                         $saveE = $this->conn->fnExecute;
00530                         $this->conn->fnExecute = false;
00531                         
00532                         if (isset($_GET['expe']) && isset($_GET['sql'])) {
00533                                 $partial = !empty($_GET['part']);
00534                                 echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
00535                         }
00536                         
00537                         if (isset($_GET['sql'])) return;
00538                         
00539                         $sql1 = $this->sql1;
00540                         $save = $ADODB_FETCH_MODE;
00541                         $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
00542                         if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
00543                         
00544                         $rs = $this->conn->SelectLimit(
00545                         "select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
00546                                 from $perf_table
00547                                 where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5))  not in ('DROP ','INSER','COMMI','CREAT')
00548                                 and (tracer is null or tracer not like 'ERROR:%')
00549                                 group by sql1
00550                                 having count(*)>1
00551                                 order by 1 desc",$numsql);
00552                         if (isset($savem)) $this->conn->SetFetchMode($savem);
00553                         $this->conn->fnExecute = $saveE;
00554                         $ADODB_FETCH_MODE = $save;
00555                         if (!$rs) return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
00556                         $s = "<h3>Expensive SQL</h3>
00557 <font size=1>Tuning the following SQL could reduce the server load substantially</font><br>
00558 <table border=1 bgcolor=white><tr><td><b>Load</b><td><b>Count</b><td><b>SQL</b><td><b>Max</b><td><b>Min</b></tr>\n";
00559                         $max = $this->maxLength;
00560                         while (!$rs->EOF) {
00561                                 $sql = $rs->fields[1];
00562                                 $raw = urlencode($sql);
00563                                 if (strlen($raw)>$max-100) {
00564                                         $sql2 = substr($sql,0,$max-500);
00565                                         $raw = urlencode($sql2).'&part='.crc32($sql);
00566                                 }
00567                                 $prefix = "<a target=sqle".rand()." href=\"?hidem=1&expe=1&sql=".$raw."&x#explain\">";
00568                                 $suffix = "</a>";
00569                                 if($this->explain == false || strlen($prefix>$max)) {
00570                                         $prefix = '';
00571                                         $suffix = '';
00572                                 }
00573                                 $s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
00574                                         "<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
00575                                 $rs->MoveNext();
00576                         }
00577                         return $s."</table>";
00578         }

_SuspiciousSQL ( numsql = 10  ) 

Definiert in Zeile 445 der Datei adodb-perf.inc.php.

00446         {
00447                 global $ADODB_FETCH_MODE;
00448                 
00449             $perf_table = adodb_perf::table();
00450                         $saveE = $this->conn->fnExecute;
00451                         $this->conn->fnExecute = false;
00452                         
00453                         if (isset($_GET['exps']) && isset($_GET['sql'])) {
00454                                 $partial = !empty($_GET['part']);
00455                                 echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
00456                         }
00457                         
00458                         if (isset($_GET['sql'])) return;
00459                         $sql1 = $this->sql1;
00460                         
00461                         $save = $ADODB_FETCH_MODE;
00462                         $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
00463                         if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
00464                         //$this->conn->debug=1;
00465                         $rs = $this->conn->SelectLimit(
00466                         "select avg(timer) as avg_timer,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
00467                                 from $perf_table
00468                                 where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT')
00469                                 and (tracer is null or tracer not like 'ERROR:%')
00470                                 group by sql1
00471                                 order by 1 desc",$numsql);
00472                         if (isset($savem)) $this->conn->SetFetchMode($savem);
00473                         $ADODB_FETCH_MODE = $save;
00474                         $this->conn->fnExecute = $saveE;
00475                         
00476                         if (!$rs) return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
00477                         $s = "<h3>Suspicious SQL</h3>
00478 <font size=1>The following SQL have high average execution times</font><br>
00479 <table border=1 bgcolor=white><tr><td><b>Avg Time</b><td><b>Count</b><td><b>SQL</b><td><b>Max</b><td><b>Min</b></tr>\n";
00480                         $max = $this->maxLength;
00481                         while (!$rs->EOF) {
00482                                 $sql = $rs->fields[1];
00483                                 $raw = urlencode($sql);
00484                                 if (strlen($raw)>$max-100) {
00485                                         $sql2 = substr($sql,0,$max-500);
00486                                         $raw = urlencode($sql2).'&part='.crc32($sql);
00487                                 }
00488                                 $prefix = "<a target=sql".rand()." href=\"?hidem=1&exps=1&sql=".$raw."&x#explain\">";
00489                                 $suffix = "</a>";
00490                                 if ($this->explain == false || strlen($prefix)>$max) {
00491                                         $suffix = ' ... <i>String too long for GET parameter: '.strlen($prefix).'</i>';
00492                                         $prefix = '';
00493                                 }
00494                                 $s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
00495                                         "<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
00496                                 $rs->MoveNext();
00497                         }
00498                         return $s."</table>";
00499                 
00500         }

CheckMemory (  ) 

Definiert in Zeile 502 der Datei adodb-perf.inc.php.

00503         {
00504                 return '';
00505         }

clearsql (  ) 

Definiert in Zeile 663 der Datei adodb-perf.inc.php.

00664         {
00665                 $perf_table = adodb_perf::table();
00666                 $this->conn->Execute("delete from $perf_table where created<".$this->conn->sysTimeStamp);
00667         }

CPULoad (  ) 

Definiert in Zeile 352 der Datei adodb-perf.inc.php.

00353         {
00354                 $info = $this->_CPULoad();
00355                 if (!$info) return false;
00356                 
00357                 if (strncmp(PHP_OS,'WIN',3)==0) {
00358                         return (integer) $info[0];
00359                 }else {
00360                         if (empty($this->_lastLoad)) {
00361                                 sleep(1);
00362                                 $this->_lastLoad = $info;
00363                                 $info = $this->_CPULoad();
00364                         }
00365                         
00366                         $last = $this->_lastLoad;
00367                         $this->_lastLoad = $info;
00368                         
00369                         $d_user = $info[0] - $last[0];
00370                         $d_nice = $info[1] - $last[1];
00371                         $d_system = $info[2] - $last[2];
00372                         $d_idle = $info[3] - $last[3];
00373                         
00374                         //printf("Delta - User: %f  Nice: %f  System: %f  Idle: %f<br>",$d_user,$d_nice,$d_system,$d_idle);
00375                 
00376                         $total=$d_user+$d_nice+$d_system+$d_idle;
00377                         if ($total<1) $total=1;
00378                         return 100*($d_user+$d_nice+$d_system)/$total; 
00379                 }
00380         }

CreateLogTable (  ) 

Definiert in Zeile 903 der Datei adodb-perf.inc.php.

00904         {
00905                 if (!$this->createTableSQL) return false;
00906                 
00907                 $table = $this->table();
00908                 $sql = str_replace('adodb_logsql',$table,$this->createTableSQL);
00909                 $savelog = $this->conn->LogSQL(false);
00910                 $ok = $this->conn->Execute($sql);
00911                 $this->conn->LogSQL($savelog);
00912                 return ($ok) ? true : false;
00913         }

DBParameter ( param  ) 

Definiert in Zeile 583 der Datei adodb-perf.inc.php.

00584         {
00585                 if (empty($this->settings[$param])) return false;
00586                 $sql = $this->settings[$param][1];
00587                 return $this->_DBParameter($sql);
00588         }

DoSQLForm (  ) 

Definiert in Zeile 915 der Datei adodb-perf.inc.php.

00916         {
00917         
00918                 
00919                 $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']);
00920                 $sql = isset($_REQUEST['sql']) ? $_REQUEST['sql'] : '';
00921 
00922                 if (isset($_SESSION['phplens_sqlrows'])) $rows = $_SESSION['phplens_sqlrows'];
00923                 else $rows = 3;
00924                 
00925                 if (isset($_REQUEST['SMALLER'])) {
00926                         $rows /= 2;
00927                         if ($rows < 3) $rows = 3;
00928                         $_SESSION['phplens_sqlrows'] = $rows;
00929                 }
00930                 if (isset($_REQUEST['BIGGER'])) {
00931                         $rows *= 2;
00932                         $_SESSION['phplens_sqlrows'] = $rows;
00933                 }
00934                 
00935 ?>
00936 
00937 <form method="POST" action="<?php echo $PHP_SELF ?>">
00938 <table><tr>
00939 <td> Form size: <input type="submit" value=" &lt; " name="SMALLER"><input type="submit" value=" &gt; &gt; " name="BIGGER">
00940 </td>
00941 <td align=right>
00942 <input type="submit" value=" Run SQL Below " name="RUN"><input type=hidden name=do value=dosql>
00943 </td></tr>
00944   <tr>
00945   <td colspan=2><textarea rows=<?php print $rows; ?> name="sql" cols="80"><?php print htmlspecialchars($sql) ?></textarea>
00946   </td>
00947   </tr>
00948  </table>
00949 </form>
00950 
00951 <?php
00952                 if (!isset($_REQUEST['sql'])) return;
00953                 
00954                 $sql = $this->undomq(trim($sql));
00955                 if (substr($sql,strlen($sql)-1) === ';') {
00956                         $print = true;
00957                         $sqla = $this->SplitSQL($sql);
00958                 } else  {
00959                         $print = false;
00960                         $sqla = array($sql);
00961                 }
00962                 foreach($sqla as $sqls) {
00963 
00964                         if (!$sqls) continue;
00965                         
00966                         if ($print) {
00967                                 print "<p>".htmlspecialchars($sqls)."</p>";
00968                                 flush();
00969                         }
00970                         $savelog = $this->conn->LogSQL(false);
00971                         $rs = $this->conn->Execute($sqls);
00972                         $this->conn->LogSQL($savelog);
00973                         if ($rs && is_object($rs) && !$rs->EOF) {
00974                                 rs2html($rs);
00975                                 while ($rs->NextRecordSet()) {
00976                                         print "<table width=98% bgcolor=#C0C0FF><tr><td>&nbsp;</td></tr></table>";
00977                                         rs2html($rs);
00978                                 }
00979                         } else {
00980                                 $e1 = (integer) $this->conn->ErrorNo();
00981                                 $e2 = $this->conn->ErrorMsg();
00982                                 if (($e1) || ($e2)) {
00983                                         if (empty($e1)) $e1 = '-1'; // postgresql fix
00984                                         print ' &nbsp; '.$e1.': '.$e2;
00985                                 } else {
00986                                         print "<p>No Recordset returned<br></p>";
00987                                 }
00988                         }
00989                 } // foreach
00990         }

ExpensiveSQL ( numsql = 10  ) 

Definiert in Zeile 513 der Datei adodb-perf.inc.php.

00514         {
00515                 return adodb_perf::_ExpensiveSQL($numsql);
00516         }

Explain ( sql,
partial = false 
)

Erneute Implementation in perf_db2, perf_mssql, perf_mssqlnative, perf_mysql und perf_postgres.

Definiert in Zeile 418 der Datei adodb-perf.inc.php.

00419         {       
00420                 return false;
00421         }

HealthCheck ( cli = false  ) 

Erneute Implementation in perf_mssql und perf_mssqlnative.

Definiert in Zeile 822 der Datei adodb-perf.inc.php.

00823         {
00824                 $saveE = $this->conn->fnExecute;
00825                 $this->conn->fnExecute = false; 
00826                 if ($cli) $html = '';
00827                 else $html = $this->table.'<tr><td colspan=3><h3>'.$this->conn->databaseType.'</h3></td></tr>'.$this->titles;
00828                 
00829                 $oldc = false;
00830                 $bgc = '';
00831                 foreach($this->settings as $name => $arr) {
00832                         if ($arr === false) break;
00833                         
00834                         if (!is_string($name)) {
00835                                 if ($cli) $html .= " -- $arr -- \n";
00836                                 else $html .= "<tr bgcolor=$this->color><td colspan=3><i>$arr</i> &nbsp;</td></tr>";
00837                                 continue;
00838                         }
00839                         
00840                         if (!is_array($arr)) break;
00841                         $category = $arr[0];
00842                         $how = $arr[1];
00843                         if (sizeof($arr)>2) $desc = $arr[2];
00844                         else $desc = ' &nbsp; ';
00845                         
00846                         
00847                         if ($category == 'HIDE') continue;
00848                         
00849                         $val = $this->_DBParameter($how);
00850                         
00851                         if ($desc && strncmp($desc,"=",1) === 0) {
00852                                 $fn = substr($desc,1);
00853                                 $desc = $this->$fn($val);
00854                         }
00855                         
00856                         if ($val === false) {
00857                                 $m = $this->conn->ErrorMsg();
00858                                 $val = "Error: $m"; 
00859                         } else {
00860                                 if (is_numeric($val) && $val >= 256*1024) {
00861                                         if ($val % (1024*1024) == 0) {
00862                                                 $val /= (1024*1024);
00863                                                 $val .= 'M';
00864                                         } else if ($val % 1024 == 0) {
00865                                                 $val /= 1024;
00866                                                 $val .= 'K';
00867                                         }
00868                                         //$val = htmlspecialchars($val);
00869                                 }
00870                         }
00871                         if ($category != $oldc) {
00872                                 $oldc = $category;
00873                                 //$bgc = ($bgc == ' bgcolor='.$this->color) ? ' bgcolor=white' : ' bgcolor='.$this->color;
00874                         }
00875                         if (strlen($desc)==0) $desc = '&nbsp;';
00876                         if (strlen($val)==0) $val = '&nbsp;';
00877                         if ($cli) {
00878                                 $html  .= str_replace('&nbsp;','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc)));
00879                                 
00880                         }else {
00881                                 $html .= "<tr$bgc><td>".$name.'</td><td>'.$val.'</td><td>'.$desc."</td></tr>\n";
00882                         }
00883                 }
00884                 
00885                 if (!$cli) $html .= "</table>\n";
00886                 $this->conn->fnExecute = $saveE;
00887                         
00888                 return $html;   
00889         }

HealthCheckCLI (  ) 

Definiert in Zeile 813 der Datei adodb-perf.inc.php.

00814         {
00815                 return $this->HealthCheck(true);
00816         }

InvalidSQL ( numsql = 10  ) 

Definiert in Zeile 423 der Datei adodb-perf.inc.php.

00424         {
00425         
00426                 if (isset($_GET['sql'])) return;
00427                 $s = '<h3>Invalid SQL</h3>';
00428                 $saveE = $this->conn->fnExecute;
00429                 $this->conn->fnExecute = false;
00430         $perf_table = adodb_perf::table();
00431                 $rs = $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc",$numsql);//,$numsql);
00432                 $this->conn->fnExecute = $saveE;
00433                 if ($rs) {
00434                         $s .= rs2html($rs,false,false,false,false);
00435                 } else
00436                         return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
00437                 
00438                 return $s;
00439         }

MemInfo (  ) 

Definiert in Zeile 320 der Datei adodb-perf.inc.php.

00321         {
00322                 /*
00323 
00324         total:    used:    free:  shared: buffers:  cached:
00325 Mem:  1055289344 917299200 137990144        0 165437440 599773184
00326 Swap: 2146775040 11055104 2135719936
00327 MemTotal:      1030556 kB
00328 MemFree:        134756 kB
00329 MemShared:           0 kB
00330 Buffers:        161560 kB
00331 Cached:         581384 kB
00332 SwapCached:       4332 kB
00333 Active:         494468 kB
00334 Inact_dirty:    322856 kB
00335 Inact_clean:     24256 kB
00336 Inact_target:   168316 kB
00337 HighTotal:      131064 kB
00338 HighFree:         1024 kB
00339 LowTotal:       899492 kB
00340 LowFree:        133732 kB
00341 SwapTotal:     2096460 kB
00342 SwapFree:      2085664 kB
00343 Committed_AS:   348732 kB
00344                 */
00345         }

optimizeDatabase (  ) 

Reorganise current database. Default implementation loops over all MetaTables() and optimize each using optmizeTable()

Autor:
Markus Staab
Rückgabe:
Returns true on success and false on error

Definiert in Zeile 1080 der Datei adodb-perf.inc.php.

01081     {
01082         $conn = $this->conn;
01083         if ( !$conn) return false;
01084         
01085         $tables = $conn->MetaTables( 'TABLES');
01086         if ( !$tables ) return false;
01087 
01088         foreach( $tables as $table) {
01089             if ( !$this->optimizeTable( $table)) {
01090                 return false;
01091             }
01092         }
01093       
01094         return true;
01095     }

OptimizeTable ( table,
mode = ADODB_OPT_LOW 
)

Reorganise the table-indices/statistics/.. depending on the given mode. Default Implementation throws an error.

Parameter:
string table name of the table to optimize
int mode optimization-mode ADODB_OPT_HIGH for full optimization ADODB_OPT_LOW for CPU-less optimization Default is LOW ADODB_OPT_LOW
Autor:
Markus Staab
Rückgabe:
Returns true on success and false on error

Definiert in Zeile 1066 der Datei adodb-perf.inc.php.

01067     {
01068         ADOConnection::outp( sprintf( "<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
01069         return false;
01070     }

OptimizeTables (  ) 

Definiert in Zeile 1035 der Datei adodb-perf.inc.php.

01036     {
01037         $args = func_get_args();
01038         $numArgs = func_num_args();
01039         
01040         if ( $numArgs == 0) return false;
01041         
01042         $mode = ADODB_OPT_LOW; 
01043         $lastArg = $args[ $numArgs - 1];
01044         if ( !is_string($lastArg)) {
01045             $mode = $lastArg;
01046             unset( $args[ $numArgs - 1]);
01047         }
01048         
01049         foreach( $args as $table) {
01050             $this->optimizeTable( $table, $mode);
01051         }
01052         }

Poll ( secs = 5  ) 

Definiert in Zeile 771 der Datei adodb-perf.inc.php.

00772         {
00773                 $this->conn->fnExecute = false;
00774                 //$this->conn->debug=1;
00775                 if ($secs <= 1) $secs = 1;
00776                 echo "Accumulating statistics, every $secs seconds...\n";flush();
00777                 $arro = $this->PollParameters();
00778                 $cnt = 0;
00779                 set_time_limit(0);
00780                 sleep($secs);
00781                 while (1) {
00782 
00783                         $arr = $this->PollParameters();
00784                         
00785                         $hits   = sprintf('%2.2f',$arr[0]);
00786                         $reads  = sprintf('%12.4f',($arr[1]-$arro[1])/$secs);
00787                         $writes = sprintf('%12.4f',($arr[2]-$arro[2])/$secs);
00788                         $sess = sprintf('%5d',$arr[3]);
00789                         
00790                         $load = $this->CPULoad();
00791                         if ($load !== false) {
00792                                 $oslabel = 'WS-CPU%';
00793                                 $osval = sprintf(" %2.1f  ",(float) $load);
00794                         }else {
00795                                 $oslabel = '';
00796                                 $osval = '';
00797                         }
00798                         if ($cnt % 10 == 0) echo " Time   ".$oslabel."   Hit%   Sess           Reads/s          Writes/s\n"; 
00799                         $cnt += 1;
00800                         echo date('H:i:s').'  '.$osval."$hits  $sess $reads $writes\n";
00801                         flush();
00802                         
00803                         if (connection_aborted()) return;
00804                         
00805                         sleep($secs);
00806                         $arro = $arr;
00807                 }
00808         }

PollParameters (  ) 

Definiert in Zeile 593 der Datei adodb-perf.inc.php.

00594         {
00595                 $arr[0] = (float)$this->DBParameter('data cache hit ratio');
00596                 $arr[1] = (float)$this->DBParameter('data reads');
00597                 $arr[2] = (float)$this->DBParameter('data writes');
00598                 $arr[3] = (integer) $this->DBParameter('current connections');
00599                 return $arr;
00600         }

SplitSQL ( sql  ) 

Definiert in Zeile 992 der Datei adodb-perf.inc.php.

00993         {
00994                 $arr = explode(';',$sql);
00995                 return $arr;
00996         }

SuspiciousSQL ( numsql = 10  ) 

Definiert in Zeile 508 der Datei adodb-perf.inc.php.

00509         {
00510                 return adodb_perf::_SuspiciousSQL($numsql);
00511         }

static table ( newtable = false  )  [static]

Definiert in Zeile 232 der Datei adodb-perf.inc.php.

00233     {
00234         static $_table;
00235 
00236         if (!empty($newtable))  $_table = $newtable;
00237                 if (empty($_table)) $_table = 'adodb_logsql';
00238         return $_table;
00239     }

Tables ( orderby = '1'  ) 

Definiert in Zeile 891 der Datei adodb-perf.inc.php.

00892         {
00893                 if (!$this->tablesSQL) return false;
00894                 
00895                 $savelog = $this->conn->LogSQL(false);
00896                 $rs = $this->conn->Execute($this->tablesSQL.' order by '.$orderby);
00897                 $this->conn->LogSQL($savelog);
00898                 $html = rs2html($rs,false,false,false,false);
00899                 return $html;
00900         }

Tracer ( sql  ) 

Definiert in Zeile 382 der Datei adodb-perf.inc.php.

00383         {
00384         $perf_table = adodb_perf::table();
00385                 $saveE = $this->conn->fnExecute;
00386                 $this->conn->fnExecute = false;
00387                 
00388                 global $ADODB_FETCH_MODE;
00389                 $save = $ADODB_FETCH_MODE;
00390                 $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
00391                 if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
00392                                 
00393                 $sqlq = $this->conn->qstr($sql);
00394                 $arr = $this->conn->GetArray(
00395 "select count(*),tracer 
00396         from $perf_table where sql1=$sqlq 
00397         group by tracer
00398         order by 1 desc");
00399                 $s = '';
00400                 if ($arr) {
00401                         $s .= '<h3>Scripts Affected</h3>';
00402                         foreach($arr as $k) {
00403                                 $s .= sprintf("%4d",$k[0]).' &nbsp; '.strip_tags($k[1]).'<br>';
00404                         }
00405                 }
00406                 
00407                 if (isset($savem)) $this->conn->SetFetchMode($savem);
00408                 $ADODB_CACHE_MODE = $save;
00409                 $this->conn->fnExecute = $saveE;
00410                 return $s;
00411         }

UI ( pollsecs = 5  ) 

Definiert in Zeile 673 der Datei adodb-perf.inc.php.

00674         {
00675         global $ADODB_LOG_CONN;
00676         
00677     $perf_table = adodb_perf::table();
00678         $conn = $this->conn;
00679         
00680         $app = $conn->host;
00681         if ($conn->host && $conn->database) $app .= ', db=';
00682         $app .= $conn->database;
00683         
00684         if ($app) $app .= ', ';
00685         $savelog = $this->conn->LogSQL(false);  
00686         $info = $conn->ServerInfo();
00687         if (isset($_GET['clearsql'])) {
00688                 $this->clearsql();
00689         }
00690         $this->conn->LogSQL($savelog);
00691         
00692         // magic quotes
00693         
00694         if (isset($_GET['sql']) && get_magic_quotes_gpc()) {
00695                 $_GET['sql'] = $_GET['sql'] = str_replace(array("\\'",'\"'),array("'",'"'),$_GET['sql']);
00696         }
00697         
00698         if (!isset($_SESSION['ADODB_PERF_SQL'])) $nsql = $_SESSION['ADODB_PERF_SQL'] = 10;
00699         else  $nsql = $_SESSION['ADODB_PERF_SQL'];
00700         
00701         $app .= $info['description'];
00702         
00703         
00704         if (isset($_GET['do'])) $do = $_GET['do'];
00705         else if (isset($_POST['do'])) $do = $_POST['do'];
00706          else if (isset($_GET['sql'])) $do = 'viewsql';
00707          else $do = 'stats';
00708          
00709         if (isset($_GET['nsql'])) {
00710                 if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql'];
00711         }
00712         echo "<title>ADOdb Performance Monitor on $app</title><body bgcolor=white>";
00713         if ($do == 'viewsql') $form = "<td><form># SQL:<input type=hidden value=viewsql name=do> <input type=text size=4 name=nsql value=$nsql><input type=submit value=Go></td></form>";
00714         else $form = "<td>&nbsp;</td>";
00715         
00716         $allowsql = !defined('ADODB_PERF_NO_RUN_SQL');
00717         global $ADODB_PERF_MIN;
00718         $app .= " (Min sql timing \$ADODB_PERF_MIN=$ADODB_PERF_MIN secs)";
00719         
00720         if  (empty($_GET['hidem']))
00721         echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
00722         <b><a href=http://adodb.sourceforge.net/?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>
00723         <a href=?do=stats><b>Performance Stats</b></a> &nbsp; <a href=?do=viewsql><b>View SQL</b></a>
00724          &nbsp; <a href=?do=tables><b>View Tables</b></a> &nbsp; <a href=?do=poll><b>Poll Stats</b></a>",
00725          $allowsql ? ' &nbsp; <a href=?do=dosql><b>Run SQL</b></a>' : '',
00726          "$form",
00727          "</tr></table>";
00728 
00729          
00730                 switch ($do) {
00731                 default:
00732                 case 'stats':
00733                         if (empty($ADODB_LOG_CONN))
00734                                 echo "<p>&nbsp; <a href=\"?do=viewsql&clearsql=1\">Clear SQL Log</a><br>";
00735                         echo $this->HealthCheck();
00736                         //$this->conn->debug=1;
00737                         echo $this->CheckMemory();              
00738                         break;
00739                 case 'poll':
00740                         $self = htmlspecialchars($_SERVER['PHP_SELF']);
00741                         echo "<iframe width=720 height=80% 
00742                                 src=\"{$self}?do=poll2&hidem=1\"></iframe>";
00743                         break;
00744                 case 'poll2':
00745                         echo "<pre>";
00746                         $this->Poll($pollsecs);
00747                         break;
00748                 
00749                 case 'dosql':
00750                         if (!$allowsql) break;
00751                         
00752                         $this->DoSQLForm();
00753                         break;
00754                 case 'viewsql':
00755                         if (empty($_GET['hidem']))
00756                                 echo "&nbsp; <a href=\"?do=viewsql&clearsql=1\">Clear SQL Log</a><br>";
00757                         echo($this->SuspiciousSQL($nsql));
00758                         echo($this->ExpensiveSQL($nsql));
00759                         echo($this->InvalidSQL($nsql));
00760                         break;
00761                 case 'tables': 
00762                         echo $this->Tables(); break;
00763                 }
00764                 global $ADODB_vers;
00765                 echo "<p><div align=center><font size=1>$ADODB_vers Sponsored by <a href=http://phplens.com/>phpLens</a></font></div>";
00766         }

undomq ( m  ) 

Definiert in Zeile 998 der Datei adodb-perf.inc.php.

00999         {
01000         if (get_magic_quotes_gpc()) {
01001                 // undo the damage
01002                 $m = str_replace('\\\\','\\',$m);
01003                 $m = str_replace('\"','"',$m);
01004                 $m = str_replace('\\\'','\'',$m);
01005         }
01006         return $m;
01007 }

WarnCacheRatio ( val  ) 

Definiert in Zeile 656 der Datei adodb-perf.inc.php.

00657         {
00658                 if ($val < $this->warnRatio) 
00659                          return '<font color=red><b>Cache ratio should be at least '.$this->warnRatio.'%</b></font>';
00660                 else return '';
00661         }


Dokumentation der Datenelemente

$_lastLoad

Definiert in Zeile 351 der Datei adodb-perf.inc.php.

$cliFormat = "%32s => %s \r\n"

Definiert in Zeile 224 der Datei adodb-perf.inc.php.

$color = '#F0F0F0'

Definiert in Zeile 219 der Datei adodb-perf.inc.php.

$conn

Definiert in Zeile 218 der Datei adodb-perf.inc.php.

$createTableSQL = false

Erneute Implementation in perf_db2, perf_informix, perf_mssql, perf_mssqlnative, perf_mysql und perf_postgres.

Definiert in Zeile 228 der Datei adodb-perf.inc.php.

$explain = true

Definiert in Zeile 226 der Datei adodb-perf.inc.php.

$helpurl = "<a href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL help</a>"

Definiert in Zeile 227 der Datei adodb-perf.inc.php.

$maxLength = 2000

Definiert in Zeile 229 der Datei adodb-perf.inc.php.

$sql1 = 'sql1'

Erneute Implementation in perf_mssql und perf_mssqlnative.

Definiert in Zeile 225 der Datei adodb-perf.inc.php.

$table = '<table border=1 bgcolor=white>'

Definiert in Zeile 220 der Datei adodb-perf.inc.php.

$tablesSQL = false

Erneute Implementation in perf_informix, perf_mysql und perf_postgres.

Definiert in Zeile 223 der Datei adodb-perf.inc.php.

$titles = '<tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr>'

Definiert in Zeile 221 der Datei adodb-perf.inc.php.

$warnRatio = 90

Definiert in Zeile 222 der Datei adodb-perf.inc.php.


Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei:
Copyright © 2003 - 2010 MyOOS [Shopsystem]. All rights reserved.
MyOOS [Shopsystem] is Free Software released under the GNU/GPL License.

Webmaster: info@r23.de (Impressum)
doxygen