From 2f12b1800d04b6f7ac456d5a76093d240cc4c34b Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 26 Sep 2015 12:59:58 +0200 Subject: Provide real reason(s) in log when cache is cleared --- config/squid3/34/swapstate_check.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'config/squid3/34/swapstate_check.php') diff --git a/config/squid3/34/swapstate_check.php b/config/squid3/34/swapstate_check.php index ea9600f3..8b4c46bb 100644 --- a/config/squid3/34/swapstate_check.php +++ b/config/squid3/34/swapstate_check.php @@ -47,12 +47,28 @@ if (isset($settings['harddisk_cache_system']) && $settings['harddisk_cache_syste $diskusedpct = round((($disktotal - $diskfree) / $disktotal) * 100); $swapstate_size = filesize($swapstate); $swapstate_pct = round(($swapstate_size / $disktotal) * 100); - // If the swap.state file is taking up more than 75% disk space, + // If the swap.state file is taking up more than 75% of disk space, // or the drive is 90% full and swap.state is larger than 1GB, // kill it and initiate a rotate to write a fresh copy. + $rotate_reason = ""; + if ($swapstate_pct > 75) { + $rotate_reason .= "$cachedir/swap.state file is taking up more than 75% of disk space. "; + } + if ($diskusedpct > 90) { + $rotate_reason .= "$cachedir filesystem is $diskusedpct pct full. "; + } + if ($swapstate_size > 1024*1024*1024) { + $rotate_reason .= "$cachedir/swap.state is larger than 1GB. "; + } + if ($settings['clear_cache'] == 'on') { + $rotate_reason .= "'Clear Cache on Log Rotate' is enabled in 'Local Cache' settings. "; + } + if ($argv[1] == "clean") { + $rotate_reason .= "Clear cache forced by cronjob. "; + } if (($swapstate_pct > 75) || (($diskusedpct > 90) && ($swapstate_size > 1024*1024*1024)) || $argv[1] == "clean") { squid_dash_z('clean'); - log_error(gettext(sprintf("Squid cache and/or swap.state exceeded size limits. Removing and rotating. File was %d bytes, %d%% of total disk space.", $swapstate_size, $swapstate_pct))); + log_error(gettext(sprintf("$rotate_reason Removing and rotating. File was %d bytes, %d%% of total disk space.", $swapstate_size, $swapstate_pct))); } } ?> -- cgit v1.2.3