diff options
author | jim-p <jimp@pfsense.org> | 2013-03-28 16:52:22 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2013-03-28 16:52:57 -0400 |
commit | e95e1e535d60d7cfbf87a8ee56bd3eb01a24656b (patch) | |
tree | b82f79ed9b6dc7dce498dbbd260ba2b9ab43c8f0 /config/mailreport/mail_reports_generate.php | |
parent | a6d5beb3f21295543ce8532ee6fd55d1a0e1ae0d (diff) | |
download | pfsense-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_generate.php')
-rw-r--r-- | config/mailreport/mail_reports_generate.php | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/config/mailreport/mail_reports_generate.php b/config/mailreport/mail_reports_generate.php index 7ff7b71e..81205ecb 100644 --- a/config/mailreport/mail_reports_generate.php +++ b/config/mailreport/mail_reports_generate.php @@ -53,17 +53,42 @@ if (!$config['mailreports']['schedule'][$id]) exit; $thisreport = $config['mailreports']['schedule'][$id]; +$cmds = $thisreport['cmd']['row']; +$logs = $thisreport['log']['row']; $graphs = $thisreport['row']; -// No graphs on the report, bail! -if (!is_array($graphs) || !(count($graphs) > 0)) - exit; +// If there is nothing to do, bail! +if ((!is_array($cmds) || !(count($cmds) > 0)) + && (!is_array($logs) || !(count($logs) > 0)) + && (!is_array($graphs) || !(count($graphs) > 0))) + return; // Print report header +// Print command output +$cmdtext = ""; +foreach ($cmds as $cmd) { + $output = ""; + $cmdtext .= "Command output for {$cmd['descr']}<br />\n"; + exec($cmd['detail'], $output); + $cmdtext .= "<pre>\n"; + $cmdtext .= implode("\n", $output); + $cmdtext .= "\n</pre>"; +} + +// Print log output +$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']}<br />\n"; + $logtext .= "<pre>\n"; + $logtext .= implode("\n", mail_report_get_log($log['logfile'], $lines, $filter)); + $logtext .= "\n</pre>"; +} + // For each graph, print a header and the graph $attach = array(); -$idx=0; foreach ($graphs as $thisgraph) { $dates = get_dates($thisgraph['period'], $thisgraph['timespan']); $start = $dates['start']; @@ -71,6 +96,6 @@ foreach ($graphs as $thisgraph) { $attach[] = mail_report_generate_graph($thisgraph['graph'], $thisgraph['style'], $thisgraph['timespan'], $start, $end); } -mail_report_send($thisreport['descr'], $attach); +mail_report_send($thisreport['descr'], $cmdtext, $logtext, $attach); ?>
\ No newline at end of file |