update
[phpmyadmin/crack.git] / server_status.php3
blobc35e6a848e4d117b3bc0d630f77563683406c0eb
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Does the common work
8 */
9 require('./server_common.inc.php3');
12 /**
13 * Displays the links
15 require('./server_links.inc.php3');
18 /**
19 * InnoDB status
21 if (!empty($innodbstatus)) {
22 echo '<h2>' . "\n"
23 . ' ' . $strInnodbStat . "\n"
24 . '</h2>' . "\n";
25 $sql_query = 'SHOW INNODB STATUS;';
26 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
27 $row = PMA_mysql_fetch_row($res);
28 echo '<pre>' . "\n"
29 . htmlspecialchars($row[0]) . "\n"
30 . '</pre>' . "\n";
31 mysql_free_result($res);
32 include('./footer.inc.php3');
33 exit;
36 /**
37 * Displays the sub-page heading
39 echo '<h2>' . "\n"
40 . ' ' . $strServerStatus . "\n"
41 . '</h2>' . "\n";
44 /**
45 * Checks if the user is allowed to do what he tries to...
47 if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
48 echo $strNoPrivileges;
49 include('./footer.inc.php3');
50 exit;
54 /**
55 * Sends the query and buffers the result
57 $res = @PMA_mysql_query('SHOW STATUS;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW STATUS;');
58 while ($row = PMA_mysql_fetch_row($res)) {
59 $serverStatus[$row[0]] = $row[1];
61 @mysql_free_result($res);
62 unset($res);
63 unset($row);
66 /**
67 * Displays the page
69 //Uptime calculation
70 $res = @PMA_mysql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
71 $row = PMA_mysql_fetch_row($res);
72 echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
73 mysql_free_result($res);
74 unset($res);
75 unset($row);
76 //Get query statistics
77 $queryStats = array();
78 $tmp_array = $serverStatus;
79 while (list($name, $value) = each($tmp_array)) {
80 if (substr($name, 0, 4) == 'Com_') {
81 $queryStats[str_replace('_', ' ', substr($name, 4))] = $value;
82 unset($serverStatus[$name]);
85 unset($tmp_array);
87 <ul>
88 <li>
89 <!-- Server Traffic -->
90 <?php echo $strServerTrafficNotes; ?><br />
91 <table border="0">
92 <tr>
93 <td valign="top">
94 <table border="0">
95 <tr>
96 <th colspan="2">&nbsp;<?php echo $strTraffic; ?>&nbsp;</th>
97 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
98 </tr>
99 <tr>
100 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strReceived; ?>&nbsp;</td>
101 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?>&nbsp;</td>
102 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
103 </tr>
104 <tr>
105 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strSent; ?>&nbsp;</td>
106 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?>&nbsp;</td>
107 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
108 </tr>
109 <tr>
110 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
111 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?>&nbsp;</td>
112 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
113 </tr>
114 </table>
115 </td>
116 <td valign="top">
117 <table border="0">
118 <tr>
119 <th colspan="2">&nbsp;<?php echo $strConnections; ?>&nbsp;</th>
120 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
121 <th>&nbsp;%&nbsp;</th>
122 </tr>
123 <tr>
124 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strFailedAttempts; ?>&nbsp;</td>
125 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Aborted_connects'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
126 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Aborted_connects'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
127 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_connects'] * 100 / $serverStatus['Connections']), 2, $number_decimal_separator, $number_thousands_separator) . '&nbsp;%' : '---'; ?>&nbsp;</td>
128 </tr>
129 <tr>
130 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strAbortedClients; ?>&nbsp;</td>
131 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Aborted_clients'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
132 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Aborted_clients'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
133 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_clients'] * 100 / $serverStatus['Connections']), 2 , $number_decimal_separator, $number_thousands_separator) . '&nbsp;%' : '---'; ?>&nbsp;</td>
134 </tr>
135 <tr>
136 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
137 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
138 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Connections'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
139 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;100,00&nbsp;%&nbsp;</td>
140 </tr>
141 </table>
142 </td>
143 </tr>
144 </table>
145 </li>
146 <br />
147 <li>
148 <!-- Queries -->
149 <?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)) . "\n"; ?>
150 <table border="0">
151 <tr>
152 <td colspan="2">
153 <br />
154 <table border="0" align="right">
155 <tr>
156 <th>&nbsp;<?php echo $strTotalUC; ?>&nbsp;</th>
157 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
158 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerMinute; ?>&nbsp;</th>
159 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerSecond; ?>&nbsp;</th>
160 </tr>
161 <tr>
162 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
163 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
164 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] * 60 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
165 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
166 </tr>
167 </table>
168 </td>
169 </tr>
170 <tr>
171 <td valign="top">
172 <table border="0">
173 <tr>
174 <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
175 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
176 <th>&nbsp;%&nbsp;</th>
177 </tr>
178 <?php
180 $useBgcolorOne = TRUE;
181 $countRows = 0;
182 while (list($name, $value) = each($queryStats)) {
184 <tr>
185 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars($name); ?>&nbsp;</td>
186 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($value, 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
187 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($value * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
188 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($value * 100 / $serverStatus['Questions']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;%&nbsp;</td>
189 </tr>
190 <?php
191 $useBgcolorOne = !$useBgcolorOne;
192 if (++$countRows == ceil(count($queryStats) / 2)) {
193 $useBgcolorOne = TRUE;
195 </table>
196 </td>
197 <td valign="top">
198 <table border="0">
199 <tr>
200 <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
201 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
202 <th>&nbsp;%&nbsp;</th>
203 </tr>
204 <?php
207 unset($countRows);
208 unset($useBgcolorOne);
210 </table>
211 </td>
212 </tr>
213 </table>
214 </li>
215 <?php
216 //Unset used variables
217 unset($serverStatus['Aborted_clients']);
218 unset($serverStatus['Aborted_connects']);
219 unset($serverStatus['Bytes_received']);
220 unset($serverStatus['Bytes_sent']);
221 unset($serverStatus['Connections']);
222 unset($serverStatus['Questions']);
223 unset($serverStatus['Uptime']);
225 if (!empty($serverStatus)) {
227 <br />
228 <li>
229 <!-- Other status variables -->
230 <b><?php echo $strMoreStatusVars; ?></b><br />
231 <table border="0">
232 <tr>
233 <td valign="top">
234 <table border="0">
235 <tr>
236 <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
237 <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
238 </tr>
239 <?php
240 $useBgcolorOne = TRUE;
241 $countRows = 0;
242 while (list($name, $value) = each($serverStatus)) {
244 <tr>
245 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?>&nbsp;</td>
246 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars($value); ?>&nbsp;</td>
247 </tr>
248 <?php
249 $useBgcolorOne = !$useBgcolorOne;
250 if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) {
251 $useBgcolorOne = TRUE;
253 </table>
254 </td>
255 <td valign="top">
256 <table border="0">
257 <tr>
258 <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
259 <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
260 </tr>
261 <?php
264 unset($useBgcolorOne);
266 </table>
267 </td>
268 </tr>
269 </table>
270 </li>
271 <?php
273 $res = PMA_mysql_query('SHOW VARIABLES LIKE "have_innodb";', $userlink);
274 if ($res) {
275 $row = PMA_mysql_fetch_row($res);
276 if (!empty($row[1]) && $row[1] == 'YES') {
278 <br />
279 <li>
280 <!-- InnoDB Status -->
281 <a href="./server_status.php3?<?php echo $url_query; ?>&amp;innodbstatus=1">
282 <b><?php echo $strInnodbStat; ?></b>
283 </a>
284 </li>
285 <?php
287 } else {
288 unset($res);
291 </ul>
294 <?php
298 * Sends the footer
300 require('./footer.inc.php3');