From 430538564431b4d42abce579175e9ee851fcf686 Mon Sep 17 00:00:00 2001 From: jim-p Date: Sun, 7 Jun 2009 21:37:46 -0400 Subject: Use saner control flow, and also make the charts each use their own data properly. --- usr/local/www/diag_logs_filter_summary.php | 108 ++++++++++++++--------------- 1 file changed, 51 insertions(+), 57 deletions(-) (limited to 'usr') diff --git a/usr/local/www/diag_logs_filter_summary.php b/usr/local/www/diag_logs_filter_summary.php index f3343b5..e5538f8 100644 --- a/usr/local/www/diag_logs_filter_summary.php +++ b/usr/local/www/diag_logs_filter_summary.php @@ -29,31 +29,27 @@ $pgtitle = "Diagnostics: System logs: Firewall Log Summary"; require_once("guiconfig.inc"); -include_once("filter_log.inc"); +include_once("includes/log.inc.php"); $filter_logfile = "{$g['varlog_path']}/filter.log"; $lines = 5000; $entriesperblock = 5; -$filterlog = conv_log_filter($filter_logfile, $lines, $lines); +$filterlog = conv_clog_filter($filter_logfile, $lines, $lines); $gotlines = count($filterlog); - -$descr = array(); -$descr['actions'] = "Actions"; -$descr['ints'] = "Interfaces"; -$descr['protos'] = "Protocols"; -$descr['srcips'] = "Source IPs"; -$descr['dstips'] = "Destination IPs"; -$descr['srcports'] = "Source Ports"; -$descr['dstports'] = "Destination Ports"; - -$summary['actions'] = array(); -$summary['ints'] = array(); -$summary['protos'] = array(); -$summary['srcips'] = array(); -$summary['dstips'] = array(); -$summary['srcports'] = array(); -$summary['dstports'] = array(); +$fields = array( + 'act' => "Actions", + 'interface' => "Interfaces", + 'proto' => "Protocols", + 'srcip' => "Source IPs", + 'dstip' => "Destination IPs", + 'srcport' => "Source Ports", + 'dstport' => "Destination Ports"); + +$summary = array(); +foreach (array_keys($fields) as $f) { + $summary[$f] = array(); +} $totals = array(); @@ -65,10 +61,10 @@ function cmp($a, $b) { } function stat_block($summary, $stat, $num) { - global $gotlines, $descr; + global $gotlines, $fields; uasort($summary[$stat] , 'cmp'); print ''; - print ""; + print ""; $k = array_keys($summary[$stat]); $total = 0; $numentries = 0; @@ -96,27 +92,24 @@ function stat_block($summary, $stat, $num) { } function pie_block($summary, $stat, $num) { - global $gotlines, $descr; + global $gotlines, $fields; uasort($summary[$stat] , 'cmp'); $k = array_keys($summary[$stat]); $total = 0; $numentries = 0; print "\n"; print "
{$descr[$stat]} data
{$fields[$stat]} data
"; - print ""; + print ""; print "
{$descr[$stat]}
{$fields[$stat]}
\n"; print "
"; } foreach ($filterlog as $fe) { - $summary['actions'][$fe['act']]++; - $summary['ints'][$fe['interface']]++; - $summary['protos'][$fe['proto']]++; - $summary['srcips'][$fe['srcip']]++; - $summary['dstips'][$fe['dstip']]++; + $specialfields = array('srcport', 'dstport'); + foreach (array_keys($fields) as $field) { + if (!in_array($field, $specialfields)) + $summary[$field][$fe[$field]]++; + } + /* Handle some special cases */ if ($fe['srcport']) - $summary['srcports'][$fe['proto'].'/'.$fe['srcport']]++; + $summary['srcport'][$fe['proto'].'/'.$fe['srcport']]++; else - $summary['srcports'][$fe['srcport']]++; + $summary['srcport'][$fe['srcport']]++; if ($fe['dstport']) - $summary['dstports'][$fe['proto'].'/'.$fe['dstport']]++; + $summary['dstport'][$fe['proto'].'/'.$fe['dstport']]++; else - $summary['dstports'][$fe['dstport']]++; + $summary['dstport'][$fe['dstport']]++; } include("head.inc"); ?> + + + +

This is a firewall log summary, of the last lines of the firewall log (Max ).
NOTE: IE8 users must enable compatibility view. -

-

-

-

-

-

-

-

-

-

-

-

-

-

- +
"; + stat_block($summary, $field , $entriesperblock); + echo "

"; +} +?>
-- cgit v1.1