[Logcheck-devel] disable message "Log file is smaller"

Andrejs Dubovskis adux at lmt.lv
Tue Aug 20 11:01:33 UTC 2013


Hello!

We have long running process and execute "cat /dev/null > logfile" to control logfile size.
So it is normal case, when a log file is smaller.

We would like to introduce new flag to disable the warning message.

Please, accept the attached patch.

--- /usr/sbin/logtail	2010-09-03 11:25:15.000000000 +0300
+++ logtail	2013-08-20 12:38:22.000000000 +0300
@@ -27,7 +27,7 @@
 
 # process args and switches
 my ($TEST_MODE) = 0;
-getopts("f:o:t", \%opts);
+getopts("f:o:t:r", \%opts);
 
 # try to detect plain logtail invocation without switches
 if (!$opts{f} && $#ARGV != 0 && $#ARGV != 1) {
@@ -84,7 +84,8 @@
 
     if ($inode == $ino) {
         exit 0 if $offset == $size; # short cut
-        if ($offset > $size) {
+        # print out a warning if the file size was reduced and the warning is not disabled
+        if ($offset > $size && !$opts{r}) {
             $offset = 0;
             print "***************\n";
             print "*** WARNING ***: Log file $logfile is smaller than last time checked!\n";



More information about the Logcheck-devel mailing list