Project

General

Profile

Download (5.52 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2

    
3
/* $Id$ */
4
/*
5
	diag_sockets.php
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	Copyright (C) 2012
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	notice, this list of conditions and the following disclaimer in the
18
	documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30

    
31
*/
32

    
33
/*
34
	pfSense_BUILDER_BINARIES:	/usr/bin/sockstat	
35
*/
36
##|+PRIV
37
##|*IDENT=page-diagnostics-sockets
38
##|*NAME=Diagnostics: Sockets page
39
##|*DESCR=Allow access to the 'Diagnostics: Sockets' page.
40
##|*MATCH=diag_sockets.php*
41
##|-PRIV
42

    
43
include('guiconfig.inc');
44

    
45
$pgtitle = array(gettext("Diagnostics"),gettext("Sockets"));
46

    
47
include('head.inc');
48

    
49
?>
50
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
51
<?php include("fbegin.inc");
52

    
53
$showAll = isset($_GET['showAll']);
54
$showAllText = $showAll ? "Show only listening sockets" : "Show all socket connections";
55
$showAllOption = $showAll ? "" : "?showAll";
56

    
57
?>
58
<div id="mainarea">
59
<table class="tabcont" width="100%" summary="diag sockets">
60
<tr>
61
<td>Information about listening sockets for both <a href="#IPv4">IPv4</a> and <a href="#IPv6">IPv6</a>.</td>
62
</tr>
63
<tr>
64
<td>For explanation about the meaning of the information listed for each socket click <a href="#about">here</a>.</td>
65
</tr>
66
<tr>
67
<td><input type="button" value="<?=$showAllText?>" onclick="window.location.href='diag_sockets.php<?=$showAllOption?>'"/>To show information about both listening and connected sockets click this.</td>
68
</tr>
69
</table>
70

    
71
<?php
72
	if (isset($_GET['showAll']))
73
	{
74
		$internet4 = shell_exec('sockstat -4');
75
		$internet6 = shell_exec('sockstat -6');
76
	} else {
77
		$internet4 = shell_exec('sockstat -4lL');
78
		$internet6 = shell_exec('sockstat -6lL');
79
	}
80
	foreach (array(&$internet4, &$internet6) as $tabindex => $table) {
81
		$elements = ($tabindex == 0 ? 7 : 7);
82
		$name = ($tabindex == 0 ? 'IPv4' : 'IPv6');
83
?>
84
<a name="<?=$name;?>"></a>
85
<table style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab">
86
<tr><td class="listtopic" colspan="<?=$elements?>"><strong><?=$name;?></strong></td></tr>
87
<tr><td>
88
<table class="tabcont sortable" id="sortabletable" width="100%" cellspacing="0" cellpadding="6" border="0" summary="results">
89
<?php
90
		foreach (explode("\n", $table) as $i => $line) {
91
			if ($i == 0)
92
				$class = 'listhdrr';
93
			else
94
				$class = 'listlr';
95

    
96
			if (trim($line) == "")
97
				continue;
98
			print("<tr id=\"$name$i\">\n");
99
			$j = 0;
100
			foreach (explode(' ', $line) as $entry) {
101
				if ($entry == '' || $entry == "ADDRESS") continue;
102
				if ($i == 0)
103
					print("<th class=\"$class\">$entry</th>\n");
104
				else		
105
					print("<td class=\"$class\">$entry</td>\n");
106
				if ($i > 0)
107
					$class = 'listr';
108
				$j++;
109
			}
110
			print("</tr>\n");			
111
		}?>
112
</table>
113
</td></tr></table>
114
<?php
115
	} 
116
?>
117

    
118
<br />
119
<a name="about"></a>
120
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="info">
121
	<tr><td colspan="2" class="listtopic" >Socket information explanation</td></tr>
122
<tr><td colspan="2" class="listhdrr">
123
This page show the output for the commands: "sockstat -4lL" and "sockstat -6lL".<br />
124
Or in case of showing all sockets the output for: "sockstat -4" and "sockstat -6".<br />
125
<br />
126
The information listed for each socket is:</td></tr>
127
	<tr><td class="listlr">USER	      </td><td class="listr">The user who owns the socket.</td></tr>
128
	<tr><td class="listlr">COMMAND	      </td><td class="listr">The command which holds the socket.</td></tr>
129
	<tr><td class="listlr">PID	      </td><td class="listr">The process ID of the command which holds the socket.</td></tr>
130
	<tr><td class="listlr">FD 	      </td><td class="listr">The file descriptor number of the socket.</td></tr>
131
	<tr><td class="listlr">PROTO	      </td><td class="listr">The transport protocol associated with the socket for Internet sockets, or the type of socket (stream or data-gram) for UNIX sockets.</td></tr>
132
	<tr><td class="listlr">ADDRESS	      </td><td class="listr">(UNIX sockets only) For bound sockets, this is the file-name of the socket.  For other sockets, it is the name, PID and file descriptor number of the peer, or ``(none)'' if the socket is neither bound nor connected.</td></tr>
133
	<tr><td class="listlr">LOCAL ADDRESS    </td><td class="listr">(Internet sockets only) The address the local end of the socket is bound to (see getsockname(2)).</td></tr>
134
	<tr><td class="listlr">FOREIGN ADDRESS  </td><td class="listr">(Internet sockets only) The address the foreign end of the socket is bound to (see getpeername(2)).</td></tr>
135
</table>
136
</div>
137
<?php
138
include('fend.inc');
139
?>
140
</body>
141
</html>
(47-47/252)