From 6eb2826c34930dbda15512f1d64db00a7c7f3859 Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 19 Jul 2011 17:13:47 -0400 Subject: Add mailreport package for periodic e-mail of RRD graphs. First rev. --- config/mailreport/status_mail_report_add_graph.php | 266 +++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 config/mailreport/status_mail_report_add_graph.php (limited to 'config/mailreport/status_mail_report_add_graph.php') diff --git a/config/mailreport/status_mail_report_add_graph.php b/config/mailreport/status_mail_report_add_graph.php new file mode 100644 index 00000000..17d7731c --- /dev/null +++ b/config/mailreport/status_mail_report_add_graph.php @@ -0,0 +1,266 @@ + + Portions Copyright (C) 2007-2011 Seth Mos + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* + pfSense_MODULE: system +*/ + +##|+PRIV +##|*IDENT=page-status-rrdgraphs +##|*NAME=Status: RRD Graphs page +##|*DESCR=Allow access to the 'Status: RRD Graphs' page. +##|*MATCH=status_rrd_graph.php* +##|-PRIV + +require("guiconfig.inc"); +require_once("filter.inc"); +require("shaper.inc"); +require_once("rrd.inc"); +require_once("mail_reports.inc"); + +/* if the rrd graphs are not enabled redirect to settings page */ +if(! isset($config['rrd']['enable'])) { + header("Location: status_rrd_graph_settings.php"); +} + +$reportid = $_GET['reportid']; +if (isset($_POST['reportid'])) + $reportid = $_POST['reportid']; + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (!is_array($config['mailreports']['schedule'])) + $config['mailreports']['schedule'] = array(); + +$a_mailreports = &$config['mailreports']['schedule']; + +if (!isset($reportid) || !isset($a_mailreports[$reportid])) { + header("Location: status_mail_report.php"); + exit; +} + +if (!is_array($a_mailreports[$reportid]['row'])) + $a_mailreports[$reportid]['row'] = array(); +$a_graphs = $a_mailreports[$reportid]['row']; + +if (isset($id) && $a_graphs[$id]) { + $pconfig = $a_graphs[$id]; +} else { + $pconfig = array(); +} + +if (isset($id) && !($a_graphs[$id])) { + header("Location: status_mail_report_edit.php?id={$reportid}"); + exit; +} + + + + +$rrddbpath = "/var/db/rrd/"; +chdir($rrddbpath); +$databases = glob("*.rrd"); + +$now = time(); + +/* sort names reverse so WAN comes first */ +rsort($databases); + +/* these boilerplate databases are required for the other menu choices */ +$dbheader = array("allgraphs-traffic.rrd", + "allgraphs-quality.rrd", + "allgraphs-wireless.rrd", + "allgraphs-cellular.rrd", + "allgraphs-vpnusers.rrd", + "captiveportal-allgraphs.rrd", + "allgraphs-packets.rrd", + "system-allgraphs.rrd", + "system-throughput.rrd", + "outbound-quality.rrd", + "outbound-packets.rrd", + "outbound-traffic.rrd"); + +/* additional menu choices for the custom tab */ +$dbheader_custom = array("system-throughput.rrd"); + +foreach($databases as $database) { + if(stristr($database, "-wireless")) { + $wireless = true; + } + if(stristr($database, "-queues")) { + $queues = true; + } + if(stristr($database, "-cellular") && !empty($config['ppps'])) { + $cellular = true; + } + if(stristr($database, "-vpnusers")) { + $vpnusers = true; + } + if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) { + $captiveportal = true; + } +} +/* append the existing array to the header */ +$ui_databases = array_merge($dbheader, $databases); +$custom_databases = array_merge($dbheader_custom, $databases); + +$styles = array('inverse' => gettext('Inverse'), + 'absolute' => gettext('Absolute')); +$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year"); +$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period")); +$graph_length = array( + "8hour" => 28800, + "day" => 86400, + "week" => 604800, + "month" => 2764800, + "quarter" => 8035200, + "year" => 31622400, + "4year" => 126489600); + +if ($_POST) { + unset($_POST['__csrf_magic']); + $pconfig = $_POST; + + if (isset($id) && $a_graphs[$id]) + $a_graphs[$id] = $pconfig; + else + $a_graphs[] = $pconfig; + + $a_mailreports[$reportid]['row'] = $a_graphs; + + write_config(); + header("Location: status_mail_report_edit.php?id={$reportid}"); + exit; +} + + +$pgtitle = array(gettext("Status"),gettext("Add Mail Report Graph")); +include("head.inc"); +?> + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Graph Settings
+ + + +
+ + + +
+ + + +
+ + + +
+ "> + "> + + + + +
+
+
+ + + + -- cgit v1.2.3