Initial import.
[openemr.git] / interface / main / myadmin / server_status.php
blob9baddf03d3730fc8fdbdec81d83974ba45898f7b
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Does the common work
8 */
9 require('./server_common.inc.php');
12 /**
13 * Displays the links
15 require('./server_links.inc.php');
18 /**
19 * InnoDB status
21 if (!empty($innodbstatus)) {
22 echo '<h2>' . "\n"
23 . ' ' . $strInnodbStat . "\n"
24 . '</h2>' . "\n";
25 $sql_query = 'SHOW INNODB STATUS;';
26 $res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query);
27 $row = PMA_mysql_fetch_row($res);
28 echo '<pre>' . "\n"
29 . htmlspecialchars($row[0]) . "\n"
30 . '</pre>' . "\n";
31 mysql_free_result($res);
32 require_once('./footer.inc.php');
35 /**
36 * Displays the sub-page heading
38 echo '<h2>' . "\n"
39 . ' ' . $strServerStatus . "\n"
40 . '</h2>' . "\n";
43 /**
44 * Checks if the user is allowed to do what he tries to...
46 if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
47 echo $strNoPrivileges;
48 require_once('./footer.inc.php');
52 /**
53 * Sends the query and buffers the result
55 $res = @PMA_mysql_query('SHOW STATUS;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW STATUS;');
56 while ($row = PMA_mysql_fetch_row($res)) {
57 $serverStatus[$row[0]] = $row[1];
59 @mysql_free_result($res);
60 unset($res);
61 unset($row);
64 /**
65 * Displays the page
67 //Uptime calculation
68 $res = @PMA_mysql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
69 $row = PMA_mysql_fetch_row($res);
70 echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
71 mysql_free_result($res);
72 unset($res);
73 unset($row);
74 //Get query statistics
75 $queryStats = array();
76 $tmp_array = $serverStatus;
77 foreach($tmp_array AS $name => $value) {
78 if (substr($name, 0, 4) == 'Com_') {
79 $queryStats[str_replace('_', ' ', substr($name, 4))] = $value;
80 unset($serverStatus[$name]);
83 unset($tmp_array);
85 <ul>
86 <li>
87 <!-- Server Traffic -->
88 <?php echo $strServerTrafficNotes; ?><br />
89 <table border="0">
90 <tr>
91 <td valign="top">
92 <table border="0">
93 <tr>
94 <th colspan="2">&nbsp;<?php echo $strTraffic; ?>&nbsp;</th>
95 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
96 </tr>
97 <tr>
98 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strReceived; ?>&nbsp;</td>
99 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?>&nbsp;</td>
100 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
101 </tr>
102 <tr>
103 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strSent; ?>&nbsp;</td>
104 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?>&nbsp;</td>
105 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
106 </tr>
107 <tr>
108 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
109 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?>&nbsp;</td>
110 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
111 </tr>
112 </table>
113 </td>
114 <td valign="top">
115 <table border="0">
116 <tr>
117 <th colspan="2">&nbsp;<?php echo $strConnections; ?>&nbsp;</th>
118 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
119 <th>&nbsp;%&nbsp;</th>
120 </tr>
121 <tr>
122 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strFailedAttempts; ?>&nbsp;</td>
123 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Aborted_connects'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
124 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Aborted_connects'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
125 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_connects'] * 100 / $serverStatus['Connections']), 2, $number_decimal_separator, $number_thousands_separator) . '&nbsp;%' : '---'; ?>&nbsp;</td>
126 </tr>
127 <tr>
128 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strAbortedClients; ?>&nbsp;</td>
129 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Aborted_clients'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
130 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Aborted_clients'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
131 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo ($serverStatus['Connections'] > 0 ) ? number_format(($serverStatus['Aborted_clients'] * 100 / $serverStatus['Connections']), 2 , $number_decimal_separator, $number_thousands_separator) . '&nbsp;%' : '---'; ?>&nbsp;</td>
132 </tr>
133 <tr>
134 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
135 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
136 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Connections'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
137 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(100, 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;%&nbsp;</td>
138 </tr>
139 </table>
140 </td>
141 </tr>
142 </table>
143 </li>
144 <br />
145 <li>
146 <!-- Queries -->
147 <?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)) . "\n"; ?>
148 <table border="0">
149 <tr>
150 <td colspan="2">
151 <br />
152 <table border="0" align="right">
153 <tr>
154 <th>&nbsp;<?php echo $strTotalUC; ?>&nbsp;</th>
155 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
156 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerMinute; ?>&nbsp;</th>
157 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerSecond; ?>&nbsp;</th>
158 </tr>
159 <tr>
160 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
161 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
162 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] * 60 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
163 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format(($serverStatus['Questions'] / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
164 </tr>
165 </table>
166 </td>
167 </tr>
168 <tr>
169 <td valign="top">
170 <table border="0">
171 <tr>
172 <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
173 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
174 <th>&nbsp;%&nbsp;</th>
175 </tr>
176 <?php
178 $useBgcolorOne = TRUE;
179 $countRows = 0;
180 foreach ($queryStats as $name => $value) {
182 // For the percentage column, use Questions - Connections, because
183 // the number of connections is not an item of the Query types
184 // but is included in Questions. Then the total of the percentages is 100.
186 <tr>
187 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars($name); ?>&nbsp;</td>
188 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format($value, 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
189 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($value * 3600 / $serverStatus['Uptime']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
190 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($value * 100 / ($serverStatus['Questions'] - $serverStatus['Connections'])), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;%&nbsp;</td>
191 </tr>
192 <?php
193 $useBgcolorOne = !$useBgcolorOne;
194 if (++$countRows == ceil(count($queryStats) / 2)) {
195 $useBgcolorOne = TRUE;
197 </table>
198 </td>
199 <td valign="top">
200 <table border="0">
201 <tr>
202 <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
203 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
204 <th>&nbsp;%&nbsp;</th>
205 </tr>
206 <?php
209 unset($countRows);
210 unset($useBgcolorOne);
212 </table>
213 </td>
214 </tr>
215 </table>
216 </li>
217 <?php
218 //Unset used variables
219 unset($serverStatus['Aborted_clients']);
220 unset($serverStatus['Aborted_connects']);
221 unset($serverStatus['Bytes_received']);
222 unset($serverStatus['Bytes_sent']);
223 unset($serverStatus['Connections']);
224 unset($serverStatus['Questions']);
225 unset($serverStatus['Uptime']);
227 if (!empty($serverStatus)) {
229 <br />
230 <li>
231 <!-- Other status variables -->
232 <b><?php echo $strMoreStatusVars; ?></b><br />
233 <table border="0">
234 <tr>
235 <td valign="top">
236 <table border="0">
237 <tr>
238 <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
239 <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
240 </tr>
241 <?php
242 $useBgcolorOne = TRUE;
243 $countRows = 0;
244 foreach($serverStatus AS $name => $value) {
246 <tr>
247 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?>&nbsp;</td>
248 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo htmlspecialchars($value); ?>&nbsp;</td>
249 </tr>
250 <?php
251 $useBgcolorOne = !$useBgcolorOne;
252 if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) {
253 $useBgcolorOne = TRUE;
255 </table>
256 </td>
257 <td valign="top">
258 <table border="0">
259 <tr>
260 <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
261 <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
262 </tr>
263 <?php
266 unset($useBgcolorOne);
268 </table>
269 </td>
270 </tr>
271 </table>
272 </li>
273 <?php
275 $res = PMA_mysql_query('SHOW VARIABLES LIKE "have_innodb";', $userlink);
276 if ($res) {
277 $row = PMA_mysql_fetch_row($res);
278 if (!empty($row[1]) && $row[1] == 'YES') {
280 <br />
281 <li>
282 <!-- InnoDB Status -->
283 <a href="./server_status.php?<?php echo $url_query; ?>&amp;innodbstatus=1">
284 <b><?php echo $strInnodbStat; ?></b>
285 </a>
286 </li>
287 <?php
289 } else {
290 unset($res);
293 </ul>
296 <?php
300 * Sends the footer
302 require_once('./footer.inc.php');