Project

General

Profile

« Previous | Next » 

Revision c9513bad

Added by NOYB NOYB over 9 years ago

Status - System Logs - Consolidate - Firewall Summary View

Update summary view log selection method to same method as firewall and system logs.

View differences:

src/usr/local/www/status_logs_filter_summary.php
60 60
##|*MATCH=status_logs_filter_summary.php*
61 61
##|-PRIV
62 62

  
63
require_once("guiconfig.inc");
64
include_once("filter_log.inc");
63
require_once("status_logs_common.inc");
65 64

  
66
$filter_logfile = "{$g['varlog_path']}/filter.log";
67 65
$lines = 5000;
68 66
$entriesperblock = 5;
69 67

  
70
$filterlog = conv_log_filter($filter_logfile, $lines, $lines);
68

  
69
/*
70
Build a list of allowed log files so we can reject others to prevent the page
71
from acting on unauthorized files.
72
*/
73
$allowed_logs = array(
74
	"filter" => array("name" => "Firewall",
75
		    "shortcut" => "filter"),
76
);
77

  
78
// The logs to display are specified in a GET argument. Default to 'system' logs
79
if (!$_GET['logfile']) {
80
	$logfile = 'filter';
81
	$view = 'normal';
82
} else {
83
	$logfile = $_GET['logfile'];
84
	$view = $_GET['view'];
85
	if (!array_key_exists($logfile, $allowed_logs)) {
86
		/* Do not let someone attempt to load an unauthorized log. */
87
		$logfile = 'filter';
88
		$view = 'normal';
89
	}
90
}
91

  
92
if ($view == 'normal')  { $view_title = gettext("Normal View"); }
93
if ($view == 'dynamic') { $view_title = gettext("Dynamic View"); }
94
if ($view == 'summary') { $view_title = gettext("Summary View"); }
95

  
96

  
97
// Miscellaneous Common - Code
98
miscellaneous_common_code();
99

  
100

  
101
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext($allowed_logs[$logfile]["name"]), $view_title);
102
include("head.inc");
103

  
104
if (!$input_errors && $savemsg) {
105
	print_info_box($savemsg);
106
	$manage_log_active = false;
107
}
108

  
109

  
110
// Tab Array
111
tab_array_logs_common();
112

  
113

  
114
$filterlog = conv_log_filter($logfile_path, $lines, $lines);
71 115
$gotlines = count($filterlog);
72 116
$fields = array(
73 117
	'act'	   => gettext("Actions"),
......
88 132

  
89 133
$totals = array();
90 134

  
135

  
136
foreach ($filterlog as $fe) {
137
	$specialfields = array('srcport', 'dstport');
138
	foreach (array_keys($fields) as $field) {
139
		if (!in_array($field, $specialfields)) {
140
			$summary[$field][$fe[$field]]++;
141
		}
142
	}
143
	/* Handle some special cases */
144
	if ($fe['srcport']) {
145
		$summary['srcport'][$fe['proto'].'/'.$fe['srcport']]++;
146
	} else {
147
		$summary['srcport'][$fe['srcport']]++;
148
	}
149
	if ($fe['dstport']) {
150
		$summary['dstport'][$fe['proto'].'/'.$fe['dstport']]++;
151
	} else {
152
		$summary['dstport'][$fe['dstport']]++;
153
	}
154
}
155

  
156

  
157
print("<br />");
158
$infomsg = sprintf('This is a summary of the last %1$s lines of the firewall log (Max %2$s).', $gotlines, $lines);
159
print_info_box($infomsg, info);
160
?>
161

  
162
<script src="d3pie/d3pie.min.js"></script>
163
<script src="d3pie/d3.min.js"></script>
164

  
165
<?php
166

  
167
$chartnum=0;
168
foreach (array_keys($fields) as $field) {
169
?>
170
<div class="panel panel-default">
171
	<div class="panel-heading"><h2 class="panel-title"><?=$fields[$field]?></h2></div>
172
	<div class="panel-body">
173
		<div id="pieChart<?=$chartnum?>" align="center">
174
<?php
175
			pie_block($summary, $field , $entriesperblock, $chartnum);
176
			stat_block($summary, $field , $entriesperblock);
177
			$chartnum++;
178
?>
179
		</div>
180
	</div>
181
</div>
182
<?php
183
}
184
?>
185

  
186
<?php
91 187
function cmp($a, $b) {
92 188
	if ($a == $b) {
93 189
		return 0;
......
132 228
	print "</table>";
133 229
	print('</div>');
134 230
}
231
?>
135 232

  
233
<?php
136 234
// Create the JSON document for the chart to be displayed
137 235
// Todo: Be good to investigate building this with json_encode and friends some time
138 236
function pie_block($summary, $stat, $num, $chartnum) {
......
248 346
</script>
249 347
<?php
250 348
}
251

  
252
foreach ($filterlog as $fe) {
253
	$specialfields = array('srcport', 'dstport');
254
	foreach (array_keys($fields) as $field) {
255
		if (!in_array($field, $specialfields)) {
256
			$summary[$field][$fe[$field]]++;
257
		}
258
	}
259
	/* Handle some special cases */
260
	if ($fe['srcport']) {
261
		$summary['srcport'][$fe['proto'].'/'.$fe['srcport']]++;
262
	} else {
263
		$summary['srcport'][$fe['srcport']]++;
264
	}
265
	if ($fe['dstport']) {
266
		$summary['dstport'][$fe['proto'].'/'.$fe['dstport']]++;
267
	} else {
268
		$summary['dstport'][$fe['dstport']]++;
269
	}
270
}
271

  
272
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("Firewall"), gettext("Summary View"));
273
$shortcut_section = "firewall";
274
include("head.inc");
275

  
276
$tab_array = array();
277
$tab_array[] = array(gettext("System"), false, "status_logs.php");
278
$tab_array[] = array(gettext("Firewall"), true, "status_logs_filter.php");
279
$tab_array[] = array(gettext("DHCP"), false, "status_logs.php?logfile=dhcpd");
280
$tab_array[] = array(gettext("Portal Auth"), false, "status_logs.php?logfile=portalauth");
281
$tab_array[] = array(gettext("IPsec"), false, "status_logs.php?logfile=ipsec");
282
$tab_array[] = array(gettext("PPP"), false, "status_logs.php?logfile=ppp");
283
$tab_array[] = array(gettext("VPN"), false, "status_logs_vpn.php");
284
$tab_array[] = array(gettext("Load Balancer"), false, "status_logs.php?logfile=relayd");
285
$tab_array[] = array(gettext("OpenVPN"), false, "status_logs.php?logfile=openvpn");
286
$tab_array[] = array(gettext("NTP"), false, "status_logs.php?logfile=ntpd");
287
$tab_array[] = array(gettext("Settings"), false, "status_logs_settings.php");
288
display_top_tabs($tab_array);
289

  
290
$tab_array = array();
291
$tab_array[] = array(gettext("Normal View"), false, "/status_logs_filter.php");
292
$tab_array[] = array(gettext("Dynamic View"), false, "/status_logs_filter_dynamic.php");
293
$tab_array[] = array(gettext("Summary View"), true, "/status_logs_filter_summary.php");
294
display_top_tabs($tab_array, false, 'nav nav-tabs');
295

  
296
print("<br />");
297
$infomsg = sprintf('This is a summary of the last %1$s lines of the firewall log (Max %2$s).', $gotlines, $lines);
298
print_info_box($infomsg, info);
299 349
?>
300 350

  
301
<script src="d3pie/d3pie.min.js"></script>
302
<script src="d3pie/d3.min.js"></script>
303

  
304
<?php
305

  
306
$chartnum=0;
307
foreach (array_keys($fields) as $field) {
308
?>
309
<div class="panel panel-default">
310
	<div class="panel-heading"><h2 class="panel-title"><?=$fields[$field]?></h2></div>
311
	<div class="panel-body">
312
		<div id="pieChart<?=$chartnum?>" align="center">
313 351
<?php
314
			pie_block($summary, $field , $entriesperblock, $chartnum);
315
			stat_block($summary, $field , $entriesperblock);
316
			$chartnum++;
317
?>
318
		</div>
319
	</div>
320
</div>
321
<?php
322
}
323

  
324 352
include("foot.inc");
353
?>

Also available in: Unified diff