def test_build_alert_hooks(self): warnfile = StringIO.StringIO() patterns_file = InlineStringIO(""" BUG ^.*Kernel panic ?(.*) machine panic'd (%s) BUG ^.*Oops ?(.*) machine Oops'd (%s) """) hooks = monitors_util.build_alert_hooks(patterns_file, warnfile) self.assertEquals(len(hooks), 2)
def main(): (options, args) = parser.parse_args() if len(args) != 2: parser.print_help() sys.exit(1) logfile = open(args[0], 'a', 0) warnfile = os.fdopen(int(args[1]), 'w', 0) # For now we aggregate all the alert_hooks. alert_hooks = [] for patterns_path in options.pattern_paths.split(','): patterns_file = open(patterns_path) alert_hooks.extend( monitors_util.build_alert_hooks(patterns_file, warnfile)) monitors_util.process_input( sys.stdin, logfile, options.log_timestamp_format, alert_hooks)