Project

General

Profile

Download (11.6 KB) Statistics
| Branch: | Tag: | Revision:
1 8cccee1c Scott Ullrich
<?php
2 2bdf4a03 Scott Ullrich
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	status_interfaces.php
5 0d7b21de sullrich
	part of pfSense
6
	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>.
7 8c3e8725 Scott Ullrich
	All rights reserved.
8 8cccee1c Scott Ullrich
9 8c3e8725 Scott Ullrich
	originally part of m0n0wall (http://m0n0.ch/wall)
10 c26e2cf0 Scott Ullrich
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
11 5b237745 Scott Ullrich
	All rights reserved.
12 8cccee1c Scott Ullrich
13 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15 8cccee1c Scott Ullrich
16 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18 8cccee1c Scott Ullrich
19 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22 8cccee1c Scott Ullrich
23 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34 1d333258 Scott Ullrich
/*	
35
	pfSense_MODULE:	interfaces
36
*/
37 5b237745 Scott Ullrich
38 6b07c15a Matthew Grooms
##|+PRIV
39
##|*IDENT=page-status-interfaces
40
##|*NAME=Status: Interfaces page
41
##|*DESCR=Allow access to the 'Status: Interfaces' page.
42
##|*MATCH=status_interfaces.php*
43
##|-PRIV
44
45 51caa77a Scott Ullrich
require_once("guiconfig.inc");
46 5b237745 Scott Ullrich
47 07c17911 Ermal Luçi
if ($_GET['if']) {
48
	$interface = $_GET['if'];
49
	if ($_GET['action'] == "Disconnect" || $_GET['action'] == "Release") {
50 80bf3f4a Ermal Luçi
		interface_bring_down($interface);
51 07c17911 Ermal Luçi
	} else if ($_GET['action'] == "Connect" || $_GET['action'] == "Renew") {
52 80bf3f4a Ermal Luçi
		interface_configure($interface); 
53 c26e2cf0 Scott Ullrich
	}
54 56e1d16e Ermal Lu?i
	header("Location: status_interfaces.php");
55
	exit;
56 c26e2cf0 Scott Ullrich
}
57
58 ee644822 Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Interfaces"));
59 4df96eff Scott Ullrich
include("head.inc");
60
61 5b237745 Scott Ullrich
?>
62 8cccee1c Scott Ullrich
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
65 0d7b21de sullrich
<table width="100%" border="0" cellspacing="0" cellpadding="0">
66
<?php 
67
	$i = 0; 
68
	$ifdescrs = get_configured_interface_with_descr(false, true);
69
	foreach ($ifdescrs as $ifdescr => $ifname):
70
	$ifinfo = get_interface_info($ifdescr);
71
?>
72
<?php if ($i): ?>
73
	<tr>
74
		<td colspan="8" class="list" height="12"></td>
75
	</tr>
76
<?php endif; ?>
77
	<tr>
78
		<td colspan="2" class="listtopic">
79 ee644822 Carlos Eduardo Ramos
			<?=htmlspecialchars($ifname);?> <?=gettext("interface"); ?> (<?=htmlspecialchars($ifinfo['hwif']);?>)
80 0d7b21de sullrich
		</td>
81
	</tr>
82
	<tr>
83 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("Status"); ?></td>
84 0d7b21de sullrich
		<td width="78%" class="listr">
85
			<?=htmlspecialchars($ifinfo['status']);?>
86
		</td>
87
	</tr>
88
	<?php if ($ifinfo['dhcplink']): ?>
89
	<tr>
90
		<td width="22%" class="vncellt">
91
			DHCP
92
		</td>
93
		<td width="78%" class="listr">
94
			<?=htmlspecialchars($ifinfo['dhcplink']);?>&nbsp;&nbsp;
95
			<?php if ($ifinfo['dhcplink'] == "up"): ?>
96
				<a href="status_interfaces.php?action=Release&if=<?php echo $ifdescr; ?>">
97 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Release");?>" class="formbtns">
98 0d7b21de sullrich
			<?php else: ?>
99
				<a href="status_interfaces.php?action=Renew&if=<?php echo $ifdescr; ?>">
100 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Renew");?>" class="formbtns">
101 0d7b21de sullrich
			<?php endif; ?>
102
			</a>
103
		</td>
104
	</tr>
105
	<?php endif; if ($ifinfo['pppoelink']): ?>
106
	<tr>
107 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPPoE"); ?></td>
108 0d7b21de sullrich
		<td width="78%" class="listr">
109
			<?=htmlspecialchars($ifinfo['pppoelink']);?>&nbsp;&nbsp;
110
			<?php if ($ifinfo['pppoelink'] == "up"): ?>
111
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
112 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
113 0d7b21de sullrich
			<?php else: ?>
114
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
115 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
116 0d7b21de sullrich
				<?php endif; ?>
117
			</a>
118
		</td>
119
	</tr>
120
	<?php  endif; if ($ifinfo['pptplink']): ?>
121
	<tr>
122 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPTP"); ?></td>
123 0d7b21de sullrich
		<td width="78%" class="listr">
124
			<?=htmlspecialchars($ifinfo['pptplink']);?>&nbsp;&nbsp;
125
			<?php if ($ifinfo['pptplink'] == "up"): ?>
126
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
127 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
128 0d7b21de sullrich
			<?php else: ?>
129
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
130 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
131 0d7b21de sullrich
			<?php endif; ?>
132
			</a>
133
		</td>
134
	</tr>
135
	<?php  endif; if ($ifinfo['ppplink']): ?>
136
	<tr>
137 ee644822 Carlos Eduardo Ramos
		<td width="22%" class="vncellt"><?=gettext("PPP"); ?></td>
138 0d7b21de sullrich
		<td width="78%" class="listr">
139 c90f2471 gnhb
			<?=htmlspecialchars($ifinfo['pppinfo']);?>
140
			<?php if ($ifinfo['ppplink'] == "up"): ?>
141 0d7b21de sullrich
				<a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
142 c8927bfb Rafael Lucas
				<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Disconnect");?>" class="formbtns">
143 0d7b21de sullrich
			<?php else: ?>
144 c90f2471 gnhb
				<?php if (!$ifinfo['nodevice']): ?>
145 9ebe7028 gnhb
					<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
146 c8927bfb Rafael Lucas
					<input type="button" name="<?php echo $ifdescr; ?>" value="<?=gettext("Connect");?>" class="formbtns">
147 9ebe7028 gnhb
				<?php endif; ?>
148 0d7b21de sullrich
			<?php endif; ?>
149
			</a>
150
		</td>
151
	</tr>
152 8eb2f33a Scott Ullrich
	<?php  endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?>
153
	<tr>
154 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Uptime ");?><?php if ($ifinfo['ppp_uptime_accumulated']) echo "(historical)"; ?></td>
155 59db783a gnhb
		<td width="78%" class="listr">
156
			<?=htmlspecialchars($ifinfo['ppp_uptime']);?> <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>
157
		</td>
158 8eb2f33a Scott Ullrich
        </tr>
159 0d7b21de sullrich
	<?php  endif; if ($ifinfo['macaddr']): ?>
160
	<tr>
161 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("MAC address");?></td>
162 0d7b21de sullrich
		<td width="78%" class="listr">
163
			<?=htmlspecialchars($ifinfo['macaddr']);?>
164
		</td>
165
	</tr>
166
	<?php endif; if ($ifinfo['status'] != "down"): ?>
167
	<?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
168
	<?php if ($ifinfo['ipaddr']): ?>
169
	<tr>
170 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("IP address");?></td>
171 0d7b21de sullrich
		<td width="78%" class="listr">
172
			<?=htmlspecialchars($ifinfo['ipaddr']);?>
173
			&nbsp; 
174
		</td>
175
	</tr>
176
	<?php endif; ?><?php if ($ifinfo['subnet']): ?>
177
	<tr>
178 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Subnet mask");?></td>
179 0d7b21de sullrich
		<td width="78%" class="listr">
180
			<?=htmlspecialchars($ifinfo['subnet']);?>
181
		</td>
182
	</tr>
183
	<?php endif; ?><?php if ($ifinfo['gateway']): ?>
184
	<tr>
185 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Gateway");?></td>
186 0d7b21de sullrich
		<td width="78%" class="listr">
187 dde9a4fc Seth Mos
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
188
			<?=htmlspecialchars($ifinfo['gateway']);?>
189 0d7b21de sullrich
		</td>
190
	</tr>
191
	<?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
192
	<tr>
193 c8927bfb Rafael Lucas
	<td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td>
194 0d7b21de sullrich
	<td width="78%" class="listr">
195 6205a304 Scott Ullrich
		<?php
196
			$dns_servers = get_dns_servers();
197
			foreach($dns_servers as $dns) {
198
				echo "{$dns}<br>";
199 f559eaf6 Scott Ullrich
			}
200 6205a304 Scott Ullrich
		?>
201
		</td>
202 0d7b21de sullrich
	</tr>
203
	<?php endif; endif; if ($ifinfo['media']): ?>
204
	<tr>
205 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Media");?></td>
206 0d7b21de sullrich
		<td width="78%" class="listr">
207
			<?=htmlspecialchars($ifinfo['media']);?>
208
		</td>
209
	</tr>
210
<?php endif; ?><?php if ($ifinfo['channel']): ?>
211
	<tr>
212 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Channel");?></td>
213 0d7b21de sullrich
		<td width="78%" class="listr">
214
			<?=htmlspecialchars($ifinfo['channel']);?>
215
		</td>
216
	</tr>
217
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
218
	<tr>
219 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("SSID");?></td>
220 0d7b21de sullrich
		<td width="78%" class="listr">
221
			<?=htmlspecialchars($ifinfo['ssid']);?>
222
		</td>
223
	</tr>
224
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
225
	<tr>
226 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("BSSID");?></td>
227 0d7b21de sullrich
		<td width="78%" class="listr">
228
			<?=htmlspecialchars($ifinfo['bssid']);?>
229
		</td>
230
	</tr>
231
<?php endif; ?><?php if ($ifinfo['rate']): ?>
232
	<tr>
233 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Rate");?></td>
234 0d7b21de sullrich
		<td width="78%" class="listr">
235
			<?=htmlspecialchars($ifinfo['rate']);?>
236
		</td>
237
	</tr>
238
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
239
	<tr>
240 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("RSSI");?></td>
241 0d7b21de sullrich
		<td width="78%" class="listr">
242
			<?=htmlspecialchars($ifinfo['rssi']);?>
243
		</td>
244
	</tr>
245
<?php endif; ?>
246
	<tr>
247 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets");?></td>
248 0d7b21de sullrich
		<td width="78%" class="listr">
249
		<?php
250
			echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
251
			echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
252
		?>
253
		</td>
254
	</tr>
255
	<tr>
256 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td>
257 0d7b21de sullrich
		<td width="78%" class="listr">
258
			<?php
259
				echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
260
				echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
261
			?>
262
		</td>
263
	</tr>
264
	<tr>
265 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td>
266 0d7b21de sullrich
		<td width="78%" class="listr">
267
			<?php
268
				echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
269
				echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
270
			?>
271
		</td>
272
	</tr>
273
<?php if (isset($ifinfo['inerrs'])): ?>
274
	<tr>
275 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("In/out errors");?></td>
276 0d7b21de sullrich
		<td width="78%" class="listr">
277
			<?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
278
		</td>
279
	</tr>
280
<?php endif; ?>
281
<?php if (isset($ifinfo['collisions'])): ?>
282
	<tr>
283 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Collisions");?></td>
284 0d7b21de sullrich
		<td width="78%" class="listr">
285
			<?=htmlspecialchars($ifinfo['collisions']);?>
286
		</td>
287
	</tr>
288
<?php endif; ?>
289
<?php endif; ?>
290
<?php if ($ifinfo['bridge']): ?>
291
	<tr>
292 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td>
293 0d7b21de sullrich
		<td width="78%" class="listr">
294
			<?=$ifinfo['bridge'];?>
295
		</td>
296
	</tr>
297
<?php endif; ?>
298
<?php if(file_exists("/usr/bin/vmstat")): ?>
299
<?php
300
	$real_interface = "";
301
	$interrupt_total = "";
302
	$interrupt_sec = "";
303
	$real_interface = $ifinfo['hwif'];
304
	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
305
	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
306
	if(strstr($interrupt_total, "hci")) {
307
		$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
308
		$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
309
	}
310
	unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
311
?>
312
<?php if($interrupt_total): ?>
313
	<tr>
314 c8927bfb Rafael Lucas
		<td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td>
315 0d7b21de sullrich
		<td width="78%" class="listr">
316
			<?php
317 ee644822 Carlos Eduardo Ramos
				echo $interrupt_total . " " . gettext("total");
318 0d7b21de sullrich
				echo "<br/>";
319 ee644822 Carlos Eduardo Ramos
				echo $interrupt_sec . " " . gettext("rate");
320 0d7b21de sullrich
			?>
321
		</td>
322
	</tr>
323
<?php endif; ?>
324
<?php endif; ?>
325
<?php $i++; endforeach; ?>
326
</table>
327 29ed06c9 Scott Ullrich
328 d290167c Seth Mos
<br/>
329 0d7b21de sullrich
330 c8927bfb Rafael Lucas
</strong><?php printf(gettext("Using dial-on-demand will bring the connection up again if any packet ".
331
"triggers it. To substantiate this point: disconnecting manually ".
332
"will %snot%s prevent dial-on-demand from making connections ".
333
"to the outside! Don't use dial-on-demand if you want to make sure that the line ".
334
"is kept disconnected."),'<strong>','</strong>')?>
335 71d9cd3d Scott Ullrich
336 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>