[check-log] Add skip-previous option
@@ -36,6 +36,7 @@ type logOpts struct {
NoState bool `long:"no-state" description:"Don't use state file and read whole logs"`
Encoding string `long:"encoding" description:"Encoding of log file"`
Missing string `long:"missing" default:"UNKNOWN" value-name:"(CRITICAL|WARNING|OK|UNKNOWN)" description:"Exit status when log files missing"`
+ SkipPrevious bool `long:"skip-previous" description:"Check logs which appended after the plugin starts"`
patternReg []*regexp.Regexp
excludeReg *regexp.Regexp
fileListFromGlob []string
@@ -234,6 +235,10 @@ func (opts *logOpts) searchLog(logFile string) (int64, int64, string, error) {
return 0, 0, "", err
}
+ if !opts.NoState && opts.SkipPrevious && skipBytes == 0 {
+ skipBytes = stat.Size()
+ }
+
rotated := false
if stat.Size() < skipBytes {
rotated = true
