added japanese language
[openemr.git] / phpmyadmin / libraries / server_status_queries.lib.php
blob87366319ba24ff1efd7833c8fa5366d777c9e645
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * functions for displaying query statistics for the server
7 * @usedby server_status_queries.php
9 * @package PhpMyAdmin
11 if (! defined('PHPMYADMIN')) {
12 exit;
15 /**
16 * Returns the html content for the query statistics
18 * @param PMA_ServerStatusData $ServerStatusData Server status data
20 * @return string
22 function PMA_getHtmlForQueryStatistics($ServerStatusData)
24 $retval = '';
26 $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
27 $used_queries = $ServerStatusData->used_queries;
28 $total_queries = array_sum($used_queries);
30 $retval .= '<h3 id="serverstatusqueries">';
31 /* l10n: Questions is the name of a MySQL Status variable */
32 $retval .= sprintf(
33 __('Questions since startup: %s'),
34 PMA_Util::formatNumber($total_queries, 0)
36 $retval .= ' ';
37 $retval .= PMA_Util::showMySQLDocu(
38 'server-status-variables',
39 false,
40 'statvar_Questions'
42 $retval .= '<br />';
43 $retval .= '<span>';
44 $retval .= '&oslash; ' . __('per hour:') . ' ';
45 $retval .= PMA_Util::formatNumber($total_queries * $hour_factor, 0);
46 $retval .= '<br />';
47 $retval .= '&oslash; ' . __('per minute:') . ' ';
48 $retval .= PMA_Util::formatNumber(
49 $total_queries * 60 / $ServerStatusData->status['Uptime'],
52 $retval .= '<br />';
53 if ($total_queries / $ServerStatusData->status['Uptime'] >= 1) {
54 $retval .= '&oslash; ' . __('per second:') . ' ';
55 $retval .= PMA_Util::formatNumber(
56 $total_queries / $ServerStatusData->status['Uptime'],
60 $retval .= '</span>';
61 $retval .= '</h3>';
63 $retval .= PMA_getHtmlForServerStatusQueriesDetails($ServerStatusData);
65 return $retval;
68 /**
69 * Returns the html content for the query details
71 * @param PMA_ServerStatusData $ServerStatusData Server status data
73 * @return string
75 function PMA_getHtmlForServerStatusQueriesDetails($ServerStatusData)
77 $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
78 $used_queries = $ServerStatusData->used_queries;
79 $total_queries = array_sum($used_queries);
80 // reverse sort by value to show most used statements first
81 arsort($used_queries);
83 $odd_row = true;
85 //(- $ServerStatusData->status['Connections']);
86 $perc_factor = 100 / $total_queries;
88 $retval = '<table id="serverstatusqueriesdetails" '
89 . 'class="data sortable noclick">';
90 $retval .= '<col class="namecol" />';
91 $retval .= '<col class="valuecol" span="3" />';
92 $retval .= '<thead>';
93 $retval .= '<tr><th>' . __('Statements') . '</th>';
94 $retval .= '<th>';
95 /* l10n: # = Amount of queries */
96 $retval .= __('#');
97 $retval .= '</th>';
98 $retval .= '<th>&oslash; ' . __('per hour') . '</th>';
99 $retval .= '<th>%</th>';
100 $retval .= '</tr>';
101 $retval .= '</thead>';
102 $retval .= '<tbody>';
104 $chart_json = array();
105 $query_sum = array_sum($used_queries);
106 $other_sum = 0;
107 foreach ($used_queries as $name => $value) {
108 $odd_row = !$odd_row;
109 // For the percentage column, use Questions - Connections, because
110 // the number of connections is not an item of the Query types
111 // but is included in Questions. Then the total of the percentages is 100.
112 $name = str_replace(array('Com_', '_'), array('', ' '), $name);
113 // Group together values that make out less than 2% into "Other", but only
114 // if we have more than 6 fractions already
115 if ($value < $query_sum * 0.02 && count($chart_json)>6) {
116 $other_sum += $value;
117 } else {
118 $chart_json[$name] = $value;
120 $retval .= '<tr class="';
121 $retval .= $odd_row ? 'odd' : 'even';
122 $retval .= '">';
123 $retval .= '<th class="name">' . htmlspecialchars($name) . '</th>';
124 $retval .= '<td class="value">';
125 $retval .= htmlspecialchars(PMA_Util::formatNumber($value, 5, 0, true));
126 $retval .= '</td>';
127 $retval .= '<td class="value">';
128 $retval .= htmlspecialchars(
129 PMA_Util::formatNumber($value * $hour_factor, 4, 1, true)
131 $retval .= '</td>';
132 $retval .= '<td class="value">';
133 $retval .= htmlspecialchars(
134 PMA_Util::formatNumber($value * $perc_factor, 0, 2)
136 $retval .= '</td>';
137 $retval .= '</tr>';
139 $retval .= '</tbody>';
140 $retval .= '</table>';
142 $retval .= '<div id="serverstatusquerieschart"></div>';
143 $retval .= '<div id="serverstatusquerieschart_data" style="display:none;">';
144 if ($other_sum > 0) {
145 $chart_json[__('Other')] = $other_sum;
147 $retval .= htmlspecialchars(json_encode($chart_json));
148 $retval .= '</div>';
150 return $retval;