aboutsummaryrefslogtreecommitdiffstats
path: root/logd/src
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-04-08 11:44:40 +0000
committerArne Juul <arnej@verizonmedia.com>2020-04-08 11:44:40 +0000
commit59f2c782fe66711b733a48bcdcad22fe37f25197 (patch)
tree4d2771160c5b3bbf02f5a279be5a64617e793149 /logd/src
parent5b579dfe5d26c10da7450fdf90f6da2499b8aba1 (diff)
remove latest vespa.log if it is filling the disk too quickly
Diffstat (limited to 'logd/src')
-rw-r--r--logd/src/logd/watcher.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/logd/src/logd/watcher.cpp b/logd/src/logd/watcher.cpp
index e481d64f721..036ef09bee6 100644
--- a/logd/src/logd/watcher.cpp
+++ b/logd/src/logd/watcher.cpp
@@ -116,6 +116,7 @@ void
Watcher::watchfile()
{
struct donecache already;
+ char newfn[FILENAME_MAX];
char *target = getenv("VESPA_LOG_TARGET");
if (target == nullptr || strncmp(target, "file:", 5) != 0) {
@@ -222,6 +223,12 @@ Watcher::watchfile()
} else {
LOG(debug, "logfile rotation complete after %2.3f s", vespalib::to_s(rotTime));
}
+ if (((now - created) < (rotTime + 300s))
+ && (sb.st_size > (1.1 * _confsubscriber.getRotateSize())))
+ {
+ LOG(warning, "logfile spamming, aggressively removing %s", newfn);
+ unlink(newfn);
+ }
created = now;
rotate = false;
close(_wfd);
@@ -240,7 +247,6 @@ Watcher::watchfile()
rotTimer = vespalib::Timer();
LOG(debug, "preparing to rotate logfile, old logfile size %d, age %2.3f seconds",
(int)offset, vespalib::to_s(now-created));
- char newfn[FILENAME_MAX];
int l = strlen(filename);
strcpy(newfn, filename);
time_t seconds = vespalib::count_s(now.time_since_epoch());