2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * functions for displaying server status
7 * @usedby server_status.php
11 if (! defined('PHPMYADMIN')) {
16 * Prints server status information: processes, connections and traffic
18 * @param PMA_ServerStatusData $ServerStatusData Server status data
22 function PMA_getHtmlForServerStatus($ServerStatusData)
24 //display the server state General Information
25 $retval = PMA_getHtmlForServerStateGeneralInfo($ServerStatusData);
27 //display the server state traffic information
28 $retval .= PMA_getHtmlForServerStateTraffic($ServerStatusData);
30 //display the server state connection information
31 $retval .= PMA_getHtmlForServerStateConnections($ServerStatusData);
33 // display replication information
34 if ($GLOBALS['replication_info']['master']['status']
35 ||
$GLOBALS['replication_info']['slave']['status']
37 $retval .= PMA_getHtmlForReplicationInfo();
44 * Prints server state General information
46 * @param PMA_ServerStatusData $ServerStatusData Server status data
50 function PMA_getHtmlForServerStateGeneralInfo($ServerStatusData)
52 $start_time = $GLOBALS['dbi']->fetchValue(
53 'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status
['Uptime']
57 $bytes_received = $ServerStatusData->status
['Bytes_received'];
58 $bytes_sent = $ServerStatusData->status
['Bytes_sent'];
60 __('Network traffic since startup: %s'),
63 PMA_Util
::formatByteDown(
64 $bytes_received +
$bytes_sent,
73 __('This MySQL server has been running for %1$s. It started up on %2$s.'),
74 PMA_Util
::timespanFormat($ServerStatusData->status
['Uptime']),
75 PMA_Util
::localisedDate($start_time)
83 * Returns HTML to display replication information
85 * @return string HTML on replication
87 function PMA_getHtmlForReplicationInfo()
89 $retval = '<p class="notice clearfloat">';
90 if ($GLOBALS['replication_info']['master']['status']
91 && $GLOBALS['replication_info']['slave']['status']
94 'This MySQL server works as <b>master</b> and '
95 . '<b>slave</b> in <b>replication</b> process.'
97 } elseif ($GLOBALS['replication_info']['master']['status']) {
99 'This MySQL server works as <b>master</b> '
100 . 'in <b>replication</b> process.'
102 } elseif ($GLOBALS['replication_info']['slave']['status']) {
104 'This MySQL server works as <b>slave</b> '
105 . 'in <b>replication</b> process.'
111 * if the server works as master or slave in replication process,
112 * display useful information
114 $retval .= '<hr class="clearfloat" />';
115 $retval .= '<h3><a name="replication">';
116 $retval .= __('Replication status');
117 $retval .= '</a></h3>';
118 foreach ($GLOBALS['replication_types'] as $type) {
119 if (isset($GLOBALS['replication_info'][$type]['status'])
120 && $GLOBALS['replication_info'][$type]['status']
122 $retval .= PMA_getHtmlForReplicationStatusTable($type);
130 * Prints server state traffic information
132 * @param PMA_ServerStatusData $ServerStatusData Server status data
136 function PMA_getHtmlForServerStateTraffic($ServerStatusData)
138 $hour_factor = 3600 / $ServerStatusData->status
['Uptime'];
139 $retval = '<table id="serverstatustraffic" class="data noclick">';
140 $retval .= '<thead>';
143 $retval .= __('Traffic') . ' ';
144 $retval .= PMA_Util
::showHint(
146 'On a busy server, the byte counters may overrun, so those statistics '
147 . 'as reported by the MySQL server may be incorrect.'
151 $retval .= '<th>#</th>';
152 $retval .= '<th>ø ' . __('per hour') . '</th>';
154 $retval .= '</thead>';
155 $retval .= '<tbody>';
156 $retval .= '<tr class="odd">';
157 $retval .= '<th class="name">' . __('Received') . '</th>';
158 $retval .= '<td class="value">';
161 PMA_Util
::formatByteDown(
162 $ServerStatusData->status
['Bytes_received'], 3, 1
166 $retval .= '<td class="value">';
169 PMA_Util
::formatByteDown(
170 $ServerStatusData->status
['Bytes_received'] * $hour_factor, 3, 1
175 $retval .= '<tr class="even">';
176 $retval .= '<th class="name">' . __('Sent') . '</th>';
177 $retval .= '<td class="value">';
180 PMA_Util
::formatByteDown(
181 $ServerStatusData->status
['Bytes_sent'], 3, 1
185 $retval .= '<td class="value">';
188 PMA_Util
::formatByteDown(
189 $ServerStatusData->status
['Bytes_sent'] * $hour_factor, 3, 1
194 $retval .= '<tr class="odd">';
195 $retval .= '<th class="name">' . __('Total') . '</th>';
196 $retval .= '<td class="value">';
197 $bytes_received = $ServerStatusData->status
['Bytes_received'];
198 $bytes_sent = $ServerStatusData->status
['Bytes_sent'];
201 PMA_Util
::formatByteDown(
202 $bytes_received +
$bytes_sent, 3, 1
206 $retval .= '<td class="value">';
207 $bytes_received = $ServerStatusData->status
['Bytes_received'];
208 $bytes_sent = $ServerStatusData->status
['Bytes_sent'];
211 PMA_Util
::formatByteDown(
212 ($bytes_received +
$bytes_sent) * $hour_factor, 3, 1
217 $retval .= '</tbody>';
218 $retval .= '</table>';
223 * Prints server state connections information
225 * @param PMA_ServerStatusData $ServerStatusData Server status data
229 function PMA_getHtmlForServerStateConnections($ServerStatusData)
231 $hour_factor = 3600 / $ServerStatusData->status
['Uptime'];
232 $retval = '<table id="serverstatusconnections" class="data noclick">';
233 $retval .= '<thead>';
235 $retval .= '<th>' . __('Connections') . '</th>';
236 $retval .= '<th>#</th>';
237 $retval .= '<th>ø ' . __('per hour') . '</th>';
238 $retval .= '<th>%</th>';
240 $retval .= '</thead>';
241 $retval .= '<tbody>';
242 $retval .= '<tr class="odd">';
243 $retval .= '<th class="name">' . __('Max. concurrent connections') . '</th>';
244 $retval .= '<td class="value">';
245 $retval .= PMA_Util
::formatNumber(
246 $ServerStatusData->status
['Max_used_connections'], 0
249 $retval .= '<td class="value">--- </td>';
250 $retval .= '<td class="value">--- </td>';
252 $retval .= '<tr class="even">';
253 $retval .= '<th class="name">' . __('Failed attempts') . '</th>';
254 $retval .= '<td class="value">';
255 $retval .= PMA_Util
::formatNumber(
256 $ServerStatusData->status
['Aborted_connects'], 4, 1, true
259 $retval .= '<td class="value">';
260 $retval .= PMA_Util
::formatNumber(
261 $ServerStatusData->status
['Aborted_connects'] * $hour_factor, 4, 2, true
264 $retval .= '<td class="value">';
265 if ($ServerStatusData->status
['Connections'] > 0) {
266 $abortNum = $ServerStatusData->status
['Aborted_connects'];
267 $connectNum = $ServerStatusData->status
['Connections'];
269 $retval .= PMA_Util
::formatNumber(
270 $abortNum * 100 / $connectNum,
279 $retval .= '<tr class="odd">';
280 $retval .= '<th class="name">' . __('Aborted') . '</th>';
281 $retval .= '<td class="value">';
282 $retval .= PMA_Util
::formatNumber(
283 $ServerStatusData->status
['Aborted_clients'], 4, 1, true
286 $retval .= '<td class="value">';
287 $retval .= PMA_Util
::formatNumber(
288 $ServerStatusData->status
['Aborted_clients'] * $hour_factor, 4, 2, true
291 $retval .= '<td class="value">';
292 if ($ServerStatusData->status
['Connections'] > 0) {
293 $abortNum = $ServerStatusData->status
['Aborted_clients'];
294 $connectNum = $ServerStatusData->status
['Connections'];
296 $retval .= PMA_Util
::formatNumber(
297 $abortNum * 100 / $connectNum,
306 $retval .= '<tr class="even">';
307 $retval .= '<th class="name">' . __('Total') . '</th>';
308 $retval .= '<td class="value">';
309 $retval .= PMA_Util
::formatNumber(
310 $ServerStatusData->status
['Connections'], 4, 0
313 $retval .= '<td class="value">';
314 $retval .= PMA_Util
::formatNumber(
315 $ServerStatusData->status
['Connections'] * $hour_factor, 4, 2
318 $retval .= '<td class="value">';
319 $retval .= PMA_Util
::formatNumber(100, 0, 2);
322 $retval .= '</tbody>';
323 $retval .= '</table>';