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