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*
|
39
|
##|-PRIV
|
40
|
|
41
|
require("guiconfig.inc");
|
42
|
|
43
|
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
|
44
|
|
45
|
$pgtitle = "Diagnostics: PFTop";
|
46
|
|
47
|
if($_REQUEST['getactivity']) {
|
48
|
if($_REQUEST['sorttype'])
|
49
|
$sorttype = escapeshellarg($_REQUEST['sorttype']);
|
50
|
else
|
51
|
$sorttype = "bytes";
|
52
|
$text = `pftop -b -a -o {$sorttype}`;
|
53
|
echo $text;
|
54
|
exit;
|
55
|
}
|
56
|
|
57
|
include("head.inc");
|
58
|
|
59
|
if($_REQUEST['sorttype'])
|
60
|
$sorttype = htmlentities($_REQUEST['sorttype']);
|
61
|
else
|
62
|
$sorttype = "bytes";
|
63
|
|
64
|
?>
|
65
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
66
|
<form method="post" action="diag_system_pftop.php">
|
67
|
<script type="text/javascript">
|
68
|
function getcpuactivity() {
|
69
|
var url = "/diag_system_pftop.php";
|
70
|
var pars = 'getactivity=yes&sorttype=' + $('sorttype').value;
|
71
|
var myAjax = new Ajax.Request(
|
72
|
url,
|
73
|
{
|
74
|
method: 'post',
|
75
|
parameters: pars,
|
76
|
onComplete: activitycallback
|
77
|
});
|
78
|
}
|
79
|
function activitycallback(transport) {
|
80
|
$('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText + '</pre></font>';
|
81
|
setTimeout('getcpuactivity()', 2500);
|
82
|
}
|
83
|
setTimeout('getcpuactivity()', 1000);
|
84
|
</script>
|
85
|
<div id='maincontent'>
|
86
|
<?php
|
87
|
include("fbegin.inc");
|
88
|
if(strstr($pfSversion, "1.2"))
|
89
|
echo "<p class=\"pgtitle\">{$pgtitle}</p>";
|
90
|
if($savemsg) {
|
91
|
echo "<div id='savemsg'>";
|
92
|
print_info_box($savemsg);
|
93
|
echo "</div>";
|
94
|
}
|
95
|
if ($input_errors)
|
96
|
print_input_errors($input_errors);
|
97
|
?>
|
98
|
<form method="post">
|
99
|
Sort type:
|
100
|
<select name='sorttype' id='sorttype' onChange='this.form.submit();'>
|
101
|
<option value='<?=$sorttype?>'><?=$sorttype?></option>
|
102
|
<option value='age'>age</option>
|
103
|
<option value='bytes'>bytes</option>
|
104
|
<option value='dest'>dest</option>
|
105
|
<option value='dport'>dport</option>
|
106
|
<option value='exp'>exp</option>
|
107
|
<option value='none'>none</option>
|
108
|
<option value='peak'>peak</option>
|
109
|
<option value='pkt'>pkt</option>
|
110
|
<option value='rate'>rate</option>
|
111
|
<option value='size'>size</option>
|
112
|
<option value='sport'>sport</option>
|
113
|
<option value='src'>src</option>
|
114
|
</select>
|
115
|
<p/>
|
116
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
117
|
<tr>
|
118
|
<td>
|
119
|
<table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
|
120
|
<tr>
|
121
|
<td>
|
122
|
<center>
|
123
|
<table>
|
124
|
<tr><td>
|
125
|
<div name='cpuactivitydiv' id='cpuactivitydiv'>
|
126
|
<b>Gathering pfTOP activity, please wait...
|
127
|
</div>
|
128
|
</td></tr>
|
129
|
</table>
|
130
|
</td>
|
131
|
</tr>
|
132
|
</table>
|
133
|
</div>
|
134
|
</td>
|
135
|
</tr>
|
136
|
</table>
|
137
|
</form>
|
138
|
<?php include("fend.inc"); ?>
|
139
|
</body>
|
140
|
</html>
|