summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2013-12-26 15:25:46 -0500
committerjim-p <jimp@pfsense.org>2013-12-26 15:27:40 -0500
commitc7a3356e6bfb67b1b617eaeddd5983ddae901759 (patch)
treee09ecd7c88d121c9c3559dc9fb39de73a9b87f8f
parent7b03748b37503e11fcb92075a375305fb06c9366 (diff)
downloadpfsense-c7a3356e6bfb67b1b617eaeddd5983ddae901759.zip
pfsense-c7a3356e6bfb67b1b617eaeddd5983ddae901759.tar.gz
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.
-rw-r--r--etc/inc/system.inc4
-rwxr-xr-xetc/rc10
-rwxr-xr-xusr/local/www/diag_logs_settings.php31
-rwxr-xr-xusr/local/www/guiconfig.inc26
4 files changed, 62 insertions, 9 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 4761fba..1dfbeb7 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -627,11 +627,11 @@ function system_syslogd_start() {
$log_size = "";
} else if (isset($config['system']['usefifolog'])) {
$log_directive = "|/usr/sbin/fifolog_writer ";
- $log_size = "10240";
+ $log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "10240";
$log_create_directive = "/usr/sbin/fifolog_create -s ";
} else { // Defaults to CLOG
$log_directive = "%";
- $log_size = "10240";
+ $log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "10240";
$log_create_directive = "/usr/sbin/clog -i -s ";
}
diff --git a/etc/rc b/etc/rc
index 95b73b0..a1d6f81 100755
--- a/etc/rc
+++ b/etc/rc
@@ -301,6 +301,12 @@ echo -n "."
DISABLESYSLOGCLOG=`/usr/bin/grep -c disablesyslogclog /cf/conf/config.xml`
ENABLEFIFOLOG=`/usr/bin/grep -c usefifolog /cf/conf/config.xml`
LOG_FILES="system filter dhcpd vpn pptps poes l2tps openvpn portalauth ipsec ppp relayd wireless lighttpd ntpd gateways resolver routing"
+
+DEFAULT_LOG_FILE_SIZE=`/usr/local/bin/xmllint --xpath 'string(//pfsense/syslog/logfilesize)' /conf/config.xml`
+if [ ! ${DEFAULT_LOG_FILE_SIZE} ]; then
+ DEFAULT_LOG_FILE_SIZE=511488
+fi
+
for logfile in $LOG_FILES; do
if [ "$DISABLESYSLOGCLOG" -gt "0" ]; then
/usr/bin/touch /var/log/$logfile.log
@@ -308,9 +314,9 @@ for logfile in $LOG_FILES; do
if [ ! -f /var/log/$logfile.log ]; then
if [ "$ENABLEFIFOLOG" -gt "0" ]; then
# generate fifolog files
- /usr/sbin/fifolog_create -s 511488 /var/log/$logfile.log
+ /usr/sbin/fifolog_create -s ${DEFAULT_LOG_FILE_SIZE} /var/log/$logfile.log
else
- /usr/sbin/clog -i -s 512144 /var/log/$logfile.log
+ /usr/sbin/clog -i -s ${DEFAULT_LOG_FILE_SIZE} /var/log/$logfile.log
fi
fi
fi
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() {
<?=gettext("Hint: This is only the number of log entries displayed in the GUI. It does not affect how many entries are contained in the actual log files.") ?></td>
</tr>
<tr>
+ <td width="22%" valign="top" class="vtable">Log File Size</td>
+ <td width="78%" class="vtable">
+ <input name="logfilesize" id="logfilesize" type="text" class="formfld unknown" size="8" value="<?=htmlspecialchars($pconfig['logfilesize']);?>" /><br/>
+ <?=gettext("Logs are held in constant-size circular log files. This field controls how large each log file is, and thus how many entries may exist inside the log By default this is approximately 500KB per log file, and there are nearly 20 such log files.") ?>
+ <br/><br/>
+ <?=gettext("NOTE: Log sizes are changed the next time a log file is cleared or deleted. To immediately increase the size of the log files, you must clear all logs using the \"Reset Log Files\" option farther down this page. "); ?>
+ <?=gettext("Be aware that increasing this value increases every log file size, so disk usage will increase significantly."); ?>
+ <?=gettext("Disk space currently used by log files: ") ?><?= exec("/usr/bin/du -sh /var/log | /usr/bin/awk '{print $1;}'"); ?>.
+ <?=gettext("Remaining disk space for log files: ") ?><?= exec("/bin/df -h /var/log | /usr/bin/awk '{print $4;}'"); ?>.
+ </td>
+ </tr>
+ <tr>
<td valign="top" class="vtable">Log Firewall Default Blocks</td>
<td class="vtable">
<input name="logdefaultblock" type="checkbox" id="logdefaultblock" value="yes" <?php if ($pconfig['logdefaultblock']) echo "checked=\"checked\""; ?> />
@@ -324,6 +345,14 @@ function check_everything() {
<?php endif; ?>
</tr>
<tr>
+ <td width="22%" valign="top">Reset Logs</td>
+ <td width="78%">
+ <input name="resetlogs" type="submit" class="formbtn" value="<?=gettext("Reset Log Files"); ?>" onclick="return confirm('<?=gettext('Do you really want to reset the log files? This will erase all local log data.');?>')" />
+ <br/><br/>
+ <?= gettext("Note: Clears all local log files and reinitializes them as empty logs. This also restarts the DHCP daemon."); ?>
+ </td>
+ </tr>
+ <tr>
<td colspan="2" valign="top">&nbsp;</td>
</tr>
<tr>
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 = "") {
OpenPOWER on IntegriCloud