From c7a3356e6bfb67b1b617eaeddd5983ddae901759 Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 26 Dec 2013 15:25:46 -0500 Subject: Add a setting to allow the user to specify the clog file size so more (or less) entries may be kept in the raw logs. Retain previous default size values if the user has not specified a preferred size. Files can only be resized when initialized, so provide a "Reset All Logs" button as well to force clear all logs and set them up at the new size. --- usr/local/www/diag_logs_settings.php | 31 ++++++++++++++++++++++++++++++- usr/local/www/guiconfig.inc | 26 ++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 5 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/diag_logs_settings.php b/usr/local/www/diag_logs_settings.php index b1eef64..b7ba070 100755 --- a/usr/local/www/diag_logs_settings.php +++ b/usr/local/www/diag_logs_settings.php @@ -71,6 +71,7 @@ $pconfig['loglighttpd'] = !isset($config['syslog']['nologlighttpd']); $pconfig['rawfilter'] = isset($config['syslog']['rawfilter']); $pconfig['filterdescriptions'] = $config['syslog']['filterdescriptions']; $pconfig['disablelocallogging'] = isset($config['syslog']['disablelocallogging']); +$pconfig['logfilesize'] = $config['syslog']['logfilesize']; if (!$pconfig['nentries']) $pconfig['nentries'] = 50; @@ -82,7 +83,9 @@ function is_valid_syslog_server($target) { || is_hostnamewithport($target)); } -if ($_POST) { +if ($_POST['resetlogs'] == gettext("Reset Log Files")) { + clear_all_log_files(); +} elseif ($_POST) { unset($input_errors); $pconfig = $_POST; @@ -102,9 +105,15 @@ if ($_POST) { $input_errors[] = gettext("Number of log entries to show must be between 5 and 2000."); } + if (isset($_POST['logfilesize']) && (strlen($_POST['logfilesize']) > 0)) { + if (!is_numeric($_POST['logfilesize']) || ($_POST['logfilesize'] < 5120)) { + $input_errors[] = gettext("Log file size must be a positive integer greater than 5120."); + } + } if (!$input_errors) { $config['syslog']['reverse'] = $_POST['reverse'] ? true : false; $config['syslog']['nentries'] = (int)$_POST['nentries']; + $config['syslog']['logfilesize'] = (int)$_POST['logfilesize']; $config['syslog']['remoteserver'] = $_POST['remoteserver']; $config['syslog']['remoteserver2'] = $_POST['remoteserver2']; $config['syslog']['remoteserver3'] = $_POST['remoteserver3']; @@ -276,6 +285,18 @@ function check_everything() { + Log File Size + +
+ +

+ + + . + . + + + Log Firewall Default Blocks /> @@ -324,6 +345,14 @@ function check_everything() { + Reset Logs + + " onclick="return confirm('')" /> +

+ + + +   diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index d5a9cf7..1997ac5 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -543,19 +543,37 @@ function update_changedesc($update) { $changecount++; } -function clear_log_file($logfile = "/var/log/system.log") { +function clear_log_file($logfile = "/var/log/system.log", $restart_syslogd = true) { global $config, $g; - exec("/usr/bin/killall syslogd"); + if ($restart_syslogd) + exec("/usr/bin/killall syslogd"); if(isset($config['system']['disablesyslogclog'])) { unlink($logfile); touch($logfile); } else { + $log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "511488"; if(isset($config['system']['usefifolog'])) - exec("/usr/sbin/fifolog_create -s 511488 {$logfile}"); + exec("/usr/sbin/fifolog_create -s {$log_size} {$logfile}"); else - exec("/usr/sbin/clog -i -s 511488 {$logfile}"); + exec("/usr/sbin/clog -i -s {$log_size} {$logfile}"); + } + if ($restart_syslogd) + system_syslogd_start(); +} + +function clear_all_log_files() { + global $g; + exec("/usr/bin/killall syslogd"); + + $log_files = array("system", "filter", "dhcpd", "vpn", "pptps", "poes", "l2tps", "openvpn", "portalauth", "ipsec", "ppp", "relayd", "wireless", "lighttpd", "ntpd", "gateways", "resolver", "routing"); + foreach ($log_files as $lfile) { + clear_log_file("{$g['varlog_path']}/{$lfile}.log", false); } + system_syslogd_start(); + killbyname("dhcpd"); + services_dhcpd_configure(); + return; } function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") { -- cgit v1.1