Translated using Weblate (Slovenian)
[phpmyadmin.git] / libraries / server_status.lib.php
blobea485f9565b0c2f8ad8b77d07d61735cd16d1164
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * functions for displaying server status
6 * @usedby server_status.php
8 * @package PhpMyAdmin
9 */
10 use PMA\libraries\ServerStatusData;
12 /**
13 * Prints server status information: processes, connections and traffic
15 * @param ServerStatusData $ServerStatusData Server status data
17 * @return string
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']
33 ) {
34 $retval .= PMA_getHtmlForReplicationInfo();
37 return $retval;
40 /**
41 * Prints server state General information
43 * @param ServerStatusData $ServerStatusData Server status data
45 * @return string
47 function PMA_getHtmlForServerStateGeneralInfo($ServerStatusData)
49 $start_time = $GLOBALS['dbi']->fetchValue(
50 'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']
53 $retval = '<h3>';
54 $bytes_received = $ServerStatusData->status['Bytes_received'];
55 $bytes_sent = $ServerStatusData->status['Bytes_sent'];
56 $retval .= sprintf(
57 __('Network traffic since startup: %s'),
58 implode(
59 ' ',
60 PMA\libraries\Util::formatByteDown(
61 $bytes_received + $bytes_sent,
67 $retval .= '</h3>';
68 $retval .= '<p>';
69 $retval .= sprintf(
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)
73 ) . "\n";
74 $retval .= '</p>';
76 return $retval;
79 /**
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']
89 ) {
90 $retval .= __(
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']) {
95 $retval .= __(
96 'This MySQL server works as <b>master</b> '
97 . 'in <b>replication</b> process.'
99 } elseif ($GLOBALS['replication_info']['slave']['status']) {
100 $retval .= __(
101 'This MySQL server works as <b>slave</b> '
102 . 'in <b>replication</b> process.'
105 $retval .= '</p>';
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);
123 return $retval;
127 * Prints server state traffic information
129 * @param ServerStatusData $ServerStatusData Server status data
131 * @return string
133 function PMA_getHtmlForServerStateTraffic($ServerStatusData)
135 $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
136 $retval = '<table id="serverstatustraffic" class="data noclick">';
137 $retval .= '<thead>';
138 $retval .= '<tr>';
139 $retval .= '<th>';
140 $retval .= __('Traffic') . '&nbsp;';
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.'
147 $retval .= '</th>';
148 $retval .= '<th>#</th>';
149 $retval .= '<th>&oslash; ' . __('per hour') . '</th>';
150 $retval .= '</tr>';
151 $retval .= '</thead>';
152 $retval .= '<tbody>';
153 $retval .= '<tr>';
154 $retval .= '<th class="name">' . __('Received') . '</th>';
155 $retval .= '<td class="value">';
156 $retval .= implode(
157 ' ',
158 PMA\libraries\Util::formatByteDown(
159 $ServerStatusData->status['Bytes_received'], 3, 1
162 $retval .= '</td>';
163 $retval .= '<td class="value">';
164 $retval .= implode(
165 ' ',
166 PMA\libraries\Util::formatByteDown(
167 $ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1
170 $retval .= '</td>';
171 $retval .= '</tr>';
172 $retval .= '<tr>';
173 $retval .= '<th class="name">' . __('Sent') . '</th>';
174 $retval .= '<td class="value">';
175 $retval .= implode(
176 ' ',
177 PMA\libraries\Util::formatByteDown(
178 $ServerStatusData->status['Bytes_sent'], 3, 1
181 $retval .= '</td>';
182 $retval .= '<td class="value">';
183 $retval .= implode(
184 ' ',
185 PMA\libraries\Util::formatByteDown(
186 $ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1
189 $retval .= '</td>';
190 $retval .= '</tr>';
191 $retval .= '<tr>';
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'];
196 $retval .= implode(
197 ' ',
198 PMA\libraries\Util::formatByteDown(
199 $bytes_received + $bytes_sent, 3, 1
202 $retval .= '</td>';
203 $retval .= '<td class="value">';
204 $bytes_received = $ServerStatusData->status['Bytes_received'];
205 $bytes_sent = $ServerStatusData->status['Bytes_sent'];
206 $retval .= implode(
207 ' ',
208 PMA\libraries\Util::formatByteDown(
209 ($bytes_received + $bytes_sent) * $hour_factor, 3, 1
212 $retval .= '</td>';
213 $retval .= '</tr>';
214 $retval .= '</tbody>';
215 $retval .= '</table>';
216 return $retval;
220 * Prints server state connections information
222 * @param ServerStatusData $ServerStatusData Server status data
224 * @return string
226 function PMA_getHtmlForServerStateConnections($ServerStatusData)
228 $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
229 $retval = '<table id="serverstatusconnections" class="data noclick">';
230 $retval .= '<thead>';
231 $retval .= '<tr>';
232 $retval .= '<th>' . __('Connections') . '</th>';
233 $retval .= '<th>#</th>';
234 $retval .= '<th>&oslash; ' . __('per hour') . '</th>';
235 $retval .= '<th>%</th>';
236 $retval .= '</tr>';
237 $retval .= '</thead>';
238 $retval .= '<tbody>';
239 $retval .= '<tr>';
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
245 $retval .= '</td>';
246 $retval .= '<td class="value">--- </td>';
247 $retval .= '<td class="value">--- </td>';
248 $retval .= '</tr>';
249 $retval .= '<tr>';
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
255 $retval .= '</td>';
256 $retval .= '<td class="value">';
257 $retval .= PMA\libraries\Util::formatNumber(
258 $ServerStatusData->status['Aborted_connects'] * $hour_factor, 4, 2, true
260 $retval .= '</td>';
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,
268 0, 2, true
270 $retval .= '%';
271 } else {
272 $retval .= '--- ';
274 $retval .= '</td>';
275 $retval .= '</tr>';
276 $retval .= '<tr>';
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
282 $retval .= '</td>';
283 $retval .= '<td class="value">';
284 $retval .= PMA\libraries\Util::formatNumber(
285 $ServerStatusData->status['Aborted_clients'] * $hour_factor, 4, 2, true
287 $retval .= '</td>';
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,
295 0, 2, true
297 $retval .= '%';
298 } else {
299 $retval .= '--- ';
301 $retval .= '</td>';
302 $retval .= '</tr>';
303 $retval .= '<tr>';
304 $retval .= '<th class="name">' . __('Total') . '</th>';
305 $retval .= '<td class="value">';
306 $retval .= PMA\libraries\Util::formatNumber(
307 $ServerStatusData->status['Connections'], 4, 0
309 $retval .= '</td>';
310 $retval .= '<td class="value">';
311 $retval .= PMA\libraries\Util::formatNumber(
312 $ServerStatusData->status['Connections'] * $hour_factor, 4, 2
314 $retval .= '</td>';
315 $retval .= '<td class="value">';
316 $retval .= PMA\libraries\Util::formatNumber(100, 0, 2);
317 $retval .= '%</td>';
318 $retval .= '</tr>';
319 $retval .= '</tbody>';
320 $retval .= '</table>';
322 return $retval;