Project

General

Profile

Download (11.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_interfaces.php
5
        part of pfSense
6
	Copyright (C) 2005 Scott Ullrich <sullrich@gmail.com>.
7
	All rights reserved.
8

    
9
	originally part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12

    
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15

    
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18

    
19
	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

    
23
	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
/*	
35
	pfSense_MODULE:	interfaces
36
*/
37

    
38
##|+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
require_once("guiconfig.inc");
46

    
47
if ($_GET['if']) {
48
	$interface = $_GET['if'];
49
	if ($_GET['action'] == "Disconnect" || $_GET['action'] == "Release") {
50
		interface_bring_down($interface);
51
	} else if ($_GET['action'] == "Connect" || $_GET['action'] == "Renew") {
52
		interface_configure($interface); 
53
	}
54
	header("Location: status_interfaces.php");
55
	exit;
56
}
57

    
58
$pgtitle = array("Status","Interfaces");
59
include("head.inc");
60

    
61
?>
62

    
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
<?php include("fbegin.inc"); ?>
65
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
66
              <?php $i = 0; $ifdescrs = get_configured_interface_with_descr(false, true);
67
		foreach ($ifdescrs as $ifdescr => $ifname):
68
			$ifinfo = get_interface_info($ifdescr);
69
		?>
70
              <?php if ($i): ?>
71
              <tr>
72
			<td colspan="8" class="list" height="12"></td>
73
			</tr>
74
		<?php endif; ?>
75
              <tr>
76
                <td colspan="2" class="listtopic">
77
                  <?=htmlspecialchars($ifname);?>
78
				  interface
79
				  (<?=($ifinfo['hwif']);?>)
80
				</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><?php if ($ifinfo['dhcplink']): ?>
88
		  <tr>
89
			<td width="22%" class="vncellt">DHCP</td>
90
			<td width="78%" class="listr">
91
			  <?=htmlspecialchars($ifinfo['dhcplink']);?>&nbsp;&nbsp;
92
			  <?php if ($ifinfo['dhcplink'] == "up"): ?>
93
			  <a href="status_interfaces.php?action=Release&if=<?php echo $ifdescr; ?>">
94
			  <input type="button" name="<?php echo $ifdescr; ?>" value="Release" class="formbtns">
95
			  <?php else: ?>
96
			  <a href="status_interfaces.php?action=Renew&if=<?php echo $ifdescr; ?>">
97
			  <input type="button" name="<?php echo $ifdescr; ?>" value="Renew" class="formbtns">
98
			  <?php endif; ?>
99
			  </a>
100
			</td>
101
		  </tr><?php endif; if ($ifinfo['pppoelink']): ?>
102
              <tr>
103
                <td width="22%" class="vncellt">PPPoE</td>
104
                <td width="78%" class="listr">
105
                  <?=htmlspecialchars($ifinfo['pppoelink']);?>&nbsp;&nbsp;
106
			  <?php if ($ifinfo['pppoelink'] == "up"): ?>
107
			  <a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
108
			  <input type="button" name="<?php echo $ifdescr; ?>" value="Disconnect" class="formbtns">
109
			  <?php else: ?>
110
			  <a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
111
			  <input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns">
112
			  <?php endif; ?>
113
			  </a>
114
                </td>
115
              </tr><?php  endif; if ($ifinfo['pptplink']): ?>
116
              <tr>
117
                <td width="22%" class="vncellt">PPTP</td>
118
                <td width="78%" class="listr">
119
                  <?=htmlspecialchars($ifinfo['pptplink']);?>&nbsp;&nbsp;
120
			  <?php if ($ifinfo['pptplink'] == "up"): ?>
121
			  <a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>">
122
			  <input type="button" name="<?php echo $ifdescr; ?>" value="Disconnect" class="formbtns">
123
			  <?php else: ?>
124
			  <a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>">
125
			  <input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns">
126
			  <?php endif; ?>
127
			  </a>
128
                </td>
129
              </tr><?php  endif; if ($ifinfo['macaddr']): ?>
130
              <tr>
131
                <td width="22%" class="vncellt">MAC address</td>
132
                <td width="78%" class="listr">
133
                  <?=htmlspecialchars($ifinfo['macaddr']);?>
134
                </td>
135
              </tr>
136
		<?php endif; if ($ifinfo['status'] != "down"): ?>
137
			  <?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?>
138
			  <?php if ($ifinfo['ipaddr']): ?>
139
              <tr>
140
                <td width="22%" class="vncellt">IP address</td>
141
                <td width="78%" class="listr">
142
                  <?=htmlspecialchars($ifinfo['ipaddr']);?>
143
                  &nbsp; </td>
144
              </tr><?php endif; ?><?php if ($ifinfo['subnet']): ?>
145
              <tr>
146
                <td width="22%" class="vncellt">Subnet mask</td>
147
                <td width="78%" class="listr">
148
                  <?=htmlspecialchars($ifinfo['subnet']);?>
149
                </td>
150
              </tr><?php endif; ?><?php if ($ifinfo['gateway']): ?>
151
              <tr>
152
                <td width="22%" class="vncellt">Gateway</td>
153
                <td width="78%" class="listr">
154
			<?=htmlspecialchars($config['interfaces'][$ifdescr]['gateway']);?>
155
			<?=htmlspecialchars($ifinfo['gateway']);?>
156
			<?php /* FIXME: possibly show gateway status and if it is the default route */ ?>
157
                </td>
158
              </tr><?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?>
159
                <td width="22%" class="vncellt">ISP DNS servers</td>
160
                <td width="78%" class="listr">
161
		<?php
162
			$dns_servers = get_dns_servers();
163
			foreach($dns_servers as $dns) {
164
				echo "{$dns}<br>";
165
			}
166
		?>
167
		</td>
168
			  <?php endif; endif; if ($ifinfo['media']): ?>
169
              <tr>
170
                <td width="22%" class="vncellt">Media</td>
171
                <td width="78%" class="listr">
172
                  <?=htmlspecialchars($ifinfo['media']);?>
173
                </td>
174
              </tr><?php endif; ?><?php if ($ifinfo['channel']): ?>
175
              <tr>
176
                <td width="22%" class="vncellt">Channel</td>
177
                <td width="78%" class="listr">
178
                  <?=htmlspecialchars($ifinfo['channel']);?>
179
                </td>
180
              </tr><?php endif; ?><?php if ($ifinfo['ssid']): ?>
181
              <tr>
182
                <td width="22%" class="vncellt">SSID</td>
183
                <td width="78%" class="listr">
184
                  <?=htmlspecialchars($ifinfo['ssid']);?>
185
                </td>
186
              </tr><?php endif; ?><?php if ($ifinfo['bssid']): ?>
187
              <tr>
188
                <td width="22%" class="vncellt">BSSID</td>
189
                <td width="78%" class="listr">
190
                  <?=htmlspecialchars($ifinfo['bssid']);?>
191
                </td>
192
              </tr><?php endif; ?><?php if ($ifinfo['rate']): ?>
193
              <tr>
194
                <td width="22%" class="vncellt">Rate</td>
195
                <td width="78%" class="listr">
196
                  <?=htmlspecialchars($ifinfo['rate']);?>
197
                </td>
198
              </tr><?php endif; ?><?php if ($ifinfo['rssi']): ?>
199
              <tr>
200
                <td width="22%" class="vncellt">RSSI</td>
201
                <td width="78%" class="listr">
202
                  <?=htmlspecialchars($ifinfo['rssi']);?>
203
                </td>
204
              </tr><?php endif; ?>
205
              <tr>
206
                <td width="22%" class="vncellt">In/out packets</td>
207
                <td width="78%" class="listr">
208
				<?php
209
					echo htmlspecialchars($ifinfo['inpkts'] . "/" . $ifinfo['outpkts'] . " (");
210
					echo htmlspecialchars(format_bytes($ifinfo['inbytes']) . "/" . format_bytes($ifinfo['outbytes']) . ")");
211
				?>
212
                </td>
213
              </tr>
214
              <tr>
215
                <td width="22%" class="vncellt">In/out packets (pass)</td>
216
                <td width="78%" class="listr">
217
				<?php
218
					echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " (");
