1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
diag_system_pftop.php
|
5
|
Copyright (C) 2008-2009 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
/*
|
31
|
pfSense_MODULE: filter
|
32
|
*/
|
33
|
|
34
|
##|+PRIV
|
35
|
##|*IDENT=page-diag-system-activity
|
36
|
##|*NAME=Diagnostics: System Activity
|
37
|
##|*DESCR=Allows access to the 'Diagnostics: System Activity' page
|
38
|
##|*MATCH=diag_system_pftop.php*
|
39
|
##|-PRIV
|
40
|
|
41
|
require("guiconfig.inc");
|
42
|
|
43
|
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
|
44
|
|
45
|
$pgtitle = gettext("Diagnostics: pfTop");
|
46
|
|
47
|
$sorttypes = array('age', 'bytes', 'dest', 'dport', 'exp', 'none', 'peak', 'pkt', 'rate', 'size', 'sport', 'src');
|
48
|
|
49
|
if($_REQUEST['getactivity']) {
|
50
|
if($_REQUEST['sorttype'] && in_array($_REQUEST['sorttype'], array_keys($sorttypes)))
|
51
|
$sorttype = escapeshellarg($_REQUEST['sorttype']);
|
52
|
else
|
53
|
$sorttype = gettext("bytes");
|
54
|
$text = `pftop -b -a -o {$sorttype}`;
|
55
|
echo $text;
|
56
|
exit;
|
57
|
}
|
58
|
|
59
|
include("head.inc");
|
60
|
|
61
|
if($_REQUEST['sorttype'] && in_array($_REQUEST['sorttype'], array_keys($sorttypes)))
|
62
|
$sorttype = htmlentities($_REQUEST['sorttype']);
|
63
|
else
|
64
|
$sorttype = gettext("bytes");
|
65
|
|
66
|
?>
|
67
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
68
|
<form method="post" action="diag_system_pftop.php">
|
69
|
<script type="text/javascript">
|
70
|
function getcpuactivity() {
|
71
|
var url = "/diag_system_pftop.php";
|
72
|
var pars = 'getactivity=yes&sorttype=' + $('sorttype').value;
|
73
|
var myAjax = new Ajax.Request(
|
74
|
url,
|
75
|
{
|
76
|
method: 'post',
|
77
|
parameters: pars,
|
78
|
onComplete: activitycallback
|
79
|
});
|
80
|
}
|
81
|
function activitycallback(transport) {
|
82
|
$('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre style="text-align:left;">' + transport.responseText + '</pre></font>';
|
83
|
setTimeout('getcpuactivity()', 2500);
|
84
|
}
|
85
|
setTimeout('getcpuactivity()', 1000);
|
86
|
</script>
|
87
|
<div id='maincontent'>
|
88
|
<?php
|
89
|
include("fbegin.inc");
|
90
|
if(strstr($pfSversion, "1.2"))
|
91
|
echo "<p class=\"pgtitle\">{$pgtitle}</p>";
|
92
|
if($savemsg) {
|
93
|
echo "<div id='savemsg'>";
|
94
|
print_info_box($savemsg);
|
95
|
echo "</div>";
|
96
|
}
|
97
|
if ($input_errors)
|
98
|
print_input_errors($input_errors);
|
99
|
?>
|
100
|
<form method="post">
|
101
|
<?=gettext("Sort type:"); ?>
|
102
|
<select name='sorttype' id='sorttype' onChange='this.form.submit();'>
|
103
|
<option value='age' <?php echo ($sorttype == "age") ? "selected" : ""; ?>><?=gettext("Age");?></option>
|
104
|
<option value='bytes' <?php echo ($sorttype == "bytes") ? "selected" : ""; ?>><?=gettext("Bytes");?></option>
|
105
|
<option value='dest' <?php echo ($sorttype == "dest") ? "selected" : ""; ?>><?=gettext("Destination Host");?></option>
|
106
|
<option value='dport' <?php echo ($sorttype == "dport") ? "selected" : ""; ?>><?=gettext("Destination Port");?></option>
|
107
|
<option value='exp' <?php echo ($sorttype == "exp") ? "selected" : ""; ?>><?=gettext("Expiry");?></option>
|
108
|
<option value='none' <?php echo ($sorttype == "none") ? "selected" : ""; ?>><?=gettext("None");?></option>
|
109
|
<option value='peak' <?php echo ($sorttype == "peak") ? "selected" : ""; ?>><?=gettext("Peak");?></option>
|
110
|
<option value='pkt' <?php echo ($sorttype == "pkt") ? "selected" : ""; ?>><?=gettext("Packet");?></option>
|
111
|
<option value='rate' <?php echo ($sorttype == "rate") ? "selected" : ""; ?>><?=gettext("Rate");?></option>
|
112
|
<option value='size' <?php echo ($sorttype == "size") ? "selected" : ""; ?>><?=gettext("Size");?></option>
|
113
|
<option value='sport' <?php echo ($sorttype == "sport") ? "selected" : ""; ?>><?=gettext("Source Port");?></option>
|
114
|
<option value='src' <?php echo ($sorttype == "src") ? "selected" : ""; ?>><?=gettext("Source Host");?></option>
|
115
|
</select>
|
116
|
<p/>
|
117
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
118
|
<tr>
|
119
|
<td>
|
120
|
<table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
|
121
|
<tr>
|
122
|
<td>
|
123
|
<center>
|
124
|
<table>
|
125
|
<tr><td>
|
126
|
<div name='cpuactivitydiv' id='cpuactivitydiv'>
|
127
|
<b><?=gettext("Gathering pfTOP activity, please wait...");?>
|
128
|
</div>
|
129
|
</td></tr>
|
130
|
</table>
|
131
|
</td>
|
132
|
</tr>
|
133
|
</table>
|
134
|
</div>
|
135
|
</td>
|
136
|
</tr>
|
137
|
</table>
|
138
|
</form>
|
139
|
<?php include("fend.inc"); ?>
|
140
|
</body>
|
141
|
</html>
|