SurvServeur
EOS;
$okdata=FALSE;
$okvariables=FALSE;
$okstatus=FALSE;
$status=array();
$variables=array();
if (isset($online)) { // perform online
$linkID2=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($dbName,$linkID2) or die ("bad select db. ".mysql_error());
$query2="show status;";
$result2=mysql_query($query2,$linkID2) or die ("bad query get status via '$query2' : ".mysql_error());
// loop
while ($res2=mysql_fetch_array($result2)) { // while lines
$status[$res2[0]]=$res2[1];
} // while
$okstatus=TRUE;
$query2="show variables;";
$result2=mysql_query($query2,$linkID2) or die ("bad query get variables via '$query2' : ".mysql_error());
// loop
while ($res2=mysql_fetch_array($result2)) { // while lines
$variables[$res2[0]]=$res2[1];
} // while
$okvariables=TRUE;
}
if (isset($file)) { // read file
//foreach ($_POST as $key=>$val) echo "POSTdata $key = $val
";
$filename=stripslashes($filename);
if ($filename=="") echo "no file selected
";
else { // proceed
$contents=array();
$contents=file($filename);
$marker='mysql>';
$exploseur='|';
$i=0;
$j=count($contents);
while($i<$j) { // while not EOF
while (($i<$j)and(($a=strpos($contents[$i],$marker))===FALSE)) $i++; // search next marker
$searchstr=strtolower(substr($contents[$i],$a+strlen($marker)));
if (!(strpos($searchstr,'status')===FALSE)) { // status
$okstatus=TRUE;
$i+=4; // skip header
while (!(strpos($contents[$i],$exploseur)===FALSE)) { // tant que trouvé une ligne
$zar=explode($exploseur,$contents[$i]);
$status[trim($zar[1])]=trim($zar[2]);
$i++;
} // tant que lignes trouvées
} // status
else
if (!(strpos($searchstr,'variables')===FALSE)) { // variables
$okvariables=TRUE;
$i+=4; // skip header
while (!(strpos($contents[$i],$exploseur)===FALSE)) { // tant que trouvé une ligne
$zar=explode($exploseur,$contents[$i]);
$variables[trim($zar[1])]=trim($zar[2]);
$i++;
} // tant que lignes trouvées
} // variables
else $i++;
} // while not EOF
} // if OK
}
$okdata=$okstatus; // OR $okvariables);
function DMS($par) { // en secondes
$resultat=floor(($par/86400)).'D '; (integer)$reste=$par-$resultat*86400;
(integer)$par=floor($reste/3600); $resultat=$resultat.$par.'H '; (integer)$reste=$reste-$par*3600;
(integer)$par=floor($reste/60); $resultat=$resultat.$par.'M '; (integer)$reste=$reste-$par*60;
$par=$reste; $resultat=$resultat.$par.'S';
return($resultat);
} // DMS String Function
if ($okdata) { // analyse
if (! $okvariables) echo 'Warning no variables data found
';
//echo ""; print_r($status);echo "
";
//echo ""; print_r($variables);echo "
";
cl(0,"Server : ".$variables['version']." up since ".$status['Uptime']." (".DMS($status['Uptime']).")");
cl(2,"Performance : ");
cl(2,"Aborted connects ".$status['Aborted_connects'].'/'.$status['Connections'].' = '.floor(100*($status['Aborted_connects']/$status['Connections'])).'%');
cl(2,"Max connects ".$status['Max_used_connections'].' versus '.$variables['max_connections']);
$value=$variables['back_log'];
cl(2,"TCP/IP Listen Queue size (backlog) = $value ");
cl(2,"IO disk/memory ".$status['Created_tmp_disk_tables'].'/'.$status['Created_tmp_tables'].' = '.floor(100*($status['Created_tmp_disk_tables']/$status['Created_tmp_tables'])).'%');
cl(2,"Max Heap table size = ".$variables['max_heap_table_size']);
$value=$variables['flush_time'];
cl(2,"Flush / flush_time (low ress. or W95/Me) = ".$variables['flush']." / $value ".(($value>0)?'WARNING':''));
$value=$variables['low_priority_updates'];
cl(2,"Low priority UPDATEs = $value ");
$value=$variables['concurrent_insert'];
cl(0,"Concurrent INSERT = $value ");
$nbqueries=$status['Questions'];
$totalreads=$status['Handler_read_first']+$status['Handler_read_key']+$status['Handler_read_next']+$status['Handler_read_prev']+$status['Handler_read_rnd']+$status['Handler_read_rnd_next'];
$total=$status['Handler_write']+$status['Handler_delete']+$status['Handler_update']+$totalreads;
cl(2,"Usage : $nbqueries queries");
cl(2,"INSERTs ".$status['Handler_write']."/$nbqueries = ".floor(($status['Handler_write']/$nbqueries)).' per query');
cl(2,"DELETEs ".$status['Handler_delete']."/$nbqueries = ".floor(($status['Handler_delete']/$nbqueries)).' per query');
cl(2,"UPDATEs ".$status['Handler_update']."/$nbqueries = ".floor(($status['Handler_update']/$nbqueries)).' per query');
cl(0,"SELECTs : $totalreads/$nbqueries = ".floor(100*($totalreads/$nbqueries)).' per query');
cl(2,"Operations : $total total");
cl(2,"INSERTs ".$status['Handler_write']."/$total = ".floor(100*($status['Handler_write']/$total)).' %');
cl(2,"DELETEs ".$status['Handler_delete']."/$total = ".floor(100*($status['Handler_delete']/$total)).' %');
cl(2,"UPDATEs ".$status['Handler_update']."/$total = ".floor(100*($status['Handler_update']/$total)).' %');
cl(4,"SELECTs : $totalreads/$total = ".floor(100*($totalreads/$total)).' %');
cl(4,"1st index ".$status['Handler_read_first']."/$totalreads = ".MyDiv($status['Handler_read_first'],$totalreads));
cl(4,"ok index ".$status['Handler_read_key']."/$totalreads = ".MyDiv($status['Handler_read_key'],$totalreads));
cl(4,"index key next (range/scan) ".$status['Handler_read_next']."/$totalreads = ".MyDiv($status['Handler_read_next'],$totalreads));
cl(4,"index key prev (order by desc) ".$status['Handler_read_prev']."/$totalreads = ".MyDiv($status['Handler_read_prev'],$totalreads));
cl(4,"accès direct (sort) ".$status['Handler_read_rnd']."/$totalreads = ".MyDiv($status['Handler_read_rnd'],$totalreads));
cl(4,"table scans (bad indexing) ".$status['Handler_read_rnd_next']."/$totalreads = ".MyDiv($status['Handler_read_rnd_next'],$totalreads));
cl(6,"JOINs : buffer size = ".$variables['join_buffer_size']);
$value=$status['Select_full_join'];
cl(6,"Joins without key = $value".(($value>0)?'CHECK INDEXES':''));
$value=$status['Select_full_range_join'];
cl(6,"Joins range search on ref. table = $value");
$value=$status['Select_range'];
cl(6,"Joins ranges on 1st table (not crit.) = $value");
$value=$status['Select_scan'];
cl(6,"Joins Full scan on 1st table = $value".(($value>0)?'BAD':''));
$value=$status['Select_range_check'];
cl(6,"Joins without key with all key range check = $value".(($value>0)?'CHECK INDEXES':''));
$value=$variables['max_join_size'];
cl(0,"Max Join Size = $value".' records');
//VGR14012007 ADDed new sections
echo '';
cl(2,"Memory Footprint");
echo '';
cl(2,"read buffer size = ".DispMB($variables['read_buffer_size']));
cl(2,"sort buffer size = ".DispMB($variables['sort_buffer_size']));
$value_standard=$variables['key_buffer_size']+($variables['read_buffer_size']+$variables['sort_buffer_size'])*$variables['max_connections'];
$value_current=$variables['key_buffer_size']+($variables['read_buffer_size']+$variables['sort_buffer_size'])*$status['Max_used_connections'];
//key_buffer_size=8388600
//read_buffer_size=131072
//max_used_connections=72
//max_connections=500
//threads_connected=57
//It is possible that mysqld could use up to
//key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 1096188 K bytes of memory
cl(2,"standard max memory = key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections");
echo '';
cl(2,"standard max memory = ".DispMB($value_standard));
echo '';
cl(2,"InnoDB Log buffer size (flushed once/s anyway) = ".DispMB($variables['innodb_log_buffer_size']));
cl(2,"InnoDB Cache for Indices and Rows (80% RAM max.) = ".DispMB($variables['innodb_buffer_pool_size']));
cl(2,"InnoDB Additional Memory pool (64MB default) = ".DispMB($variables['innodb_additional_mem_pool_size']));
$value_innodb=0;
if ($variables['have_innodb']=='DISABLED') {
echo '';
cl(2,"InnoDB Engine is theoretically DISABLED and should NOT have allocated any memory");
echo '';
} else {
$value_innodb=$variables['innodb_log_buffer_size']+$variables['innodb_buffer_pool_size']+$variables['innodb_additional_mem_pool_size'];
echo '';
cl(2,"InnoDB Allocated memory = ".DispMB($value_innodb));
echo '';
}
cl(2,"Query cache size (0=disabled) = ".DispMB($variables['query_cache_size']));
cl(2,"Key Index cache size (0=disabled) = ".DispMB($variables['key_buffer_size']));
$value_caches=$variables['query_cache_size']+$variables['key_buffer_size'];
echo '';
cl(2,"Caches Allocated memory = ".DispMB($value_caches));
cl(2,'----------');
echo '';
cl(2,"Min Allocated memory = ".DispMB($value_innodb+$value_current+$value_caches));
cl(0,"Max Allocated memory = ".DispMB($value_innodb+$value_standard+$value_caches));
echo '';
cl(2,"Key Index Cache : size = ".DispMB($variables['key_buffer_size']));
cl(2,"key reads from disk (cache miss%)(<1%) ".$status['Key_reads']."/".$status['Key_read_requests']." = ".floor(100*($status['Key_reads']/$status['Key_read_requests'])).' %');
if (isset($status['Not_flushed_key_blocks'])) { //VGR14012007 ADDed sécurité, unset in 5.0, was set before
cl(2,"key writes unflushed ".$status['Not_flushed_key_blocks']);
}
cl(0,"key writes ratio (~100% upd/del) ".$status['Key_writes']."/".$status['Key_write_requests']." = ".floor(100*($status['Key_writes']/$status['Key_write_requests'])).' %');
cl(2,"Queries :");
$qtot=$nbqueries;
$qslow=$status['Slow_queries'];
cl(2,"slow Queries $qslow (TO=".$variables['long_query_time'].' s) '.MyDiv($qslow,$qtot));
cl(2,"Query not cached if > ".DispMB($variables['query_cache_limit']));
cl(2,"Query cache size (0=disabled) = ".DispMB($variables['query_cache_size']));
cl(2,"Query cache type (ON,OF,DEMAND) = ".$variables['query_cache_type']);
//VGR14012007 ADDed QCache details (if available)
cl(2,"Query cache free memory = ".DispMB($status['Qcache_free_memory']).' ( '.MyDiv($status['Qcache_free_memory'],$variables['query_cache_size']).' )');
$qsize=$variables['query_cache_size']-$status['Qcache_free_memory']; // in bytes
$qhits=$status['Qcache_hits'];
$qins=$status['Qcache_inserts'];
$qnotc=$status['Qcache_not_cached'];
//if ($qnotc+$qhits<>$qtot) die("problem $qnotc+$qhits<>$qtot");
cl(2,"Query cache Hits = $qhits (".MyDiv($qhits,$qtot).' )');
cl(2,"Query cache Inserts = $qins (hits/inserts = ".MyDiv($qhits,$qins,FALSE).")");
cl(2,"Query cache Miss = $qnotc (".MyDiv($qnotc,$qtot).' )');
$qprobl=$status['Qcache_lowmem_prunes'];
if ($qprobl>0) { // insufficient memory allocated to QCache
echo '';
cl(2,"Query Cache seems too small !");
cl(0,"$qprobl queries were removed from Cache to make room for new ones");
echo '';
}
cl(0,"Queries in cache : {$status['Qcache_queries_in_cache']} (average size=".MyDiv($qsize,$status['Qcache_queries_in_cache'],FALSE).' bytes )');
//EoAdd
cl(2,"Threads :");
cl(2,"slow Threads ".$status['Slow_launch_threads']." TO= ".$variables['slow_launch_time'].' s');
cl(2,"Threads Cache : size = ".$variables['thread_cache_size']);
cl(4,"cache miss ratio = ".$status['Threads_created']."/".$status['Connections']." = ".floor(100*($status['Threads_created']/$status['Connections'])).' %');
cl(4,"Threads cached ".$status['Threads_cached']);
cl(4,"Threads running ".$status['Threads_running']);
cl(4,"Threads connected ".$status['Threads_connected']);
cl(0,"Thread stack (0=disabled) = ".$variables['thread_stack']);
cl(2,'Tables : ');
$nblocksreq=$status['Table_locks_immediate']+$status['Table_locks_waited'];
cl(2,"Locks miss ratio = ".$status['Table_locks_waited']."/".$nblocksreq." = ".floor(100*($status['Table_locks_waited']/$nblocksreq)).' %');
cl(0,"Opened tables (FLUSH TABLES?) versus Cache size = ".$status['Opened_tables']." versus ".$variables['table_cache']);
cl(2,'Sorts Buffer (order by,group by) : size = '.$variables['sort_buffer_size']);
$nbsorts=$status['Sort_scan']+$status['Sort_range'];
cl(2,"full scan sorts ".$status['Sort_scan']."/".$nbsorts." = ".MyDiv($status['Sort_scan'],$nbsorts));
cl(2,"range sorts ".$status['Sort_range']."/".$nbsorts." = ".MyDiv($status['Sort_range'],$nbsorts));
cl(2,"number of passes per sort ".$status['Sort_merge_passes']."/".$nbsorts." = ".MyDiv($status['Sort_merge_passes'],$nbsorts));
cl(2,"number of rows sorted ".$status['Sort_rows']."/".$nbsorts." = ".MyDiv($status['Sort_rows'],$nbsorts,FALSE).' rows per sort');
cl(0,"MaxSorted length for BLOBs and TEXTs = ".$variables['max_sort_length']);
cl(2,'Delayed Key (index) Write (MyISAM) : (OFF,ON,ALL) = '.$variables['delay_key_write']);
cl(2,"execute SELECTs every ".$variables['delayed_insert_limit'].' delayed INSERTs pending');
cl(2,"TO for receiving SELECT = ".$variables['delayed_insert_timeout'].' s');
cl(2,"Queue size = ".$variables['delayed_queue_size'].' rows');
cl(0,"Max delayed Threads = ".$variables['max_delayed_threads']);
cl(2,'Others : ');
$nbfiles=(isset($variables['open_file_limit']))?$variables['open_file_limit']:((isset($variables['open_files_limit']))?$variables['open_files_limit']:0);
if ($nbfiles==0) {
$nbfiles=max($variables['max_connections']*5,$variables['max_connections']+$variables['table_cache']*2);
} // max
cl(2,"\"Too many open files\" when reaching ".$nbfiles.' file descriptors');
$nbfiles=$variables['bulk_insert_buffer_size'];
if ($nbfiles==0) $nbfiles='DISABLED';
cl(0,"MyISAM cache for bulk inserts, limits cache tree to ".$nbfiles.' bytes/thread');
cl(2,"Configuration (have_* options for 5.0+):");
cl(2,"have_archive = {$variables['have_archive']}");
cl(2,"have_bdb = {$variables['have_bdb']}"); // | NO
cl(2,"have_blackhole_engine = {$variables['have_blackhole_engine']}"); // | NO
cl(2,"have_compress = {$variables['have_compress']}"); // | YES
cl(2,"have_crypt = {$variables['have_crypt']}"); // | NO
cl(2,"have_csv = {$variables['have_csv']}"); // | NO
cl(2,"have_dynamic_loading = {$variables['have_dynamic_loading']}"); // | YES
cl(2,"have_example_engine = {$variables['have_example_engine']}"); // | NO
cl(2,"have_federated_engine = {$variables['have_federated_engine']}"); // | NO
cl(2,"have_geometry = {$variables['have_geometry']}"); // | YES
echo '';
cl(2,"have_innodb = {$variables['have_innodb']}"); // | DISABLED
cl(2,"have_isam = {$variables['have_isam']}"); // | NO
echo '';
cl(2,"have_merge_engine = {$variables['have_merge_engine']}"); // | YES
cl(2,"have_ndbcluster = {$variables['have_ndbcluster']}"); // | NO
cl(2,"have_openssl = {$variables['have_openssl']}"); // | DISABLED
echo '';
cl(2,"have_query_cache = {$variables['have_query_cache']}"); // | YES
echo '';
cl(2,"have_raid = {$variables['have_raid']}"); // | NO
cl(2,"have_rtree_keys = {$variables['have_rtree_keys']}"); // | YES
cl(0,"have_symlink = {$variables['have_symlink']}"); // | YES
//EoAdd
cl(2,"Fulltext search (options for 4.0+):");
cl(2,"min word length = ".$variables['ft_min_word_len']);
cl(2,"max word length = ".$variables['ft_max_word_len']);
if (isset($variables['ft_max_word_len_for_sort'])) { //VGR14012007 ADDed sécurité, unset in 5.0, was set before
cl(2,"max word length for Sort = ".$variables['ft_max_word_len_for_sort']);
}
cl(2,"stopword file = ".$variables['ft_stopword_file']);
cl(0,"boolean syntax operators supported = ".htmlspecialchars($variables['ft_boolean_syntax']));
} // analyse
echo '';
?>