Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: server_status.php,v 2.13 2005/05/01 12:43:26 lem9 Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 00004 00005 00009 require('./server_common.inc.php'); 00010 00011 00015 require('./server_links.inc.php'); 00016 00017 00021 echo '<h2>' . "\n" 00022 . ($GLOBALS['cfg']['MainPageIconic'] ? '<img src="' . $GLOBALS['pmaThemeImage'] . 's_status.png" width="16" height="16" border="0" hspace="2" align="middle" />' : '' ) 00023 . ' ' . $strServerStatus . "\n" 00024 . '</h2>' . "\n"; 00025 00026 00030 if (!$is_superuser && !$cfg['ShowMysqlInfo']) { 00031 echo $strNoPrivileges; 00032 require_once('./footer.inc.php'); 00033 } 00034 00035 00039 $res = PMA_DBI_query('SHOW STATUS;'); 00040 while ($row = PMA_DBI_fetch_row($res)) { 00041 $serverStatus[$row[0]] = $row[1]; 00042 } 00043 PMA_DBI_free_result($res); 00044 unset($res, $row); 00045 00046 00050 //Uptime calculation 00051 $res = PMA_DBI_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';'); 00052 $row = PMA_DBI_fetch_row($res); 00053 echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n"; 00054 PMA_DBI_free_result($res); 00055 unset($res, $row); 00056 //Get query statistics 00057 $queryStats = array(); 00058 $tmp_array = $serverStatus; 00059 foreach ($tmp_array AS $name => $value) { 00060 if (substr($name, 0, 4) == 'Com_') { 00061 $queryStats[str_replace('_', ' ', substr($name, 4))] = $value; 00062 unset($serverStatus[$name]); 00063 } 00064 } 00065 unset($tmp_array); 00066 ?> 00067 <ul> 00068 <li> 00069 <!-- Server Traffic --> 00070 <?php echo $strServerTrafficNotes; ?><br /> 00071 <table border="0" cellpadding="5" cellspacing="0"> 00072 <tr> 00073 <td valign="top"> 00074 <table border="0" cellpadding="2" cellspacing="1"> 00075 <tr> 00076 <th colspan="2"> <?php echo $strTraffic; ?> </th> 00077 <th> ø <?php echo $strPerHour; ?> </th> 00078 </tr> 00079 <tr> 00080 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strReceived; ?> </td> 00081 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?> </td> 00082 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?> </td> 00083 </tr> 00084 <tr> 00085 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strSent; ?> </td> 00086 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?> </td> 00087 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?> </td> 00088 </tr> 00089 <tr> 00090 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td> 00091 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?> </td> 00092 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?> </td> 00093 </tr> 00094 </table> 00095 </td> 00096 <td valign="top"> 00097 <table border="0" cellpadding="2" cellspacing="1"> 00098 <tr> 00099 <th colspan="2"> <?php echo $strConnections; ?> </th> 00100 <th> ø <?php echo $strPerHour; ?> </th> 00101 <th> % </th> 00102 </tr> 00103 <tr> 00104 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strFailedAttempts; ?> </td> 00105 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_connects'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td> 00106 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($serverStatus['Aborted_connects'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td> 00107 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_connects'] * 100 / $serverStatus['Connections']), 2, $number_decimal_separator, $number_thousands_separator) . ' %' : '---'; ?> </td> 00108 </tr> 00109 <tr> 00110 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"> <?php echo $strAbortedClients; ?> </td> 00111 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($serverStatus['Aborted_clients'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td> 00112 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($serverStatus['Aborted_clients'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td> 00113 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right"> <?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_clients'] * 100 / $serverStatus['Connections']), 2 , $number_decimal_separator, $number_thousands_separator) . ' %' : '---'; ?> </td> 00114 </tr> 00115 <tr> 00116 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"> <?php echo $strTotalUC; ?> </td> 00117 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td> 00118 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Connections'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td> 00119 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(100, 2, $number_decimal_separator, $number_thousands_separator); ?> % </td> 00120 </tr> 00121 </table> 00122 </td> 00123 </tr> 00124 </table> 00125 </li> 00126 <li> 00127 <!-- Queries --> 00128 <?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)) . "\n"; ?> 00129 <table border="0" cellpadding="5" cellspacing="0"> 00130 <tr> 00131 <td colspan="2"> 00132 <table border="0" cellpadding="2" cellspacing="1" width="100%"> 00133 <tr> 00134 <th> <?php echo $strTotalUC; ?> </th> 00135 <th> ø <?php echo $strPerHour; ?> </th> 00136 <th> ø <?php echo $strPerMinute; ?> </th> 00137 <th> ø <?php echo $strPerSecond; ?> </th> 00138 </tr> 00139 <tr> 00140 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator); ?> </td> 00141 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td> 00142 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] * 60 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td> 00143 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right"> <?php echo number_format(($serverStatus['Questions'] / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td> 00144 </tr> 00145 </table> 00146 </td> 00147 </tr> 00148 <tr> 00149 <td valign="top"> 00150 <table border="0" cellpadding="2" cellspacing="1"> 00151 <tr> 00152 <th colspan="2"> <?php echo $strQueryType; ?> </th> 00153 <th> ø <?php echo $strPerHour; ?> </th> 00154 <th> % </th> 00155 </tr> 00156 <?php 00157 00158 $useBgcolorOne = TRUE; 00159 $countRows = 0; 00160 foreach ($queryStats as $name => $value) { 00161 00162 // For the percentage column, use Questions - Connections, because 00163 // the number of connections is not an item of the Query types 00164 // but is included in Questions. Then the total of the percentages is 100. 00165 ?> 00166 <tr> 00167 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars($name); ?> </td> 00168 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format($value, 0, $number_decimal_separator, $number_thousands_separator); ?> </td> 00169 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($value * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?> </td> 00170 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo number_format(($value * 100 / ($serverStatus['Questions'] - $serverStatus['Connections'])), 2, $number_decimal_separator, $number_thousands_separator); ?> % </td> 00171 </tr> 00172 <?php 00173 $useBgcolorOne = !$useBgcolorOne; 00174 if (++$countRows == ceil(count($queryStats) / 2)) { 00175 $useBgcolorOne = TRUE; 00176 ?> 00177 </table> 00178 </td> 00179 <td valign="top"> 00180 <table border="0" cellpadding="2" cellspacing="1"> 00181 <tr> 00182 <th colspan="2"> <?php echo $strQueryType; ?> </th> 00183 <th> ø <?php echo $strPerHour; ?> </th> 00184 <th> % </th> 00185 </tr> 00186 <?php 00187 } 00188 } 00189 unset($countRows); 00190 unset($useBgcolorOne); 00191 ?> 00192 </table> 00193 </td> 00194 </tr> 00195 </table> 00196 </li> 00197 <?php 00198 //Unset used variables 00199 unset($serverStatus['Aborted_clients']); 00200 unset($serverStatus['Aborted_connects']); 00201 unset($serverStatus['Bytes_received']); 00202 unset($serverStatus['Bytes_sent']); 00203 unset($serverStatus['Connections']); 00204 unset($serverStatus['Questions']); 00205 unset($serverStatus['Uptime']); 00206 00207 if (!empty($serverStatus)) { 00208 ?> 00209 <li> 00210 <!-- Other status variables --> 00211 <b><?php echo $strMoreStatusVars; ?></b><br /> 00212 <table border="0" cellpadding="5" cellspacing="0"> 00213 <tr> 00214 <td valign="top"> 00215 <table border="0" cellpadding="2" cellspacing="1"> 00216 <tr> 00217 <th> <?php echo $strVar; ?> </th> 00218 <th> <?php echo $strValue; ?> </th> 00219 </tr> 00220 <?php 00221 $useBgcolorOne = TRUE; 00222 $countRows = 0; 00223 foreach ($serverStatus AS $name => $value) { 00224 ?> 00225 <tr> 00226 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>"> <?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?> </td> 00227 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right"> <?php echo htmlspecialchars($value); ?> </td> 00228 </tr> 00229 <?php 00230 $useBgcolorOne = !$useBgcolorOne; 00231 if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) { 00232 $useBgcolorOne = TRUE; 00233 ?> 00234 </table> 00235 </td> 00236 <td valign="top"> 00237 <table border="0" cellpadding="2" cellspacing="1"> 00238 <tr> 00239 <th> <?php echo $strVar; ?> </th> 00240 <th> <?php echo $strValue; ?> </th> 00241 </tr> 00242 <?php 00243 } 00244 } 00245 unset($useBgcolorOne); 00246 ?> 00247 </table> 00248 </td> 00249 </tr> 00250 </table> 00251 </li> 00252 </ul> 00253 <?php 00254 } 00255 00256 00260 require_once('./footer.inc.php'); 00261 00262 ?>