aboutsummaryrefslogtreecommitdiffstats
path: root/config/mailreport/mail_reports.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2013-03-28 16:52:22 -0400
committerjim-p <jimp@pfsense.org>2013-03-28 16:52:57 -0400
commite95e1e535d60d7cfbf87a8ee56bd3eb01a24656b (patch)
treeb82f79ed9b6dc7dce498dbbd260ba2b9ab43c8f0 /config/mailreport/mail_reports.inc
parenta6d5beb3f21295543ce8532ee6fd55d1a0e1ae0d (diff)
downloadpfsense-packages-e95e1e535d60d7cfbf87a8ee56bd3eb01a24656b.tar.gz
pfsense-packages-e95e1e535d60d7cfbf87a8ee56bd3eb01a24656b.tar.bz2
pfsense-packages-e95e1e535d60d7cfbf87a8ee56bd3eb01a24656b.zip
Add command output and log output capabilities to the "mail reports" package.
Diffstat (limited to 'config/mailreport/mail_reports.inc')
-rw-r--r--config/mailreport/mail_reports.inc29
1 files changed, 27 insertions, 2 deletions
diff --git a/config/mailreport/mail_reports.inc b/config/mailreport/mail_reports.inc
index 8ab31301..7d68055d 100644
--- a/config/mailreport/mail_reports.inc
+++ b/config/mailreport/mail_reports.inc
@@ -29,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
*/
+require_once("globals.inc");
require_once("config.inc");
require_once("filter.inc");
require_once("rrd.inc");
@@ -162,7 +163,7 @@ function set_mail_report_cron_jobs($a_mailreports) {
include('phpmailer/class.phpmailer.php');
-function mail_report_send($headertext, $attachments) {
+function mail_report_send($headertext, $cmdtext, $logtext, $attachments) {
global $config, $g;
if (empty($config['notifications']['smtp']['ipaddress']))
@@ -191,7 +192,11 @@ function mail_report_send($headertext, $attachments) {
$address = $config['notifications']['smtp']['notifyemailaddress'];
$mail->AddAddress($address, "Report Recipient");
$mail->Subject = "{$config['system']['hostname']}.{$config['system']['domain']} Graph Report: {$headertext}";
- $mail->Body .= "This is a periodic graph report from your firewall, {$config['system']['hostname']}.{$config['system']['domain']}.<br/><br/>Current report: {$headertext}\n";
+ $mail->Body .= "This is a periodic report from your firewall, {$config['system']['hostname']}.{$config['system']['domain']}.<br /><br />Current report: {$headertext}<br />\n<br />\n";
+ if (!empty($cmdtext))
+ $mail->Body .= $cmdtext;
+ if (!empty($logtext))
+ $mail->Body .= $logtext;
if(is_array($attachments)) {
foreach($attachments as $filename) {
$shortname = basename($filename);
@@ -1201,4 +1206,24 @@ function timeDiff($time, $opt = array()) {
return $str;
}
+function mail_report_get_log($logfile, $tail, $grepfor) {
+ global $g, $config;
+ $logfile = "{$g['varlog_path']}/{$logfile}";
+ $logarr = "";
+ $grepline = " ";
+ if(is_array($grepfor))
+ foreach($grepfor as $agrep)
+ $grepline .= " | grep \"$agrep\"";
+ if($config['system']['disablesyslogclog']) {
+ exec("cat {$logfile}{$grepline} | /usr/bin/tail -n {$tail}", $logarr);
+ } else {
+ if(isset($config['system']['usefifolog'])) {
+ exec("/usr/sbin/fifolog_reader {$logfile}{$grepline} | /usr/bin/tail -n {$tail}", $logarr);
+ } else {
+ exec("/usr/sbin/clog {$logfile}{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail -n {$tail}", $logarr);
+ }
+ }
+ return($logarr);
+}
+
?>