Revision b9a5448f
Added by Stephen Beaver over 9 years ago
src/usr/local/www/diag_sockets.php | ||
---|---|---|
3 | 3 |
diag_sockets.php |
4 | 4 |
*/ |
5 | 5 |
/* ==================================================================== |
6 |
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
|
6 |
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
|
7 | 7 |
* |
8 |
* Redistribution and use in source and binary forms, with or without modification,
|
|
9 |
* are permitted provided that the following conditions are met:
|
|
8 |
* Redistribution and use in source and binary forms, with or without modification,
|
|
9 |
* are permitted provided that the following conditions are met:
|
|
10 | 10 |
* |
11 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
12 |
* this list of conditions and the following disclaimer.
|
|
11 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
12 |
* this list of conditions and the following disclaimer.
|
|
13 | 13 |
* |
14 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
15 |
* notice, this list of conditions and the following disclaimer in
|
|
16 |
* the documentation and/or other materials provided with the
|
|
17 |
* distribution.
|
|
14 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
15 |
* notice, this list of conditions and the following disclaimer in
|
|
16 |
* the documentation and/or other materials provided with the
|
|
17 |
* distribution.
|
|
18 | 18 |
* |
19 |
* 3. All advertising materials mentioning features or use of this software
|
|
20 |
* must display the following acknowledgment:
|
|
21 |
* "This product includes software developed by the pfSense Project
|
|
22 |
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
|
19 |
* 3. All advertising materials mentioning features or use of this software
|
|
20 |
* must display the following acknowledgment:
|
|
21 |
* "This product includes software developed by the pfSense Project
|
|
22 |
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
|
23 | 23 |
* |
24 |
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
|
25 |
* endorse or promote products derived from this software without
|
|
26 |
* prior written permission. For written permission, please contact
|
|
27 |
* coreteam@pfsense.org.
|
|
24 |
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
|
25 |
* endorse or promote products derived from this software without
|
|
26 |
* prior written permission. For written permission, please contact
|
|
27 |
* coreteam@pfsense.org.
|
|
28 | 28 |
* |
29 |
* 5. Products derived from this software may not be called "pfSense"
|
|
30 |
* nor may "pfSense" appear in their names without prior written
|
|
31 |
* permission of the Electric Sheep Fencing, LLC.
|
|
29 |
* 5. Products derived from this software may not be called "pfSense"
|
|
30 |
* nor may "pfSense" appear in their names without prior written
|
|
31 |
* permission of the Electric Sheep Fencing, LLC.
|
|
32 | 32 |
* |
33 |
* 6. Redistributions of any form whatsoever must retain the following
|
|
34 |
* acknowledgment:
|
|
33 |
* 6. Redistributions of any form whatsoever must retain the following
|
|
34 |
* acknowledgment:
|
|
35 | 35 |
* |
36 |
* "This product includes software developed by the pfSense Project
|
|
37 |
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
|
36 |
* "This product includes software developed by the pfSense Project
|
|
37 |
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
|
38 | 38 |
* |
39 |
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
|
40 |
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
41 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
42 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
|
43 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
44 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
45 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
46 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
47 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
48 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
49 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
50 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
39 |
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
|
40 |
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
41 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
42 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
|
43 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
44 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
45 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
46 |
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
47 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
48 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
49 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
50 |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
51 | 51 |
* |
52 |
* ====================================================================
|
|
52 |
* ====================================================================
|
|
53 | 53 |
* |
54 | 54 |
*/ |
55 | 55 |
|
... | ... | |
69 | 69 |
|
70 | 70 |
include('head.inc'); |
71 | 71 |
|
72 |
?> |
|
73 |
|
|
74 |
<?php include("fbegin.inc"); |
|
75 |
|
|
76 | 72 |
$showAll = isset($_GET['showAll']); |
77 | 73 |
$showAllText = $showAll ? "Show only listening sockets" : "Show all socket connections"; |
78 | 74 |
$showAllOption = $showAll ? "" : "?showAll"; |
79 | 75 |
|
80 | 76 |
?> |
81 |
|
|
82 |
<div class="panel panel-default"> |
|
83 |
<div class="panel-heading"><h2 class="panel-title">System socket information for both IPv4 and IPv6</h2></div> |
|
84 |
<div class="panel-body"> |
|
85 |
|
|
86 |
(Click <a href="#about">here </a>for explanation of the information listed for each socket) <br /><br /> |
|
87 |
<input class="btn btn-info btn-xs" type="button" value="<?=$showAllText?>" onclick="window.location.href='diag_sockets.php<?=$showAllOption?>'"/> |
|
88 |
|
|
77 |
<input class="btn btn-info btn-sm" type="button" value="<?=$showAllText?>" onclick="window.location.href='diag_sockets.php<?=$showAllOption?>'"/> |
|
78 |
<br /> |
|
79 |
<br /> |
|
89 | 80 |
|
90 | 81 |
<?php |
91 | 82 |
if (isset($_GET['showAll'])) { |
... | ... | |
95 | 86 |
$internet4 = shell_exec('sockstat -4l'); |
96 | 87 |
$internet6 = shell_exec('sockstat -6l'); |
97 | 88 |
} |
89 |
|
|
90 |
|
|
98 | 91 |
foreach (array(&$internet4, &$internet6) as $tabindex => $table) { |
99 | 92 |
$elements = ($tabindex == 0 ? 7 : 7); |
100 | 93 |
$name = ($tabindex == 0 ? 'IPv4' : 'IPv6'); |
101 | 94 |
?> |
95 |
<div class="panel panel-default"> |
|
96 |
<div class="panel-heading"><h2 class="panel-title"><?=$name?> system socket information</h2></div> |
|
97 |
<div class="panel-body"> |
|
102 | 98 |
<div class="table table-responsive"> |
103 | 99 |
<table class="table table-hover table-striped table-condensed"> |
104 | 100 |
<thead> |
105 |
<tr> |
|
106 |
<th> |
|
107 |
<?=$name?> |
|
108 |
</th> |
|
109 |
</tr> |
|
110 |
</thead> |
|
111 |
<tbody> |
|
112 |
|
|
113 | 101 |
<?php |
114 | 102 |
foreach (explode("\n", $table) as $i => $line) { |
115 |
if ($i == 0) |
|
116 |
$class = 'info'; |
|
117 |
else |
|
118 |
$class = ''; |
|
119 |
|
|
120 | 103 |
if (trim($line) == "") |
121 | 104 |
continue; |
122 | 105 |
|
123 |
print("<tr>\n"); |
|
124 | 106 |
$j = 0; |
125 | 107 |
foreach (explode(' ', $line) as $entry) { |
126 |
if ($entry == '' || $entry == "ADDRESS") continue; |
|
127 |
if ($i == 0) |
|
108 |
if ($entry == '' || $entry == "ADDRESS") |
|
109 |
continue; |
|
110 |
|
|
111 |
if ($i == 0) { |
|
128 | 112 |
print("<th class=\"$class\">$entry</th>\n"); |
129 |
else |
|
113 |
} |
|
114 |
else { |
|
130 | 115 |
print("<td class=\"$class\">$entry</td>\n"); |
116 |
} |
|
131 | 117 |
|
132 | 118 |
$j++; |
133 | 119 |
} |
134 | 120 |
print("</tr>\n"); |
121 |
if($i == 0) { |
|
122 |
print("</thead>\n"); |
|
123 |
print("<tbody>\n"); |
|
124 |
} |
|
135 | 125 |
} |
136 | 126 |
?> |
137 | 127 |
</tbody> |
138 | 128 |
</table> |
139 | 129 |
</div> |
130 |
</div> |
|
131 |
</div> |
|
140 | 132 |
<?php |
141 | 133 |
} |
142 | 134 |
?> |
143 |
</div> |
|
144 |
<a name="about"></a> |
|
145 |
<div class="alert alert-success" role="alert"> |
|
146 |
<div class="panel panel-default"> |
|
147 |
<div class="panel-heading"><h2 class="panel-title">Socket information - explanation</h2></div> |
|
148 |
<div class="panel-body"> |
|
149 |
This page shows the output for the commands: "sockstat -4lL" and "sockstat -6lL".<br /> |
|
150 |
Or in case of showing all sockets the output for: "sockstat -4" and "sockstat -6".<br /> |
|
151 |
<br /> |
|
152 |
The information listed for each socket is: |
|
153 |
<br /><br /> |
|
154 |
<dl class="dl-horizontal responsive"> |
|
155 |
<dt>USER</dt> <dd>The user who owns the socket.</dd> |
|
156 |
<dt>COMMAND</dt> <dd>The command which holds the socket.</dd> |
|
157 |
<dt>PID</dt> <dd>The process ID of the command which holds the socket.</dd> |
|
158 |
<dt>FD</dt> <dd>The file descriptor number of the socket.</dd> |
|
159 |
<dt>PROTO</dt> <dd>The transport protocol associated with the socket for Internet sockets, or the type of socket (stream or data-gram) for UNIX sockets.</dd> |
|
160 |
<dt>ADDRESS</dt> <dd>(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.</dd> |
|
161 |
<dt>LOCAL ADDRESS</dt> <dd>(Internet sockets only) The address the local end of the socket is bound to (see getsockname(2)).</dd> |
|
162 |
<dt>FOREIGN ADDRESS</dt><dd>(Internet sockets only) The address the foreign end of the socket is bound to (see getpeername(2)).</dd> |
|
163 |
</dl> |
|
164 |
</div> |
|
165 |
</div> |
|
166 |
</div> |
|
135 |
|
|
136 |
<div> |
|
137 |
<div id="infoblock"> |
|
138 |
<?php |
|
139 |
print_info_box(gettext('Socket information - explanation.') . '<br /><br />' . |
|
140 |
gettext('This page shows the output for the commands: "sockstat -4lL" and "sockstat -6lL".' . '<br />' . |
|
141 |
'Or in case of showing all sockets the output for: "sockstat -4" and "sockstat -6".' . '<br />' . '<br />' . |
|
142 |
'The information listed for each socket is:' . '<br /><br />' . |
|
143 |
' <dl class="dl-horizontal responsive">' . |
|
144 |
'<dt>USER</dt> <dd>The user who owns the socket.</dd>' . |
|
145 |
'<dt>COMMAND</dt> <dd>The command which holds the socket.</dd>' . |
|
146 |
'<dt>PID</dt> <dd>The process ID of the command which holds the socket.</dd>' . |
|
147 |
'<dt>FD</dt> <dd>The file descriptor number of the socket.</dd>' . |
|
148 |
'<dt>PROTO</dt> <dd>The transport protocol associated with the socket for Internet sockets, or the type of socket (stream or data-gram) for UNIX sockets.</dd>' . |
|
149 |
'<dt>ADDRESS</dt> <dd>(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.</dd>' . |
|
150 |
'<dt>LOCAL ADDRESS</dt> <dd>(Internet sockets only) The address the local end of the socket is bound to (see getsockname(2)).</dd>' . |
|
151 |
'<dt>FOREIGN ADDRESS</dt><dd>(Internet sockets only) The address the foreign end of the socket is bound to (see getpeername(2)).</dd>' . |
|
152 |
'</dl>'), info); |
|
153 |
?> |
|
154 |
</div> |
|
167 | 155 |
</div> |
168 | 156 |
<?php |
169 | 157 |
|
Also available in: Unified diff
Fixed #5404