2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * functions for displaying server status
6 * @usedby server_status.php
10 use PMA\libraries\ServerStatusData
;
13 * Prints server status information: processes, connections and traffic
15 * @param ServerStatusData $ServerStatusData Server status data
19 function PMA_getHtmlForServerStatus($ServerStatusData)
21 //display the server state General Information
22 $retval = PMA_getHtmlForServerStateGeneralInfo($ServerStatusData);
24 //display the server state traffic information
25 $retval .= PMA_getHtmlForServerStateTraffic($ServerStatusData);
27 //display the server state connection information
28 $retval .= PMA_getHtmlForServerStateConnections($ServerStatusData);
30 // display replication information
31 if ($GLOBALS['replication_info']['master']['status']
32 ||
$GLOBALS['replication_info']['slave']['status']
34 $retval .= PMA_getHtmlForReplicationInfo();
41 * Prints server state General information
43 * @param ServerStatusData $ServerStatusData Server status data
47 function PMA_getHtmlForServerStateGeneralInfo($ServerStatusData)
49 $start_time = $GLOBALS['dbi']->fetchValue(
50 'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status
['Uptime']
54 $bytes_received = $ServerStatusData->status
['Bytes_received'];
55 $bytes_sent = $ServerStatusData->status
['Bytes_sent'];
57 __('Network traffic since startup: %s'),
60 PMA\libraries\Util
::formatByteDown(
61 $bytes_received +
$bytes_sent,
70 __('This MySQL server has been running for %1$s. It started up on %2$s.'),
71 PMA\libraries\Util
::timespanFormat($ServerStatusData->status
['Uptime']),
72 PMA\libraries\Util
::localisedDate($start_time)
80 * Returns HTML to display replication information
82 * @return string HTML on replication
84 function PMA_getHtmlForReplicationInfo()
86 $retval = '<p class="notice clearfloat">';
87 if ($GLOBALS['replication_info']['master']['status']
88 && $GLOBALS['replication_info']['slave']['status']
91 'This MySQL server works as <b>master</b> and '
92 . '<b>slave</b> in <b>replication</b> process.'
94 } elseif ($GLOBALS['replication_info']['master']['status']) {
96 'This MySQL server works as <b>master</b> '
97 . 'in <b>replication</b> process.'
99 } elseif ($GLOBALS['replication_info']['slave']['status']) {
101 'This MySQL server works as <b>slave</b> '
102 . 'in <b>replication</b> process.'
108 * if the server works as master or slave in replication process,
109 * display useful information
111 $retval .= '<hr class="clearfloat" />';
112 $retval .= '<h3><a name="replication">';
113 $retval .= __('Replication status');
114 $retval .= '</a></h3>';
115 foreach ($GLOBALS['replication_types'] as $type) {
116 if (isset($GLOBALS['replication_info'][$type]['status'])
117 && $GLOBALS['replication_info'][$type]['status']
119 $retval .= PMA_getHtmlForReplicationStatusTable($type);
127 * Prints server state traffic information
129 * @param ServerStatusData $ServerStatusData Server status data
133 function PMA_getHtmlForServerStateTraffic($ServerStatusData)
135 $hour_factor = 3600 / $ServerStatusData->status
['Uptime'];
136 $retval = '<table id="serverstatustraffic" class="data noclick">';
137 $retval .= '<thead>';
140 $retval .= __('Traffic') . ' ';
141 $retval .= PMA\libraries\Util
::showHint(
143 'On a busy server, the byte counters may overrun, so those statistics '
144 . 'as reported by the MySQL server may be incorrect.'
148 $retval .= '<th>#</th>';
149 $retval .= '<th>ø ' . __('per hour') . '</th>';
151 $retval .= '</thead>';
152 $retval .= '<tbody>';
154 $retval .= '<th class="name">' . __('Received') . '</th>';
155 $retval .= '<td class="value">';
158 PMA\libraries\Util
::formatByteDown(
159 $ServerStatusData->status
['Bytes_received'], 3, 1
163 $retval .= '<td class="value">';
166 PMA\libraries\Util
::formatByteDown(
167 $ServerStatusData->status
['Bytes_received'] * $hour_factor, 3, 1
173 $retval .= '<th class="name">' . __('Sent') . '</th>';
174 $retval .= '<td class="value">';
177 PMA\libraries\Util
::formatByteDown(
178 $ServerStatusData->status
['Bytes_sent'], 3, 1
182 $retval .= '<td class="value">';
185 PMA\libraries\Util
::formatByteDown(
186 $ServerStatusData->status
['Bytes_sent'] * $hour_factor, 3, 1
192 $retval .= '<th class="name">' . __('Total') . '</th>';
193 $retval .= '<td class="value">';
194 $bytes_received = $ServerStatusData->status
['Bytes_received'];
195 $bytes_sent = $ServerStatusData->status
['Bytes_sent'];
198 PMA\libraries\Util
::formatByteDown(
199 $bytes_received +
$bytes_sent, 3, 1
203 $retval .= '<td class="value">';
204 $bytes_received = $ServerStatusData->status
['Bytes_received'];
205 $bytes_sent = $ServerStatusData->status
['Bytes_sent'];
208 PMA\libraries\Util
::formatByteDown(
209 ($bytes_received +
$bytes_sent) * $hour_factor, 3, 1
214 $retval .= '</tbody>';
215 $retval .= '</table>';
220 * Prints server state connections information
222 * @param ServerStatusData $ServerStatusData Server status data
226 function PMA_getHtmlForServerStateConnections($ServerStatusData)
228 $hour_factor = 3600 / $ServerStatusData->status
['Uptime'];
229 $retval = '<table id="serverstatusconnections" class="data noclick">';
230 $retval .= '<thead>';
232 $retval .= '<th>' . __('Connections') . '</th>';
233 $retval .= '<th>#</th>';
234 $retval .= '<th>ø ' . __('per hour') . '</th>';
235 $retval .= '<th>%</th>';
237 $retval .= '</thead>';
238 $retval .= '<tbody>';
240 $retval .= '<th class="name">' . __('Max. concurrent connections') . '</th>';
241 $retval .= '<td class="value">';
242 $retval .= PMA\libraries\Util
::formatNumber(
243 $ServerStatusData->status
['Max_used_connections'], 0
246 $retval .= '<td class="value">--- </td>';
247 $retval .= '<td class="value">--- </td>';
250 $retval .= '<th class="name">' . __('Failed attempts') . '</th>';
251 $retval .= '<td class="value">';
252 $retval .= PMA\libraries\Util
::formatNumber(
253 $ServerStatusData->status
['Aborted_connects'], 4, 1, true
256 $retval .= '<td class="value">';
257 $retval .= PMA\libraries\Util
::formatNumber(
258 $ServerStatusData->status
['Aborted_connects'] * $hour_factor, 4, 2, true
261 $retval .= '<td class="value">';
262 if ($ServerStatusData->status
['Connections'] > 0) {
263 $abortNum = $ServerStatusData->status
['Aborted_connects'];
264 $connectNum = $ServerStatusData->status
['Connections'];
266 $retval .= PMA\libraries\Util
::formatNumber(
267 $abortNum * 100 / $connectNum,
277 $retval .= '<th class="name">' . __('Aborted') . '</th>';
278 $retval .= '<td class="value">';
279 $retval .= PMA\libraries\Util
::formatNumber(
280 $ServerStatusData->status
['Aborted_clients'], 4, 1, true
283 $retval .= '<td class="value">';
284 $retval .= PMA\libraries\Util
::formatNumber(
285 $ServerStatusData->status
['Aborted_clients'] * $hour_factor, 4, 2, true
288 $retval .= '<td class="value">';
289 if ($ServerStatusData->status
['Connections'] > 0) {
290 $abortNum = $ServerStatusData->status
['Aborted_clients'];
291 $connectNum = $ServerStatusData->status
['Connections'];
293 $retval .= PMA\libraries\Util
::formatNumber(
294 $abortNum * 100 / $connectNum,
304 $retval .= '<th class="name">' . __('Total') . '</th>';
305 $retval .= '<td class="value">';
306 $retval .= PMA\libraries\Util
::formatNumber(
307 $ServerStatusData->status
['Connections'], 4, 0
310 $retval .= '<td class="value">';
311 $retval .= PMA\libraries\Util
::formatNumber(
312 $ServerStatusData->status
['Connections'] * $hour_factor, 4, 2
315 $retval .= '<td class="value">';
316 $retval .= PMA\libraries\Util
::formatNumber(100, 0, 2);
319 $retval .= '</tbody>';
320 $retval .= '</table>';