Project

General

Profile

Download (10.9 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 d88c6a9f Scott Ullrich
$pgtitle = array("Status","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 ebdbdbc2 gnhb
			<?=htmlspecialchars($ifname);?> interface (<?=htmlspecialchars($ifinfo['hwif']);?>)
80 0d7b21de sullrich
		</td>
81
	</tr>
82
	<tr>
83
		<td width="22%" class="vncellt">Status</td>
84
		<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
				<input type="button" name="<?php echo $ifdescr; ?>" value="Release" class="formbtns">
98
			<?php else: ?>
99
				<a href="status_interfaces.php?action=Renew&if=<?php echo $ifdescr; ?>">
100
				<input type="button" name="<?php echo $ifdescr; ?>" value="Renew" class="formbtns">
101
			<?php endif; ?>
102
			</a>
103
		</td>
104
	</tr>
105
	<?php endif; if ($ifinfo['pppoelink']): ?>
106
	<tr>
107
		<td width="22%" class="vncellt">PPPoE</td>
108
		<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
				<input type="button" name="<?php echo $ifdescr; ?>" value="Disconnect" class="formbtns">
113
			<?php else: ?>
114
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
115
				<input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns">
116
				<?php endif; ?>
117
			</a>
118
		</td>
119
	</tr>
120
	<?php  endif; if ($ifinfo['pptplink']): ?>
121
	<tr>
122
		<td width="22%" class="vncellt">PPTP</td>
123
		<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
				<input type="button" name="<?php echo $ifdescr; ?>" value="Disconnect" class="formbtns">
128
			<?php else: ?>
129
				<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
130
				<input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns">
131
			<?php endif; ?>
132
			</a>
133
		</td>
134
	</tr>
135
	<?php  endif; if ($ifinfo['ppplink']): ?>
136
	<tr>
137
		<td width="22%" class="vncellt">PPP</td>
138
		<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
				<input type="button" name="<?php echo $ifdescr; ?>" value="Disconnect" class="formbtns">
143
			<?php else: ?>
144 c90f2471 gnhb
				<?php if (!$ifinfo['nodevice']): ?>
145 9ebe7028 gnhb
					<a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
146
					<input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns">
147
				<?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 ed476f6f gnhb
		<td width="22%" class="vncellt">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
		<td width="22%" class="vncellt">MAC address</td>
162
		<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
		<td width="22%" class="vncellt">IP address</td>
171
		<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
		<td width="22%" class="vncellt">Subnet mask</td>
179
		<td width="78%" class="listr">
180
			<?=htmlspecialchars($ifinfo['subnet']);?>
181
		</td>
182
	</tr>
183
	<?php endif; ?><?php if ($ifinfo['gateway']): ?>
184
	<tr>
185
		<td width="22%" class="vncellt">Gateway</td>
186
		<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
	<td width="22%" class="vncellt">ISP DNS servers</td>
194
	<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
		<td width="22%" class="vncellt">Media</td>
206
		<td width="78%" class="listr">
207
			<?=htmlspecialchars($ifinfo['media']);?>
208
		</td>
209
	</tr>
210
<?php endif; ?><?php if ($ifinfo['channel']): ?>
211
	<tr>
212
		<td width="22%" class="vncellt">Channel</td>
213
		<td width="78%" class="listr">
214
			<?=htmlspecialchars($ifinfo['channel']);?>
215
		</td>
216
	</tr>
217
<?php endif; ?><?php if ($ifinfo['ssid']): ?>
218
	<tr>
219
		<td width="22%" class="vncellt">SSID</td>
220
		<td width="78%" class="listr">
221
			<?=htmlspecialchars($ifinfo['ssid']);?>
222
		</td>
223
	</tr>
224
<?php endif; ?><?php if ($ifinfo['bssid']): ?>
225
	<tr>
226
		<td width="22%" class="vncellt">BSSID</td>
227
		<td width="78%" class="listr">
228
			<?=htmlspecialchars($ifinfo['bssid']);?>
229
		</td>
230
	</tr>
231
<?php endif; ?><?php if ($ifinfo['rate']): ?>
232
	<tr>
233
		<td width="22%" class="vncellt">Rate</td>
234
		<td width="78%" class="listr">
235
			<?=htmlspecialchars($ifinfo['rate']);?>
236
		</td>
237
	</tr>
238
<?php endif; ?><?php if ($ifinfo['rssi']): ?>
239
	<tr>
240
		<td width="22%" class="vncellt">RSSI</td>
241
		<td width="78%" class="listr">
242
			<?=htmlspecialchars($ifinfo['rssi']);?>
243
		</td>
244
	</tr>
245
<?php endif; ?>
246
	<tr>
247
		<td width="22%" class="vncellt">In/out packets</td>
248
		<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
		<td width="22%" class="vncellt">In/out packets (pass)</td>
257
		<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
		<td width="22%" class="vncellt">In/out packets (block)</td>
266
		<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
		<td width="22%" class="vncellt">In/out errors</td>
276
		<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
		<td width="22%" class="vncellt">Collisions</td>
284
		<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
		<td width="22%" class="vncellt">Bridge (<?=$ifinfo['bridgeint']?>)</td>
293
		<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
		<td width="22%" class="vncellt">Interrupts/Second</td>
315
		<td width="78%" class="listr">
316
			<?php
317
				echo $interrupt_total . " total";
318
				echo "<br/>";
319
				echo $interrupt_sec . " rate";
320
			?>
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 c26e2cf0 Scott Ullrich
</strong>Using dial-on-demand will bring the connection up again if any packet
331 8cccee1c Scott Ullrich
triggers it. To substantiate this point: disconnecting manually
332 c26e2cf0 Scott Ullrich
will <strong>not</strong> prevent dial-on-demand from making connections
333 f559eaf6 Scott Ullrich
to the outside! Don't use dial-on-demand if you want to make sure that the line
334 8c3e8725 Scott Ullrich
is kept disconnected.
335 71d9cd3d Scott Ullrich
336 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>