Project

General

Profile

Download (5.47 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / diag_sockets.php @ a1b66bec

1
<?php
2

    
3
/* $Id$ */
4
/*
5
	diag_sockets.php
6
	Copyright (C) 2012
7
	All rights reserved.
8

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

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

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

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

    
30
*/
31

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

    
42
include('guiconfig.inc');
43

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

    
46
include('head.inc');
47

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

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

    
56
?>
57
<div id="mainarea">
58
<table class="tabcont" width="100%" summary="diag sockets">
59
<tr>
60
<td>Information about listening sockets for both <a href="#IPv4">IPv4</a> and <a href="#IPv6">IPv6</a>.</td>
61
</tr>
62
<tr>
63
<td>For explanation about the meaning of the information listed for each socket click <a href="#about">here</a>.</td>
64
</tr>
65
<tr>
66
<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>
67
</tr>
68
</table>
69

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

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

    
117
<br />
118
<a name="about"></a>
119
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="info">
120
	<tr><td colspan="2" class="listtopic" >Socket information explanation</td></tr>
121
<tr><td colspan="2" class="listhdrr">
122
This page show the output for the commands: "sockstat -4lL" and "sockstat -6lL".<br />
123
Or in case of showing all sockets the output for: "sockstat -4" and "sockstat -6".<br />
124
<br />
125
The information listed for each socket is:</td></tr>
126
	<tr><td class="listlr">USER	      </td><td class="listr">The user who owns the socket.</td></tr>
127
	<tr><td class="listlr">COMMAND	      </td><td class="listr">The command which holds the socket.</td></tr>
128
	<tr><td class="listlr">PID	      </td><td class="listr">The process ID of the command which holds the socket.</td></tr>
129
	<tr><td class="listlr">FD 	      </td><td class="listr">The file descriptor number of the socket.</td></tr>
130
	<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>
131
	<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>
132
	<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>
133
	<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>
134
</table>
135
</div>
136
<?php
137
include('fend.inc');
138
?>
139
</body>
140
</html>
(47-47/256)