From 9bb239d4732cfd2b3ee6a5ade5839267563a6d0b Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 29 Mar 2013 10:31:21 -0400 Subject: Some more refinements for the mail reports package. --- config/mailreport/mail_reports.inc | 32 +++++++++++++++++++++++- config/mailreport/mail_reports_generate.php | 4 +-- config/mailreport/mailreport.xml | 2 +- config/mailreport/status_mail_report_add_cmd.php | 8 ++++++ config/mailreport/status_mail_report_add_log.php | 6 +---- config/mailreport/status_mail_report_edit.php | 2 +- pkg_config.8.xml | 2 +- pkg_config.8.xml.amd64 | 2 +- 8 files changed, 46 insertions(+), 12 deletions(-) diff --git a/config/mailreport/mail_reports.inc b/config/mailreport/mail_reports.inc index 7d68055d..85b67ddf 100644 --- a/config/mailreport/mail_reports.inc +++ b/config/mailreport/mail_reports.inc @@ -43,6 +43,28 @@ $graph_length = array( "year" => 31622400, "4year" => 126489600); +$logfile_friendly = array( + "dhcpd" => "DHCP", + "filter" => "Firewall (raw)", + "gateways" => "Gateway Events", + "installer" => "Installation", + "ipsec" => "IPsec VPN", + "l2tps" => "L2TP Server (raw)", + "lighttpd" => "Web Server (lighttpd)", + "ntpd" => "NTP", + "openvpn" => "OpenVPN", + "poes" => "PPPoE Server (raw)", + "portalauth" => "Captive Portal Authentication", + "ppp" => "PPP", + "pptps" => "PPTP Server (raw)", + "relayd" => "Load Balancer (relayd)", + "resolver" => "DNS Resolver", + "routing" => "Routing", + "system" => "System", + "vpn" => "PPTP/L2TP/PPPoE Server Login Events", + "wireless" => "Wireless" +); + function get_dates($curperiod, $graph) { global $graph_length; $now = time(); @@ -208,7 +230,7 @@ function mail_report_send($headertext, $cmdtext, $logtext, $attachments) { if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { - echo "Message sent to {$userid}!\n"; + echo "Message sent to {$address}!\n"; } } @@ -1226,4 +1248,12 @@ function mail_report_get_log($logfile, $tail, $grepfor) { return($logarr); } +function get_friendly_log_name($logfile) { + global $logfile_friendly; + $friendly = str_replace(".log", "", $logfile); + if (!empty($logfile_friendly[$friendly])) + $friendly = $logfile_friendly[$friendly]; + return $friendly; +} + ?> diff --git a/config/mailreport/mail_reports_generate.php b/config/mailreport/mail_reports_generate.php index 81205ecb..a784c596 100644 --- a/config/mailreport/mail_reports_generate.php +++ b/config/mailreport/mail_reports_generate.php @@ -69,7 +69,7 @@ if ((!is_array($cmds) || !(count($cmds) > 0)) $cmdtext = ""; foreach ($cmds as $cmd) { $output = ""; - $cmdtext .= "Command output for {$cmd['descr']}
\n"; + $cmdtext .= "Command output: {$cmd['descr']} (" . htmlspecialchars($cmd['detail']) . ")
\n"; exec($cmd['detail'], $output); $cmdtext .= "
\n";
 	$cmdtext .= implode("\n", $output);
@@ -81,7 +81,7 @@ $logtext = "";
 foreach ($logs as $log) {
 	$lines = empty($log['lines']) ? 50 : $log['lines'];
 	$filter = empty($log['detail']) ? null : array($log['detail']);
-	$logtext .= "Log output for {$log['logfile']}
\n"; + $logtext .= "Log output: " . get_friendly_log_name($log['logfile']) . " ({$log['logfile']})
\n"; $logtext .= "
\n";
 	$logtext .= implode("\n", mail_report_get_log($log['logfile'], $lines, $filter));
 	$logtext .= "\n
"; diff --git a/config/mailreport/mailreport.xml b/config/mailreport/mailreport.xml index a437851c..d27d3a28 100644 --- a/config/mailreport/mailreport.xml +++ b/config/mailreport/mailreport.xml @@ -37,7 +37,7 @@ ]]> mailreport - 2.0 + 2.0.4 Status: Mail Reports /usr/local/bin/ diff --git a/config/mailreport/status_mail_report_add_cmd.php b/config/mailreport/status_mail_report_add_cmd.php index adbdcd77..4a82f051 100644 --- a/config/mailreport/status_mail_report_add_cmd.php +++ b/config/mailreport/status_mail_report_add_cmd.php @@ -117,6 +117,14 @@ include("head.inc"); + +   + +
NOTE: The command will be run during the report and its stdout output will be included in the report body. Be extremely careful what commands you choose to run, the same warnings apply as those when using Diagnostics > Command. +
+
Do not use this solely as a way to run a command on a schedule, use the Cron package for that purpose instead. + + "> diff --git a/config/mailreport/status_mail_report_add_log.php b/config/mailreport/status_mail_report_add_log.php index 5a2261be..75d092b5 100644 --- a/config/mailreport/status_mail_report_add_log.php +++ b/config/mailreport/status_mail_report_add_log.php @@ -72,9 +72,6 @@ if (isset($id) && !($a_logs[$id])) { return; } - - - $logpath = "/var/log/"; chdir($logpath); $logfiles = glob("*.log"); @@ -118,12 +115,11 @@ include("head.inc"); diff --git a/config/mailreport/status_mail_report_edit.php b/config/mailreport/status_mail_report_edit.php index c1289442..7ddb4c36 100644 --- a/config/mailreport/status_mail_report_edit.php +++ b/config/mailreport/status_mail_report_edit.php @@ -293,7 +293,7 @@ include("head.inc"); - + diff --git a/pkg_config.8.xml b/pkg_config.8.xml index 29ee34de..22740632 100644 --- a/pkg_config.8.xml +++ b/pkg_config.8.xml @@ -1628,7 +1628,7 @@ mailreport Allows you to setup periodic e-mail reports containing command output, log file contents, and RRD graphs. Network Management - 2.0 + 2.0.4 BETA 2.0 http://www.pfsense.com/packages/config/mailreport/mailreport.xml diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64 index 67383f7a..ba941b46 100644 --- a/pkg_config.8.xml.amd64 +++ b/pkg_config.8.xml.amd64 @@ -1615,7 +1615,7 @@ mailreport Allows you to setup periodic e-mail reports containing command output, log file contents, and RRD graphs. Network Management - 2.0 + 2.0.4 BETA 2.0 http://www.pfsense.com/packages/config/mailreport/mailreport.xml -- cgit v1.2.3