219
					echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")");
220
				?>
221
                </td>
222
              </tr>
223
              <tr>
224
                <td width="22%" class="vncellt">In/out packets (block)</td>
225
                <td width="78%" class="listr">
226
				<?php
227
					echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " (");
228
					echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")");
229
				?>
230
                </td>
231
              </tr><?php if (isset($ifinfo['inerrs'])): ?>
232

    
233
              <tr>
234
                <td width="22%" class="vncellt">In/out errors</td>
235
                <td width="78%" class="listr">
236
                  <?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?>
237
                </td>
238
              </tr><?php endif; ?><?php if (isset($ifinfo['collisions'])): ?>
239
              <tr>
240
                <td width="22%" class="vncellt">Collisions</td>
241
                <td width="78%" class="listr">
242
                  <?=htmlspecialchars($ifinfo['collisions']);?>
243
                </td>
244
              </tr><?php endif; ?>
245
	      <?php endif; ?>
246

    
247
		  <?php if ($ifinfo['bridge']): ?>
248
		  <tr>
249
		    <td width="22%" class="vncellt">Bridge (<?=$ifinfo['bridgeint']?>)</td>
250
		    <td width="78%" class="listr">
251
		      <?=$ifinfo['bridge'];?>
252
		    </td>
253
		  </tr>
254
		  <?php endif; ?>
255

    
256
	<?php if(file_exists("/usr/bin/vmstat")): ?>
257
	<?php
258
			$real_interface = "";
259
			$interrupt_total = "";
260
			$interrupt_sec = "";
261
			$real_interface = $ifinfo['hwif'];
262
		/* XXX for virtual interfaces this are not the most accurate stats! */
263
          	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`;
264
          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
265
          	if(strstr($interrupt_total, "hci")) {
266
    	      	$interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`;
267
	          	$interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`;          	
268
          	}
269
			unset($interrupt_total); // XXX: FIX ME!  Need a regex and parse correct data 100% of the time.
270
	?>
271
	<?php if($interrupt_total): ?>
272
     <tr>
273
        <td width="22%" class="vncellt">Interrupts/Second</td>
274
        <td width="78%" class="listr">
275
          <?php
276

    
277
          	echo $interrupt_total . " total";
278
          	echo "<br/>";
279
          	echo $interrupt_sec . " rate";
280
          ?>
281
        </td>
282
      </tr>
283
     <?php endif; ?>
284
	<?php endif; ?>
285
	
286
              <?php $i++; endforeach; ?>
287
            </table>
288
<br/>
289
</strong>Using dial-on-demand will bring the connection up again if any packet
290
triggers it. To substantiate this point: disconnecting manually
291
will <strong>not</strong> prevent dial-on-demand from making connections
292
to the outside! Don't use dial-on-demand if you want to make sure that the line
293
is kept disconnected.
294

    
295

    
296
<?php include("fend.inc"); ?>
(154-154/214)