fixed -w flag
This commit is contained in:
parent
0e50791a21
commit
6b3d94141d
@ -40,7 +40,7 @@ def parse_args():
|
|||||||
help='Warn to stderr (as in "send mail") at most once within this time interval (seconds)',
|
help='Warn to stderr (as in "send mail") at most once within this time interval (seconds)',
|
||||||
type=int,
|
type=int,
|
||||||
metavar='warn_interval',
|
metavar='warn_interval',
|
||||||
default=[86400])
|
default=86400)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-L', '--no-lock',
|
'-L', '--no-lock',
|
||||||
@ -184,7 +184,7 @@ def main():
|
|||||||
r.write("\nFalse\n")
|
r.write("\nFalse\n")
|
||||||
res = False
|
res = False
|
||||||
|
|
||||||
previous_runs = []
|
previous_runs = {}
|
||||||
for root, dirs, files in os.walk(os.path.join(args.cachedir[0], args.name[0])):
|
for root, dirs, files in os.walk(os.path.join(args.cachedir[0], args.name[0])):
|
||||||
previous_runs = {
|
previous_runs = {
|
||||||
os.path.join(root, d): datetime.datetime.strptime(d, time_format)
|
os.path.join(root, d): datetime.datetime.strptime(d, time_format)
|
||||||
@ -217,9 +217,9 @@ def main():
|
|||||||
if previous_runs:
|
if previous_runs:
|
||||||
# Not the first failure...
|
# Not the first failure...
|
||||||
oldest = min(previous_runs.values())
|
oldest = min(previous_runs.values())
|
||||||
if now-oldest > datetime.timedelta(seconds=args.warn_interval[0]):
|
if now-oldest > datetime.timedelta(seconds=args.warn_interval):
|
||||||
# we have failed for a long time, send a report
|
# we have failed for a long time, send a report
|
||||||
print("Cronjob is still failing after {} seconds ({} failures)\n".format(args.warn_interval[0], len(previous_runs)))
|
print("Cronjob is still failing after {} seconds ({} failures)\n".format(args.warn_interval, len(previous_runs)))
|
||||||
print_runs(previous_runs.keys())
|
print_runs(previous_runs.keys())
|
||||||
else:
|
else:
|
||||||
# Within limits, save the output for a later instance
|
# Within limits, save the output for a later instance
|
||||||
|
Loading…
Reference in New Issue
Block a user