1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_rrd_graph.php
|
5
|
Part of pfSense
|
6
|
Copyright (C) 2007 Seth Mos <seth.mos@dds.nl>
|
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
|
pfSense_BUILDER_BINARIES: /usr/bin/find
|
32
|
pfSense_MODULE: system
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-status-rrdgraph-settings
|
37
|
##|*NAME=Status: RRD Graphs settings page
|
38
|
##|*DESCR=Allow access to the 'Status: RRD Graphs: settings' page.
|
39
|
##|*MATCH=status_rrd_graph_settings.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require("guiconfig.inc");
|
43
|
require_once("filter.inc");
|
44
|
require("shaper.inc");
|
45
|
require_once("rrd.inc");
|
46
|
|
47
|
$pconfig['enable'] = isset($config['rrd']['enable']);
|
48
|
$pconfig['category'] = $config['rrd']['category'];
|
49
|
$pconfig['style'] = $config['rrd']['style'];
|
50
|
$pconfig['period'] = $config['rrd']['period'];
|
51
|
|
52
|
$curcat = "settings";
|
53
|
$categories = array('system' => gettext("System"),
|
54
|
'traffic' => gettext("Traffic"),
|
55
|
'packets' => gettext("Packets"),
|
56
|
'quality' => gettext("Quality"),
|
57
|
'queues' => gettext("Queues"),
|
58
|
'captiveportal' => gettext("Captive Portal"));
|
59
|
$styles = array('inverse' => gettext("Inverse"),
|
60
|
'absolute' => gettext("Absolute"));
|
61
|
$periods = array("absolute" => gettext("Absolute Timespans"),
|
62
|
"current" => gettext("Current Period"),
|
63
|
"previous" => gettext("Previous Period"));
|
64
|
|
65
|
if ($_POST['ResetRRD']) {
|
66
|
mwexec('/bin/rm /var/db/rrd/*');
|
67
|
enable_rrd_graphing();
|
68
|
setup_gateways_monitor();
|
69
|
$savemsg = "RRD data has been cleared. New RRD files have been generated.";
|
70
|
} elseif ($_POST) {
|
71
|
unset($input_errors);
|
72
|
$pconfig = $_POST;
|
73
|
|
74
|
/* input validation */
|
75
|
/* none */
|
76
|
|
77
|
if (!$input_errors) {
|
78
|
$config['rrd']['enable'] = $_POST['enable'] ? true : false;
|
79
|
$config['rrd']['category'] = $_POST['category'];
|
80
|
$config['rrd']['style'] = $_POST['style'];
|
81
|
$config['rrd']['period'] = $_POST['period'];
|
82
|
write_config();
|
83
|
|
84
|
$retval = 0;
|
85
|
$retval = enable_rrd_graphing();
|
86
|
$savemsg = get_std_save_message($retval);
|
87
|
}
|
88
|
}
|
89
|
|
90
|
|
91
|
|
92
|
$rrddbpath = "/var/db/rrd/";
|
93
|
chdir($rrddbpath);
|
94
|
$databases = glob("*.rrd");
|
95
|
|
96
|
foreach($databases as $database) {
|
97
|
if(stristr($database, "wireless")) {
|
98
|
$wireless = true;
|
99
|
}
|
100
|
if(stristr($database, "queues")) {
|
101
|
$queues = true;
|
102
|
}
|
103
|
if(stristr($database, "-cellular") && !empty($config['ppps'])) {
|
104
|
$cellular = true;
|
105
|
}
|
106
|
if(stristr($database, "-vpnusers")) {
|
107
|
$vpnusers = true;
|
108
|
}
|
109
|
if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
|
110
|
$captiveportal = true;
|
111
|
}
|
112
|
}
|
113
|
|
114
|
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
|
115
|
include("head.inc");
|
116
|
|
117
|
?>
|
118
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
119
|
<?php include("fbegin.inc"); ?>
|
120
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
121
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
122
|
<form action="status_rrd_graph_settings.php" method="post" name="iform" id="iform">
|
123
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
124
|
<tr>
|
125
|
<td>
|
126
|
<?php
|
127
|
$tab_array = array();
|
128
|
if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
|
129
|
$tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
|
130
|
if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
|
131
|
$tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
|
132
|
if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
|
133
|
$tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
|
134
|
if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
|
135
|
$tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
|
136
|
if($queues) {
|
137
|
if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
|
138
|
$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
|
139
|
if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
|
140
|
$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
|
141
|
}
|
142
|
if($wireless) {
|
143
|
if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
|
144
|
$tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
|
145
|
}
|
146
|
if($cellular) {
|
147
|
if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
|
148
|
$tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
|
149
|
}
|
150
|
if($vpnusers) {
|
151
|
if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
|
152
|
$tab_array[] = array(gettext("VPN"), $tabactive, "status_rrd_graph.php?cat=vpnusers");
|
153
|
}
|
154
|
if($captiveportal) {
|
155
|
if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
|
156
|
$tab_array[] = array(gettext("Captive Portal"), $tabactive, "status_rrd_graph.php?cat=captiveportal");
|
157
|
}
|
158
|
if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
|
159
|
$tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
|
160
|
if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
|
161
|
$tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
|
162
|
|
163
|
display_top_tabs($tab_array);
|
164
|
?>
|
165
|
</td>
|
166
|
</tr>
|
167
|
<tr>
|
168
|
<td>
|
169
|
<div id="mainarea">
|
170
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
|
171
|
<tr>
|
172
|
<td width="22%" valign="top" class="vtable"><?=gettext("RRD Graphs");?></td>
|
173
|
<td width="78%" class="vtable">
|
174
|
<input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked=\"checked\"" ?> onclick="enable_change(false)"/>
|
175
|
<b><?=gettext("Enables the RRD graphing backend.");?></b>
|
176
|
</td>
|
177
|
</tr>
|
178
|
<tr>
|
179
|
<td width="22%" valign="top" class="vtable"><?=gettext("Default category");?></td>
|
180
|
<td width="78%" class="vtable">
|
181
|
<select name="category" id="category" class="formselect" style="z-index: -10;" >
|
182
|
<?php
|
183
|
foreach ($categories as $category => $categoryd) {
|
184
|
echo "<option value=\"$category\"";
|
185
|
if ($category == $pconfig['category']) echo " selected=\"selected\"";
|
186
|
echo ">" . htmlspecialchars($categoryd) . "</option>\n";
|
187
|
}
|
188
|
?>
|
189
|
</select>
|
190
|
<b><?=gettext("This selects default category.");?></b>
|
191
|
</td>
|
192
|
</tr>
|
193
|
<tr>
|
194
|
<td width="22%" valign="top" class="vtable"><?=gettext("Default style");?></td>
|
195
|
<td width="78%" class="vtable">
|
196
|
<select name="style" class="formselect" style="z-index: -10;" >
|
197
|
<?php
|
198
|
foreach ($styles as $style => $styled) {
|
199
|
echo "<option value=\"$style\"";
|
200
|
if ($style == $pconfig['style']) echo " selected=\"selected\"";
|
201
|
echo ">" . htmlspecialchars($styled) . "</option>\n";
|
202
|
}
|
203
|
?>
|
204
|
</select>
|
205
|
<b><?=gettext("This selects the default style.");?></b>
|
206
|
</td>
|
207
|
</tr>
|
208
|
<tr>
|
209
|
<td width="22%" valign="top" class="vtable"><?=gettext("Default period");?></td>
|
210
|
<td width="78%" class="vtable">
|
211
|
<select name="period" class="formselect" style="z-index: -10;" >
|
212
|
<?php
|
213
|
foreach ($periods as $period => $periodd) {
|
214
|
echo "<option value=\"$period\"";
|
215
|
if ($period == $pconfig['period']) echo " selected=\"selected\"";
|
216
|
echo ">" . htmlspecialchars($periodd) . "</option>\n";
|
217
|
}
|
218
|
?>
|
219
|
</select>
|
220
|
<b><?=gettext("This selects the default period.");?></b>
|
221
|
</td>
|
222
|
</tr>
|
223
|
<tr>
|
224
|
<td width="22%" valign="top"> </td>
|
225
|
<td width="78%">
|
226
|
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)"/>
|
227
|
</td>
|
228
|
</tr>
|
229
|
<tr>
|
230
|
<td width="22%" valign="top"> </td>
|
231
|
<td width="78%">
|
232
|
<input name="ResetRRD" type="submit" class="formbtn" value="<?=gettext("Reset RRD Data");?>" onclick="return confirm('<?=gettext('Do you really want to reset the RRD graphs? This will erase all graph data.');?>')"/>
|
233
|
</td>
|
234
|
</tr>
|
235
|
<tr>
|
236
|
<td width="22%" height="53" valign="top"> </td>
|
237
|
<td width="78%"><strong><span class="red"><?=gettext("Note:");?></span></strong><br />
|
238
|
<?=gettext("Graphs will not be allowed to be recreated within a 1 minute interval, please " .
|
239
|
"take this into account after changing the style.");?>
|
240
|
</td>
|
241
|
</tr>
|
242
|
</table>
|
243
|
</div>
|
244
|
</td>
|
245
|
</tr>
|
246
|
</table>
|
247
|
|
248
|
</form>
|
249
|
<?php include("fend.inc"); ?>
|
250
|
</body>
|
251
|
</html>
|