implement return flag
@@ -31,6 +31,7 @@ type logOpts struct {
WarningOver int `short:"w" long:"warning-over" value-name:"WARNING" description:"Trigger a warning if matched lines is over a number"`
CriticalOver int `short:"c" long:"critical-over" value-name:"CRITICAL" description:"Trigger a critical if matched lines is over a number"`
StateDir string `short:"s" long:"state-dir" value-name:"DIR" description:"Dir to keep state files under"`
+ ReturnContent bool `short:"r" long:"return" description:"Output matched lines"`
}
// Do the plugin
@@ -47,6 +48,7 @@ type cloudwatchLogsPlugin struct {
WarningOver int
CriticalOver int
StateFile string
+ ReturnContent bool
}
func newCloudwatchLogsPlugin(args []string) (*cloudwatchLogsPlugin, error) {
@@ -67,7 +69,10 @@ func newCloudwatchLogsPlugin(args []string) (*cloudwatchLogsPlugin, error) {
Service: service,
LogGroupName: opts.LogGroupName,
Pattern: opts.Pattern,
+ WarningOver: opts.WarningOver,
+ CriticalOver: opts.CriticalOver,
StateFile: getStateFile(opts.StateDir, opts.LogGroupName, args),
+ ReturnContent: opts.ReturnContent,
}, nil
}
@@ -202,7 +207,10 @@ func run(args []string) *checkers.Checker {
}
msg += " for pattern /" + p.Pattern + "/"
if messages != nil {
- return checkers.NewChecker(status, msg+"\n"+strings.Join(messages, ""))
+ if p.ReturnContent {
+ msg += "\n" + strings.Join(messages, "")
+ }
+ return checkers.NewChecker(status, msg)
}
return checkers.NewChecker(checkers.OK, msg)
}
