MAX_LINES = 10
ALERT_INTERVAL = 86400
-logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s',
- level=logging.INFO,
- datefmt='%m/%d/%Y %H:%M:%S')
-
parser = argparse.ArgumentParser(description='Alert on excessive number of error log lines.')
parser.add_argument('logfile', type=str, help='logfile to be watched')
parser.add_argument('handler', type=str,
help='sample interval size in seconds (default: 600)')
parser.add_argument('-n', '--num-intervals', type=int, default=6, dest='num_intervals',
help='number of intervals to keep in history (default: 6)')
+parser.add_argument('-l', '--log-level', type=str, default='INFO', dest='log_lvl',
+ choices=['DEBUG', 'INFO', 'WARNING'], help='select log level')
args = parser.parse_args()
+logging.basicConfig(format='[%(asctime)s] %(levelname)s: %(message)s',
+ level=logging.getLevelName(args.log_lvl),
+ datefmt='%m/%d/%Y %H:%M:%S')
+
kept_times = []
lines = []
last_slot_time = None