Project

General

Profile

Download (4.01 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    diag_cpu_pftop.php
5
    Copyright (C) 2008 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
##|+PRIV
31
##|*IDENT=page-diag-system-activity
32
##|*NAME=Diagnostics: System Activity
33
##|*DESCR=Allows access to the 'Diagnostics: System Activity' page
34
##|*MATCH=diag_system_activity*
35
##|-PRIV
36

    
37
require("guiconfig.inc");
38

    
39
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
40

    
41
$pgtitle = "Diagnostics: PFTop";
42

    
43
if($_REQUEST['getactivity']) {
44
	if($_REQUEST['sorttype'])
45
		$sorttype = escapeshellarg($_REQUEST['sorttype']);
46
	else
47
		$sorttype = "bytes";	
48
	$text = `pftop -b -a -o {$sorttype}`;
49
	echo $text;
50
	exit;
51
}
52

    
53
include("head.inc");
54

    
55
if($_REQUEST['sorttype'])
56
	$sorttype = htmlentities($_REQUEST['sorttype']);
57
else
58
	$sorttype = "bytes";
59

    
60
?>
61
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
62
<form method="post" action="diag_system_pftop.php">
63
<script type="text/javascript">
64
	function getcpuactivity() {
65
		var url = "/diag_system_pftop.php";
66
		var pars = 'getactivity=yes&sorttype=' + $('sorttype').value;
67
		var myAjax = new Ajax.Request(
68
			url,
69
			{
70
				method: 'post',
71
				parameters: pars,
72
				onComplete: activitycallback
73
			});
74
	}
75
	function activitycallback(transport) {
76
		$('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText  + '</pre></font>';
77
		setTimeout('getcpuactivity()', 2500);		
78
	}
79
	setTimeout('getcpuactivity()', 1000);	
80
</script>
81
<div id='maincontent'>
82
<?php
83
	include("fbegin.inc"); 
84
	if(strstr($pfSversion, "1.2")) 
85
		echo "<p class=\"pgtitle\">{$pgtitle}</p>";
86
	if($savemsg) {
87
		echo "<div id='savemsg'>";
88
		print_info_box($savemsg);
89
		echo "</div>";	
90
	}
91
	if ($input_errors)
92
		print_input_errors($input_errors);
93
?>
94
	<form method="post">
95
	Sort type: 
96
	<select name='sorttype' id='sorttype' onChange='this.form.submit();'>
97
		<option value='<?=$sorttype?>'><?=$sorttype?></option>
98
		<option value='age'>age</option>
99
		<option value='bytes'>bytes</option>
100
		<option value='dest'>dest</option>
101
		<option value='dport'>dport</option>
102
		<option value='exp'>exp</option>
103
		<option value='none'>none</option>
104
		<option value='peak'>peak</option>
105
		<option value='pkt'>pkt</option>
106
		<option value='rate'>rate</option>
107
		<option value='size'>size</option>
108
		<option value='sport'>sport</option>
109
		<option value='src'>src</option>														
110
	</select>
111
	<p/>
112
<table width="100%" border="0" cellpadding="0" cellspacing="0">  
113
  <tr>
114
    <td>
115
	<table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
116
		<tr>
117
			<td>
118
				<center>
119
				<table>
120
					<tr><td>
121
						<div name='cpuactivitydiv' id='cpuactivitydiv'>
122
							<b>Gathering pfTOP activity, please wait...
123
						</div>
124
					</td></tr>
125
				</table>
126
			</td>
127
		</tr>
128
	</table>
129
	</div>
130
    </td>
131
  </tr>
132
</table>
133
</form>
134
<?php include("fend.inc"); ?>
135
</body>
136
</html>
(30-30/203)