43
43
""" % (hostname, scriptname))
44
44
date_last_seen = cur.fetchone()[0]
46
"The script '%s' didn't run on '%s' between %s and %s (last seen %s)"
47
% (scriptname, hostname, completed_from, completed_to, date_last_seen)
46
"The script '%s' didn't run on '%s' between "
47
"%s and %s (last seen %s)"
48
% (scriptname, hostname, completed_from,
49
completed_to, date_last_seen)
51
"The script '%s' didn't run on '%s' between %s and %s"
53
"The script '%s' didn't run on '%s' between %s and %s"
52
54
% (scriptname, hostname, completed_from, completed_to)
57
59
parser = OptionParser(
58
'%prog [options] (username|email) [...]'
60
'%prog [options] (minutes) (host:scriptname) [host:scriptname]'
61
63
logger_options(parser)
63
65
(options, args) = parser.parse_args()
66
parser.error("Must specify at least one host and script")
68
parser.error("Must specify at time in minutes and "
69
"at least one host and script")
68
71
# First argument is the number of minutes into the past
69
72
# we want to look for the scripts on the specified hosts
70
minutes_ago, args = int(args[0]), args[1:]
71
start_date = datetime.now() - timedelta(minutes=minutes_ago)
73
completed_from = strftime("%Y-%m-%d %H:%M:%S", start_date.timetuple())
74
completed_to = strftime("%Y-%m-%d %H:%M:%S", datetime.now().timetuple())
74
minutes_ago, args = int(args[0]), args[1:]
75
start_date = datetime.now() - timedelta(minutes=minutes_ago)
77
completed_from = strftime("%Y-%m-%d %H:%M:%S", start_date.timetuple())
78
completed_to = strftime("%Y-%m-%d %H:%M:%S", datetime.now().timetuple())
81
if len(arg.split(":")) != 2:
84
parser.error("Must specify at time in minutes and "
85
"at least one host and script")
76
87
log = logger(options)
90
101
for hs in hosts_scripts:
91
if not check_script(con, log, hs['hostname'], hs['scriptname'], completed_from, completed_to):
102
if not check_script(con, log, hs['hostname'], hs['scriptname'],
103
completed_from, completed_to):
93
105
return error_found