update
[phpmyadmin/crack.git] / server_status.php3
blob5815d39356fa35ed4a432cc37acf37c1e0c55f44
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.php3');
11 /**
12 * Displays the links
14 require('./server_links.inc.php3');
16 /**
17 * Displays the sub-page heading
19 echo '<h2>' . "\n"
20 . ' ' . $strServerStatus . "\n"
21 . '</h2>' . "\n";
23 /**
24 * Checks if the user is allowed to do what he tries to...
26 if (!$is_superuser && !$cfg['ShowMysqlInfo']) {
27 echo $strNoPrivileges;
28 include('./footer.inc.php3');
29 exit;
32 /**
33 * Sends the query and buffers the result
35 $res = @PMA_mysql_query('SHOW STATUS;', $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), 'SHOW STATUS;');
36 while ($row = PMA_mysql_fetch_row($res)) {
37 $serverStatus[$row[0]] = $row[1];
39 @mysql_free_result($res);
40 unset($res);
41 unset($row);
43 /**
44 * Displays the page
46 //Uptime calculation
47 $res = @PMA_mysql_query('SELECT UNIX_TIMESTAMP() - ' . $serverStatus['Uptime'] . ';');
48 $row = PMA_mysql_fetch_row($res);
49 echo sprintf($strServerStatusUptime, PMA_timespanFormat($serverStatus['Uptime']), PMA_localisedDate($row[0])) . "\n";
50 mysql_free_result($res);
51 unset($res);
52 unset($row);
53 //Get query statistics
54 $queryStats = array();
55 $tmp_array = $serverStatus;
56 while (list($name, $value) = each($tmp_array)) {
57 if (substr($name, 0, 4) == 'Com_') {
58 $queryStats[str_replace('_', ' ', substr($name, 4))] = $value;
59 unset($serverStatus[$name]);
62 unset($tmp_array);
64 <ul>
65 <li>
66 <!-- Server Traffic -->
67 <?php echo $strServerTrafficNotes; ?><br />
68 <table border="0">
69 <tr>
70 <td valign="top">
71 <table border="0">
72 <tr>
73 <th colspan="2">&nbsp;<?php echo $strTraffic; ?>&nbsp;</th>
74 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
75 </tr>
76 <tr>
77 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strReceived; ?>&nbsp;</td>
78 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'])); ?>&nbsp;</td>
79 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
80 </tr>
81 <tr>
82 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strSent; ?>&nbsp;</td>
83 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'])); ?>&nbsp;</td>
84 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_sent'] * 3600 / $serverStatus['Uptime'])); ?>&nbsp;</td>
85 </tr>
86 <tr>
87 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
88 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?>&nbsp;</td>
89 <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>
90 </tr>
91 </table>
92 </td>
93 <td valign="top">
94 <table border="0">
95 <tr>
96 <th colspan="2">&nbsp;<?php echo $strConnections; ?>&nbsp;</th>
97 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
98 <th>&nbsp;%&nbsp;</th>
99 </tr>
100 <tr>
101 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strFailedAttempts; ?>&nbsp;</td>
102 <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>
103 <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>
104 <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>
105 </tr>
106 <tr>
107 <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo $strAbortedClients; ?>&nbsp;</td>
108 <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>
109 <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>
110 <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>
111 </tr>
112 <tr>
113 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">&nbsp;<?php echo $strTotalUC; ?>&nbsp;</td>
114 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;<?php echo number_format($serverStatus['Connections'], 0, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;</td>
115 <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>
116 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">&nbsp;100,00&nbsp;%&nbsp;</td>
117 </tr>
118 </table>
119 </td>
120 </tr>
121 </table>
122 </li>
123 <br />
124 <li>
125 <!-- Queries -->
126 <?php echo sprintf($strQueryStatistics, number_format($serverStatus['Questions'], 0, $number_decimal_separator, $number_thousands_separator)); ?><br />
127 <table border="0">
128 <tr>
129 <td valign="top">
130 <table border="0">
131 <tr>
132 <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
133 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
134 <th>&nbsp;%&nbsp;</th>
135 </tr>
136 <?php
138 $useBgcolorOne = TRUE;
139 $countRows = 0;
140 while (list($name, $value) = each($queryStats)) {
142 <tr>
143 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars($name); ?>&nbsp;</td>
144 <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>
145 <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>
146 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>" align="right">&nbsp;<?php echo number_format(($value * 100 / $serverStatus['Questions']), 2, $number_decimal_separator, $number_thousands_separator); ?>&nbsp;%&nbsp;</td>
147 </tr>
148 <?php
149 $useBgcolorOne = !$useBgcolorOne;
150 if (++$countRows == ceil(count($queryStats) / 2)) {
151 $useBgcolorOne = TRUE;
153 </table>
154 </td>
155 <td valign="top">
156 <table border="0">
157 <tr>
158 <th colspan="2">&nbsp;<?php echo $strQueryType; ?>&nbsp;</th>
159 <th>&nbsp;&oslash;&nbsp;<?php echo $strPerHour; ?>&nbsp;</th>
160 <th>&nbsp;%&nbsp;</th>
161 </tr>
162 <?php
165 unset($countRows);
166 unset($useBgcolorOne);
169 </table>
170 </td>
171 </tr>
172 </table>
173 </li>
174 <?php
175 //Unset used variables
176 unset($serverStatus['Aborted_clients']);
177 unset($serverStatus['Aborted_connects']);
178 unset($serverStatus['Bytes_received']);
179 unset($serverStatus['Bytes_sent']);
180 unset($serverStatus['Connections']);
181 unset($serverStatus['Questions']);
182 unset($serverStatus['Uptime']);
184 if (!empty($serverStatus)) {
186 <br />
187 <li>
188 <!-- Other status variables -->
189 <b><?php echo $strMoreStatusVars; ?></b><br />
190 <table border="0">
191 <tr>
192 <td valign="top">
193 <table border="0">
194 <tr>
195 <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
196 <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
197 </tr>
198 <?php
199 $useBgcolorOne = TRUE;
200 $countRows = 0;
201 while (list($name, $value) = each($serverStatus)) {
203 <tr>
204 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars(str_replace('_', ' ', $name)); ?>&nbsp;</td>
205 <td bgcolor="<?php echo $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; ?>">&nbsp;<?php echo htmlspecialchars($value); ?>&nbsp;</td>
206 </tr>
207 <?php
208 $useBgcolorOne = !$useBgcolorOne;
209 if (++$countRows == ceil(count($serverStatus) / 3) || $countRows == ceil(count($serverStatus) * 2 / 3)) {
210 $useBgcolorOne = TRUE;
212 </table>
213 </td>
214 <td valign="top">
215 <table border="0">
216 <tr>
217 <th>&nbsp;<?php echo $strVar; ?>&nbsp;</th>
218 <th>&nbsp;<?php echo $strValue; ?>&nbsp;</th>
219 </tr>
220 <?php
223 unset($useBgcolorOne);
225 </table>
226 </td>
227 </tr>
228 </table>
229 </li>
230 <?php
233 </ul>
236 <?php
239 * Sends the footer
241 require('./footer.inc.php3');