250 |
kaklik |
1 |
<?php |
|
|
2 |
/* $Id: server_status.php,v 2.28 2006/01/25 08:16:40 cybot_tm Exp $ */ |
|
|
3 |
// vim: expandtab sw=4 ts=4 sts=4: |
|
|
4 |
/** |
|
|
5 |
* displays status variables with descriptions and some hints an optmizing |
|
|
6 |
* + reset status variables |
|
|
7 |
*/ |
|
|
8 |
if ( ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) { |
|
|
9 |
define( 'PMA_NO_VARIABLES_IMPORT', true ); |
|
|
10 |
} |
|
|
11 |
require_once('./libraries/common.lib.php'); |
|
|
12 |
|
|
|
13 |
/** |
|
|
14 |
* Does the common work |
|
|
15 |
*/ |
|
|
16 |
require './libraries/server_common.inc.php'; |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
/** |
|
|
20 |
* Displays the links |
|
|
21 |
*/ |
|
|
22 |
require './libraries/server_links.inc.php'; |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
/** |
|
|
26 |
* Displays the sub-page heading |
|
|
27 |
*/ |
|
|
28 |
echo '<a name="_top"></a>' . "\n"; |
|
|
29 |
echo '<div id="serverstatus">' . "\n"; |
|
|
30 |
echo '<h2>' . "\n" |
|
|
31 |
. ($GLOBALS['cfg']['MainPageIconic'] |
|
|
32 |
? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . |
|
|
33 |
's_status.png" width="16" height="16" alt="" />' |
|
|
34 |
: '' ) |
|
|
35 |
. $strServerStatus . "\n" |
|
|
36 |
. '</h2>' . "\n"; |
|
|
37 |
|
|
|
38 |
|
|
|
39 |
/** |
|
|
40 |
* flush status variables if requested |
|
|
41 |
*/ |
|
|
42 |
if ( isset( $_REQUEST['flush'] ) ) { |
|
|
43 |
$_flush_commands = array( |
|
|
44 |
'STATUS', |
|
|
45 |
'TABLES', |
|
|
46 |
'QUERY CACHE', |
|
|
47 |
); |
|
|
48 |
|
|
|
49 |
if ( in_array( $_REQUEST['flush'], $_flush_commands ) ) { |
|
|
50 |
PMA_DBI_query('FLUSH ' . $_REQUEST['flush'] . ';'); |
|
|
51 |
} |
|
|
52 |
unset( $_flush_commands ); |
|
|
53 |
} |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
/** |
|
|
57 |
* get status from server |
|
|
58 |
*/ |
|
|
59 |
if ( PMA_MYSQL_INT_VERSION >= 50002 ) { |
|
|
60 |
$server_status = PMA_DBI_fetch_result( 'SHOW GLOBAL STATUS', 0, 1 ); |
|
|
61 |
} else { |
|
|
62 |
$server_status = PMA_DBI_fetch_result( 'SHOW STATUS', 0, 1 ); |
|
|
63 |
} |
|
|
64 |
|
|
|
65 |
|
|
|
66 |
/** |
|
|
67 |
* for some calculations we require also some server settings |
|
|
68 |
*/ |
|
|
69 |
if ( PMA_MYSQL_INT_VERSION >= 40003 ) { |
|
|
70 |
$server_variables = PMA_DBI_fetch_result( 'SHOW GLOBAL VARIABLES', 0, 1 ); |
|
|
71 |
} else { |
|
|
72 |
$server_variables = PMA_DBI_fetch_result( 'SHOW VARIABLES', 0, 1 ); |
|
|
73 |
} |
|
|
74 |
|
|
|
75 |
|
|
|
76 |
/** |
|
|
77 |
* starttime calculation |
|
|
78 |
*/ |
|
|
79 |
$start_time = PMA_DBI_fetch_value( |
|
|
80 |
'SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime'] ); |
|
|
81 |
|
|
|
82 |
|
|
|
83 |
/** |
|
|
84 |
* cleanup some deprecated values |
|
|
85 |
*/ |
|
|
86 |
$deprecated = array( |
|
|
87 |
'Com_prepare_sql' => 'Com_stmt_prepare', |
|
|
88 |
'Com_execute_sql' => 'Com_stmt_execute', |
|
|
89 |
'Com_dealloc_sql' => 'Com_stmt_close', |
|
|
90 |
); |
|
|
91 |
|
|
|
92 |
foreach ( $deprecated as $old => $new ) { |
|
|
93 |
if ( isset( $server_status[$old] ) |
|
|
94 |
&& isset( $server_status[$new] ) ) { |
|
|
95 |
unset( $server_status[$old] ); |
|
|
96 |
} |
|
|
97 |
} |
|
|
98 |
unset( $deprecated ); |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
/** |
|
|
102 |
* calculate some values |
|
|
103 |
*/ |
|
|
104 |
// Key_buffer_fraction |
|
|
105 |
if ( isset( $server_status['Key_blocks_unused'] ) |
|
|
106 |
&& isset( $server_variables['key_cache_block_size'] ) |
|
|
107 |
&& isset( $server_variables['key_buffer_size'] ) ) { |
|
|
108 |
$server_status['Key_buffer_fraction_%'] = |
|
|
109 |
100 |
|
|
110 |
- $server_status['Key_blocks_unused'] |
|
|
111 |
* $server_variables['key_cache_block_size'] |
|
|
112 |
/ $server_variables['key_buffer_size'] |
|
|
113 |
* 100; |
|
|
114 |
} elseif ( |
|
|
115 |
isset( $server_status['Key_blocks_used'] ) |
|
|
116 |
&& isset( $server_variables['key_buffer_size'] ) ) { |
|
|
117 |
$server_status['Key_buffer_fraction_%'] = |
|
|
118 |
$server_status['Key_blocks_used'] |
|
|
119 |
* 1024 |
|
|
120 |
/ $server_variables['key_buffer_size']; |
|
|
121 |
} |
|
|
122 |
// Threads_cache_hitrate |
|
|
123 |
if ( isset( $server_status['Threads_created'] ) |
|
|
124 |
&& isset( $server_status['Connections'] ) ) { |
|
|
125 |
$server_status['Threads_cache_hitrate_%'] = |
|
|
126 |
100 |
|
|
127 |
- $server_status['Threads_created'] |
|
|
128 |
/ $server_status['Connections'] |
|
|
129 |
* 100; |
|
|
130 |
} |
|
|
131 |
|
|
|
132 |
|
|
|
133 |
/** |
|
|
134 |
* define some alerts |
|
|
135 |
*/ |
|
|
136 |
// name => max value before alert |
|
|
137 |
$alerts = array( |
|
|
138 |
// lower is better |
|
|
139 |
// variable => max value |
|
|
140 |
'Aborted_clients' => 0, |
|
|
141 |
'Aborted_connects' => 0, |
|
|
142 |
|
|
|
143 |
'Binlog_cache_disk_use' => 0, |
|
|
144 |
|
|
|
145 |
'Created_tmp_disk_tables' => 0, |
|
|
146 |
|
|
|
147 |
'Handler_read_rnd' => 0, |
|
|
148 |
'Handler_read_rnd_next' => 0, |
|
|
149 |
|
|
|
150 |
'Innodb_buffer_pool_pages_dirty' => 0, |
|
|
151 |
'Innodb_buffer_pool_reads' => 0, |
|
|
152 |
'Innodb_buffer_pool_wait_free' => 0, |
|
|
153 |
'Innodb_log_waits' => 0, |
|
|
154 |
'Innodb_row_lock_time_avg' => 10, // ms |
|
|
155 |
'Innodb_row_lock_time_max' => 50, // ms |
|
|
156 |
'Innodb_row_lock_waits' => 0, |
|
|
157 |
|
|
|
158 |
'Slow_queries' => 0, |
|
|
159 |
'Delayed_errors' => 0, |
|
|
160 |
'Select_full_join' => 0, |
|
|
161 |
'Select_range_check' => 0, |
|
|
162 |
'Sort_merge_passes' => 0, |
|
|
163 |
'Opened_tables' => 0, |
|
|
164 |
'Table_locks_waited' => 0, |
|
|
165 |
'Qcache_lowmem_prunes' => 0, |
|
|
166 |
'Slow_launch_threads' => 0, |
|
|
167 |
|
|
|
168 |
// depends on Key_read_requests |
|
|
169 |
// normaly lower then 1:0.01 |
|
|
170 |
'Key_reads' => (0.01 * $server_status['Key_read_requests']), |
|
|
171 |
// depends on Key_write_requests |
|
|
172 |
// normaly nearly 1:1 |
|
|
173 |
'Key_writes' => (0.9 * $server_status['Key_write_requests']), |
|
|
174 |
|
|
|
175 |
'Key_buffer_fraction' => 0.5, |
|
|
176 |
|
|
|
177 |
// alert if more than 95% of thread cache is in use |
|
|
178 |
'Threads_cached' => 0.95 * $server_variables['thread_cache_size'] |
|
|
179 |
|
|
|
180 |
// higher is better |
|
|
181 |
// variable => min value |
|
|
182 |
//'Handler read key' => '> ', |
|
|
183 |
); |
|
|
184 |
|
|
|
185 |
|
|
|
186 |
/** |
|
|
187 |
* split variables in sections |
|
|
188 |
*/ |
|
|
189 |
$allocations = array( |
|
|
190 |
// variable name => section |
|
|
191 |
|
|
|
192 |
'Com_' => 'com', |
|
|
193 |
'Innodb_' => 'innodb', |
|
|
194 |
'Ndb_' => 'ndb', |
|
|
195 |
'Ssl_' => 'ssl', |
|
|
196 |
'Handler_' => 'handler', |
|
|
197 |
'Qcache_' => 'qcache', |
|
|
198 |
'Threads_' => 'threads', |
|
|
199 |
'Slow_launch_threads' => 'threads', |
|
|
200 |
|
|
|
201 |
'Binlog_cache_' => 'binlog_cache', |
|
|
202 |
'Created_tmp_' => 'created_tmp', |
|
|
203 |
'Key_' => 'key', |
|
|
204 |
|
|
|
205 |
'Delayed_' => 'delayed', |
|
|
206 |
'Not_flushed_delayed_rows' => 'delayed', |
|
|
207 |
|
|
|
208 |
'Flush_commands' => 'query', |
|
|
209 |
'Last_query_cost' => 'query', |
|
|
210 |
'Slow_queries' => 'query', |
|
|
211 |
|
|
|
212 |
'Select_' => 'select', |
|
|
213 |
'Sort_' => 'sort', |
|
|
214 |
|
|
|
215 |
'Open_tables' => 'table', |
|
|
216 |
'Opened_tables' => 'table', |
|
|
217 |
'Table_locks_' => 'table', |
|
|
218 |
|
|
|
219 |
'Rpl_status' => 'repl', |
|
|
220 |
'Slave_' => 'repl', |
|
|
221 |
|
|
|
222 |
'Tc_' => 'tc', |
|
|
223 |
); |
|
|
224 |
|
|
|
225 |
$sections = array( |
|
|
226 |
// section => section name (description) |
|
|
227 |
'com' => array( 'title' => '' ), |
|
|
228 |
'query' => array( 'title' => '' ), |
|
|
229 |
'innodb' => array( 'title' => 'InnoDB' ), |
|
|
230 |
'ndb' => array( 'title' => 'NDB' ), |
|
|
231 |
'ssl' => array( 'title' => 'SSL' ), |
|
|
232 |
'handler' => array( 'title' => $strHandler ), |
|
|
233 |
'qcache' => array( 'title' => $strQueryCache ), |
|
|
234 |
'threads' => array( 'title' => $strThreads ), |
|
|
235 |
'binlog_cache' => array( 'title' => $strBinaryLog ), |
|
|
236 |
'created_tmp' => array( 'title' => $strTempData ), |
|
|
237 |
'delayed' => array( 'title' => $strServerStatusDelayedInserts ), |
|
|
238 |
'key' => array( 'title' => $strKeyCache ), |
|
|
239 |
'select' => array( 'title' => $strJoins ), |
|
|
240 |
'repl' => array( 'title' => $strReplication ), |
|
|
241 |
'sort' => array( 'title' => $strSorting ), |
|
|
242 |
'table' => array( 'title' => $strNumTables ), |
|
|
243 |
'tc' => array( 'title' => $strTransactionCoordinator ), |
|
|
244 |
); |
|
|
245 |
|
|
|
246 |
|
|
|
247 |
/** |
|
|
248 |
* define some needfull links/commands |
|
|
249 |
*/ |
|
|
250 |
// variable or section name => (name => url) |
|
|
251 |
$links = array(); |
|
|
252 |
|
|
|
253 |
$links['table'][$strFlushTables] |
|
|
254 |
= $PHP_SELF . '?flush=TABLES&' . PMA_generate_common_url(); |
|
|
255 |
$links['table'][$strShowOpenTables] |
|
|
256 |
= 'sql.php?sql_query=' . urlencode('SHOW OPEN TABLES') . |
|
|
257 |
'&goto=server_status.php&' . PMA_generate_common_url(); |
|
|
258 |
|
|
|
259 |
$links['repl'][$strShowSlaveHosts] |
|
|
260 |
= 'sql.php?sql_query=' . urlencode('SHOW SLAVE HOSTS') . |
|
|
261 |
'&goto=server_status.php&' . PMA_generate_common_url(); |
|
|
262 |
$links['repl'][$strShowSlaveStatus] |
|
|
263 |
= 'sql.php?sql_query=' . urlencode('SHOW SLAVE STATUS') . |
|
|
264 |
'&goto=server_status.php&' . PMA_generate_common_url(); |
|
|
265 |
$links['repl']['MySQL - ' . $strDocu] |
|
|
266 |
= $cfg['MySQLManualBase'] . '/replication.html'; |
|
|
267 |
|
|
|
268 |
$links['qcache'][$strFlushQueryCache] |
|
|
269 |
= $PHP_SELF . '?flush=' . urlencode('QUERY CACHE') . '&' . |
|
|
270 |
PMA_generate_common_url(); |
|
|
271 |
$links['qcache']['MySQL - ' . $strDocu] |
|
|
272 |
= $cfg['MySQLManualBase'] . '/query-cache.html'; |
|
|
273 |
|
|
|
274 |
$links['threads'][$strMySQLShowProcess] |
|
|
275 |
= 'server_processlist.php?' . PMA_generate_common_url(); |
|
|
276 |
$links['threads']['MySQL - ' . $strDocu] |
|
|
277 |
= $cfg['MySQLManualBase'] . '/mysql-threads.html'; |
|
|
278 |
|
|
|
279 |
$links['key']['MySQL - ' . $strDocu] |
|
|
280 |
= $cfg['MySQLManualBase'] . '/myisam-key-cache.html'; |
|
|
281 |
|
|
|
282 |
$links['slow_queries']['MySQL - ' . $strDocu] |
|
|
283 |
= $cfg['MySQLManualBase'] . '/slow-query-log.html'; |
|
|
284 |
|
|
|
285 |
$links['binlog_cache']['MySQL - ' . $strDocu] |
|
|
286 |
= $cfg['MySQLManualBase'] . '/binary-log.html'; |
|
|
287 |
|
|
|
288 |
$links['Slow_queries']['MySQL - ' . $strDocu] |
|
|
289 |
= $cfg['MySQLManualBase'] . '/slow-query-log.html'; |
|
|
290 |
|
|
|
291 |
$links['innodb'][$strServerTabVariables] |
|
|
292 |
= 'server_engines.php?engine=innodb&' . PMA_generate_common_url(); |
|
|
293 |
$links['innodb'][$strInnodbStat] |
|
|
294 |
= 'server_engines.php?engine=innodb&page=status&' . |
|
|
295 |
PMA_generate_common_url(); |
|
|
296 |
$links['innodb']['MySQL - ' . $strDocu] |
|
|
297 |
= $cfg['MySQLManualBase'] . '/innodb.html'; |
|
|
298 |
|
|
|
299 |
|
|
|
300 |
// sort status vars into arrays |
|
|
301 |
foreach ( $server_status as $name => $value ) { |
|
|
302 |
if ( isset( $allocations[$name] ) ) { |
|
|
303 |
$sections[$allocations[$name]]['vars'][$name] = $value; |
|
|
304 |
unset( $server_status[$name] ); |
|
|
305 |
} else { |
|
|
306 |
foreach ( $allocations as $filter => $section ) { |
|
|
307 |
if ( preg_match( '/^' . $filter . '/', $name ) |
|
|
308 |
&& isset( $server_status[$name] ) ) { |
|
|
309 |
unset( $server_status[$name] ); |
|
|
310 |
$sections[$section]['vars'][$name] = $value; |
|
|
311 |
} |
|
|
312 |
} |
|
|
313 |
} |
|
|
314 |
} |
|
|
315 |
unset( $name, $value, $filter, $section, $allocations ); |
|
|
316 |
|
|
|
317 |
// rest |
|
|
318 |
$sections['all']['vars'] =& $server_status; |
|
|
319 |
|
|
|
320 |
$hour_factor = 3600 / $server_status['Uptime']; |
|
|
321 |
|
|
|
322 |
/** |
|
|
323 |
* start output |
|
|
324 |
*/ |
|
|
325 |
?> |
|
|
326 |
<div id="statuslinks"> |
|
|
327 |
<a href="<?php echo |
|
|
328 |
$PHP_SELF . '?' . PMA_generate_common_url(); ?>" |
|
|
329 |
><?php echo $strRefresh; ?></a> |
|
|
330 |
<a href="<?php echo |
|
|
331 |
$PHP_SELF . '?flush=STATUS&' . PMA_generate_common_url(); ?>" |
|
|
332 |
><?php echo $strShowStatusReset; ?></a> |
|
|
333 |
<a href="<?php echo |
|
|
334 |
$cfg['MySQLManualBase']; ?>/server-status-variables.html" |
|
|
335 |
target="documentation">MySQL - <?php echo $strDocu; ?></a> |
|
|
336 |
</div> |
|
|
337 |
|
|
|
338 |
<p> |
|
|
339 |
<?php |
|
|
340 |
echo sprintf( $strServerStatusUptime, |
|
|
341 |
PMA_timespanFormat( $server_status['Uptime'] ), |
|
|
342 |
PMA_localisedDate( $start_time ) ) . "\n"; |
|
|
343 |
?> |
|
|
344 |
</p> |
|
|
345 |
|
|
|
346 |
<div id="sectionlinks"> |
|
|
347 |
<?php |
|
|
348 |
foreach ( $sections as $section_name => $section ) { |
|
|
349 |
if ( ! empty( $section['vars'] ) && ! empty( $section['title'] ) ) { |
|
|
350 |
echo '<a href="' . $PHP_SELF . '?' . |
|
|
351 |
PMA_generate_common_url() . '#' . $section_name . '">' . |
|
|
352 |
$section['title'] . '</a>' . "\n"; |
|
|
353 |
} |
|
|
354 |
} |
|
|
355 |
?> |
|
|
356 |
</div> |
|
|
357 |
|
|
|
358 |
<h3><?php echo $strServerTrafficNotes; ?></h3> |
|
|
359 |
|
|
|
360 |
<table id="serverstatustraffic" class="data"> |
|
|
361 |
<thead> |
|
|
362 |
<tr> |
|
|
363 |
<th colspan="2"><?php echo $strTraffic . ' ' . PMA_showHint($strStatisticsOverrun); ?></th> |
|
|
364 |
<th>ø <?php echo $strPerHour; ?></th> |
|
|
365 |
</tr> |
|
|
366 |
</thead> |
|
|
367 |
<tbody> |
|
|
368 |
<tr class="odd"> |
|
|
369 |
<th class="name"><?php echo $strReceived; ?></th> |
|
|
370 |
<td class="value"><?php echo |
|
|
371 |
implode(' ', |
|
|
372 |
PMA_formatByteDown( $server_status['Bytes_received'], 3 ) ); ?></td> |
|
|
373 |
<td class="value"><?php echo |
|
|
374 |
implode(' ', |
|
|
375 |
PMA_formatByteDown( |
|
|
376 |
$server_status['Bytes_received'] * $hour_factor, 3 ) ); ?></td> |
|
|
377 |
</tr> |
|
|
378 |
<tr class="even"> |
|
|
379 |
<th class="name"><?php echo $strSent; ?></th> |
|
|
380 |
<td class="value"><?php echo |
|
|
381 |
implode(' ', |
|
|
382 |
PMA_formatByteDown( $server_status['Bytes_sent'], 3 ) ); ?></td> |
|
|
383 |
<td class="value"><?php echo |
|
|
384 |
implode(' ', |
|
|
385 |
PMA_formatByteDown( |
|
|
386 |
$server_status['Bytes_sent'] * $hour_factor, 3 ) ); ?></td> |
|
|
387 |
</tr> |
|
|
388 |
<tr class="odd"> |
|
|
389 |
<th class="name"><?php echo $strTotalUC; ?></th> |
|
|
390 |
<td class="value"><?php echo |
|
|
391 |
implode(' ', |
|
|
392 |
PMA_formatByteDown( |
|
|
393 |
$server_status['Bytes_received'] + $server_status['Bytes_sent'], 3 ) |
|
|
394 |
); ?></td> |
|
|
395 |
<td class="value"><?php echo |
|
|
396 |
implode(' ', |
|
|
397 |
PMA_formatByteDown( |
|
|
398 |
($server_status['Bytes_received'] + $server_status['Bytes_sent']) |
|
|
399 |
* $hour_factor, 3 ) |
|
|
400 |
); ?></td> |
|
|
401 |
</tr> |
|
|
402 |
</tbody> |
|
|
403 |
</table> |
|
|
404 |
|
|
|
405 |
<table id="serverstatusconnections" class="data"> |
|
|
406 |
<thead> |
|
|
407 |
<tr> |
|
|
408 |
<th colspan="2"><?php echo $strConnections; ?></th> |
|
|
409 |
<th>ø <?php echo $strPerHour; ?></th> |
|
|
410 |
<th>%</th> |
|
|
411 |
</tr> |
|
|
412 |
</thead> |
|
|
413 |
<tbody> |
|
|
414 |
<tr class="odd"> |
|
|
415 |
<th class="name"><?php echo $strMaxConnects; ?></th> |
|
|
416 |
<td class="value"><?php echo |
|
|
417 |
number_format( $server_status['Max_used_connections'], 0, |
|
|
418 |
$GLOBALS['number_decimal_separator'], |
|
|
419 |
$GLOBALS['number_thousands_separator']); ?> </td> |
|
|
420 |
<td class="value">--- </td> |
|
|
421 |
<td class="value">--- </td> |
|
|
422 |
</tr> |
|
|
423 |
<tr class="even"> |
|
|
424 |
<th class="name"><?php echo $strFailedAttempts; ?></th> |
|
|
425 |
<td class="value"><?php echo |
|
|
426 |
PMA_formatNumber( $server_status['Aborted_connects'], 4, 0 ); ?></td> |
|
|
427 |
<td class="value"><?php echo |
|
|
428 |
PMA_formatNumber( $server_status['Aborted_connects'] * $hour_factor, |
|
|
429 |
4, 2 ); ?></td> |
|
|
430 |
<td class="value"><?php echo |
|
|
431 |
$server_status['Connections'] > 0 |
|
|
432 |
? number_format( |
|
|
433 |
$server_status['Aborted_connects'] * 100 / $server_status['Connections'], |
|
|
434 |
2, $GLOBALS['number_decimal_separator'], |
|
|
435 |
$GLOBALS['number_thousands_separator'] ) . '%' |
|
|
436 |
: '--- '; ?></td> |
|
|
437 |
</tr> |
|
|
438 |
<tr class="odd"> |
|
|
439 |
<th class="name"><?php echo $strAbortedClients; ?></th> |
|
|
440 |
<td class="value"><?php echo |
|
|
441 |
PMA_formatNumber( $server_status['Aborted_clients'], 4, 0 ); ?></td> |
|
|
442 |
<td class="value"><?php echo |
|
|
443 |
PMA_formatNumber( $server_status['Aborted_clients'] * $hour_factor, |
|
|
444 |
4, 2 ); ?></td> |
|
|
445 |
<td class="value"><?php echo |
|
|
446 |
$server_status['Connections'] > 0 |
|
|
447 |
? number_format( |
|
|
448 |
$server_status['Aborted_clients'] * 100 / $server_status['Connections'], |
|
|
449 |
2, $GLOBALS['number_decimal_separator'], |
|
|
450 |
$GLOBALS['number_thousands_separator']) . '%' |
|
|
451 |
: '--- '; ?></td> |
|
|
452 |
</tr> |
|
|
453 |
<tr class="even"> |
|
|
454 |
<th class="name"><?php echo $strTotalUC; ?></th> |
|
|
455 |
<td class="value"><?php echo |
|
|
456 |
PMA_formatNumber( $server_status['Connections'], 4, 0 ); ?></td> |
|
|
457 |
<td class="value"><?php echo |
|
|
458 |
PMA_formatNumber( $server_status['Connections'] * $hour_factor, |
|
|
459 |
4, 2 ); ?></td> |
|
|
460 |
<td class="value"><?php echo |
|
|
461 |
number_format( 100, 2, $GLOBALS['number_decimal_separator'], |
|
|
462 |
$GLOBALS['number_thousands_separator'] ); ?>%</td> |
|
|
463 |
</tr> |
|
|
464 |
</tbody> |
|
|
465 |
</table> |
|
|
466 |
|
|
|
467 |
<hr class="clearfloat" /> |
|
|
468 |
|
|
|
469 |
<h3><?php echo |
|
|
470 |
sprintf( $strQueryStatistics, |
|
|
471 |
number_format($server_status['Questions'], |
|
|
472 |
0, $GLOBALS['number_decimal_separator'], |
|
|
473 |
$GLOBALS['number_thousands_separator'] ) ); ?></h3> |
|
|
474 |
|
|
|
475 |
<table id="serverstatusqueriessummary" class="data"> |
|
|
476 |
<thead> |
|
|
477 |
<tr> |
|
|
478 |
<th><?php echo $strTotalUC; ?></th> |
|
|
479 |
<th>ø <?php echo $strPerHour; ?></th> |
|
|
480 |
<th>ø <?php echo $strPerMinute; ?></th> |
|
|
481 |
<th>ø <?php echo $strPerSecond; ?></th> |
|
|
482 |
</tr> |
|
|
483 |
</thead> |
|
|
484 |
<tbody> |
|
|
485 |
<tr class="odd"> |
|
|
486 |
<td class="value"><?php echo |
|
|
487 |
PMA_formatNumber( $server_status['Questions'], 3, 0 ); ?></td> |
|
|
488 |
<td class="value"><?php echo |
|
|
489 |
PMA_formatNumber( $server_status['Questions'] * $hour_factor, |
|
|
490 |
3, 2 ); ?></td> |
|
|
491 |
<td class="value"><?php echo |
|
|
492 |
PMA_formatNumber( |
|
|
493 |
$server_status['Questions'] * 60 / $server_status['Uptime'], |
|
|
494 |
3, 2 ); ?></td> |
|
|
495 |
<td class="value"><?php echo |
|
|
496 |
PMA_formatNumber( |
|
|
497 |
$server_status['Questions'] / $server_status['Uptime'], |
|
|
498 |
3, 2 ); ?></td> |
|
|
499 |
</tr> |
|
|
500 |
</tbody> |
|
|
501 |
</table> |
|
|
502 |
|
|
|
503 |
<div id="serverstatusqueriesdetails"> |
|
|
504 |
<?php |
|
|
505 |
// number of tables to split values into |
|
|
506 |
$tables = 2; |
|
|
507 |
$rows_per_table = (int) ceil( count( $sections['com']['vars'] ) / $tables ); |
|
|
508 |
$current_table = 0; |
|
|
509 |
$odd_row = true; |
|
|
510 |
$countRows = 0; |
|
|
511 |
$perc_factor = 100 / ( $server_status['Questions'] - $server_status['Connections'] ); |
|
|
512 |
foreach ( $sections['com']['vars'] as $name => $value ) { |
|
|
513 |
$current_table++; |
|
|
514 |
if ( $countRows === 0 || $countRows === $rows_per_table ) { |
|
|
515 |
$odd_row = true; |
|
|
516 |
if ( $countRows === $rows_per_table ) { |
|
|
517 |
echo ' </tbody>' . "\n"; |
|
|
518 |
echo ' </table>' . "\n"; |
|
|
519 |
} |
|
|
520 |
?> |
|
|
521 |
<table id="serverstatusqueriesdetails<?php echo $current_table; ?>" class="data"> |
|
|
522 |
<col class="namecol" /> |
|
|
523 |
<col class="valuecol" span="3" /> |
|
|
524 |
<thead> |
|
|
525 |
<tr><th colspan="2"><?php echo $strQueryType; ?></th> |
|
|
526 |
<th>ø <?php echo $strPerHour; ?></th> |
|
|
527 |
<th>%</th> |
|
|
528 |
</tr> |
|
|
529 |
</thead> |
|
|
530 |
<tbody> |
|
|
531 |
<?php |
|
|
532 |
} else { |
|
|
533 |
$odd_row = !$odd_row; |
|
|
534 |
} |
|
|
535 |
$countRows++; |
|
|
536 |
|
|
|
537 |
// For the percentage column, use Questions - Connections, because |
|
|
538 |
// the number of connections is not an item of the Query types |
|
|
539 |
// but is included in Questions. Then the total of the percentages is 100. |
|
|
540 |
$name = str_replace( 'Com_', '', $name ); |
|
|
541 |
$name = str_replace( '_', ' ', $name ); |
|
|
542 |
?> |
|
|
543 |
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>"> |
|
|
544 |
<th class="name"><?php echo htmlspecialchars( $name ); ?></th> |
|
|
545 |
<td class="value"><?php echo PMA_formatNumber( $value, 3, 0 ); ?></td> |
|
|
546 |
<td class="value"><?php echo |
|
|
547 |
PMA_formatNumber( $value * $hour_factor, 3, 2 ); ?></td> |
|
|
548 |
<td class="value"><?php echo |
|
|
549 |
number_format( $value * $perc_factor, 2, |
|
|
550 |
$GLOBALS['number_decimal_separator'], |
|
|
551 |
$GLOBALS['number_thousands_separator'] ); ?>%</td> |
|
|
552 |
</tr> |
|
|
553 |
<?php |
|
|
554 |
} |
|
|
555 |
?> |
|
|
556 |
</tbody> |
|
|
557 |
</table> |
|
|
558 |
</div> |
|
|
559 |
|
|
|
560 |
<div id="serverstatussection"> |
|
|
561 |
<?php |
|
|
562 |
//Unset used variables |
|
|
563 |
unset( |
|
|
564 |
$tables, $rows_per_table, $current_table, $countRows, $perc_factor, |
|
|
565 |
$hour_factor, $sections['com'], |
|
|
566 |
$server_status['Aborted_clients'], $server_status['Aborted_connects'], |
|
|
567 |
$server_status['Max_used_connections'], $server_status['Bytes_received'], |
|
|
568 |
$server_status['Bytes_sent'], $server_status['Connections'], |
|
|
569 |
$server_status['Questions'], $server_status['Uptime'] |
|
|
570 |
); |
|
|
571 |
|
|
|
572 |
foreach ( $sections as $section_name => $section ) { |
|
|
573 |
if ( ! empty( $section['vars'] ) ) { |
|
|
574 |
?> |
|
|
575 |
<table class="data" id="serverstatussection<?php echo $section_name; ?>"> |
|
|
576 |
<caption class="tblHeaders"> |
|
|
577 |
<a class="top" |
|
|
578 |
href="<?php echo $PHP_SELF . '?' . |
|
|
579 |
PMA_generate_common_url() . '#_top'; ?>" |
|
|
580 |
name="<?php echo $section_name; ?>"><?php echo $strPos1; ?> |
|
|
581 |
<?php echo |
|
|
582 |
($GLOBALS['cfg']['MainPageIconic'] |
|
|
583 |
? '<img src="' . $GLOBALS['pmaThemeImage'] . |
|
|
584 |
's_asc.png" width="11" height="9" align="middle" alt="" />' |
|
|
585 |
: '' ); ?> |
|
|
586 |
</a> |
|
|
587 |
<?php |
|
|
588 |
if ( ! empty( $section['title'] ) ) { |
|
|
589 |
echo $section['title']; |
|
|
590 |
} |
|
|
591 |
?> |
|
|
592 |
</caption> |
|
|
593 |
<col class="namecol" /> |
|
|
594 |
<col class="valuecol" /> |
|
|
595 |
<col class="descrcol" /> |
|
|
596 |
<thead> |
|
|
597 |
<tr> |
|
|
598 |
<th><?php echo $strVar; ?></th> |
|
|
599 |
<th><?php echo $strValue; ?></th> |
|
|
600 |
<th><?php echo $strDescription; ?></th> |
|
|
601 |
</tr> |
|
|
602 |
</thead> |
|
|
603 |
<?php |
|
|
604 |
if ( ! empty( $links[$section_name] ) ) { |
|
|
605 |
?> |
|
|
606 |
<tfoot> |
|
|
607 |
<tr class="tblFooters"> |
|
|
608 |
<th colspan="3" class="tblFooters"> |
|
|
609 |
<?php |
|
|
610 |
foreach ( $links[$section_name] as $link_name => $link_url ) { |
|
|
611 |
echo '<a href="' . $link_url . '">' . $link_name . '</a>' . "\n"; |
|
|
612 |
} |
|
|
613 |
unset( $link_url, $link_name ); |
|
|
614 |
?> |
|
|
615 |
</th> |
|
|
616 |
</tr> |
|
|
617 |
</tfoot> |
|
|
618 |
<?php |
|
|
619 |
} |
|
|
620 |
?> |
|
|
621 |
<tbody> |
|
|
622 |
<?php |
|
|
623 |
$odd_row = false; |
|
|
624 |
foreach ( $section['vars'] as $name => $value ) { |
|
|
625 |
$odd_row = !$odd_row; |
|
|
626 |
?> |
|
|
627 |
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>"> |
|
|
628 |
<th class="name"><?php echo htmlspecialchars($name); ?></th> |
|
|
629 |
<td class="value"><?php |
|
|
630 |
if ( isset( $alerts[$name] ) ) { |
|
|
631 |
if ( $value > $alerts[$name] ) { |
|
|
632 |
echo '<span class="attention">'; |
|
|
633 |
} else { |
|
|
634 |
echo '<span class="allfine">'; |
|
|
635 |
} |
|
|
636 |
} |
|
|
637 |
if ( '%' === substr( $name, -1, 1 ) ) { |
|
|
638 |
echo number_format( $value, 2, |
|
|
639 |
$GLOBALS['number_decimal_separator'], |
|
|
640 |
$GLOBALS['number_thousands_separator'] ) . ' %'; |
|
|
641 |
} elseif ( is_numeric( $value ) && $value == (int) $value ) { |
|
|
642 |
echo PMA_formatNumber( $value, 3, 0 ); |
|
|
643 |
} elseif ( is_numeric( $value ) ) { |
|
|
644 |
echo PMA_formatNumber( $value, 3, 2 ); |
|
|
645 |
} else { |
|
|
646 |
echo htmlspecialchars( $value ); |
|
|
647 |
} |
|
|
648 |
if ( isset( $alerts[$name] ) ) { |
|
|
649 |
echo '</span>'; |
|
|
650 |
} |
|
|
651 |
?></td> |
|
|
652 |
<td class="descr"> |
|
|
653 |
<?php |
|
|
654 |
if ( isset( $GLOBALS['strShowStatus' . $name . 'Descr'] ) ) { |
|
|
655 |
echo $GLOBALS['strShowStatus' . $name . 'Descr']; |
|
|
656 |
} |
|
|
657 |
|
|
|
658 |
if ( isset( $links[$name] ) ) { |
|
|
659 |
foreach ( $links[$name] as $link_name => $link_url ) { |
|
|
660 |
echo ' <a href="' . $link_url . '">' . $link_name . '</a>' . |
|
|
661 |
"\n"; |
|
|
662 |
} |
|
|
663 |
unset( $link_url, $link_name ); |
|
|
664 |
} |
|
|
665 |
?> |
|
|
666 |
</td> |
|
|
667 |
</tr> |
|
|
668 |
<?php |
|
|
669 |
} |
|
|
670 |
unset( $name, $value ); |
|
|
671 |
?> |
|
|
672 |
</tbody> |
|
|
673 |
</table> |
|
|
674 |
<?php |
|
|
675 |
} |
|
|
676 |
} |
|
|
677 |
unset( $section_name, $section, $sections, $server_status, $odd_row, $alerts ); |
|
|
678 |
?> |
|
|
679 |
</div> |
|
|
680 |
</div> |
|
|
681 |
<?php |
|
|
682 |
|
|
|
683 |
|
|
|
684 |
/** |
|
|
685 |
* Sends the footer |
|
|
686 |
*/ |
|
|
687 |
require_once './libraries/footer.inc.php'; |
|
|
688 |
?> |