print execd withen error happens
This commit is contained in:
parent
b528868249
commit
798ee6bcd2
|
@ -26,36 +26,41 @@ def get_next_elapse(timer_name):
|
||||||
lines = output.split('\n')
|
lines = output.split('\n')
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if timer_name in line:
|
if timer_name in line:
|
||||||
parts = re.search(SYSTEMCTL_TIMERS_RE, line)
|
try:
|
||||||
|
parts = re.search(SYSTEMCTL_TIMERS_RE, line)
|
||||||
|
|
||||||
datetime_object = None
|
datetime_object = None
|
||||||
if parts.group(2):
|
if parts.group(2):
|
||||||
try:
|
try:
|
||||||
datetime_object = datetime.strptime(parts.group(2), '%a %Y-%m-%d %H:%M:%S %Z')
|
datetime_object = datetime.strptime(parts.group(2), '%a %Y-%m-%d %H:%M:%S %Z')
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return None, e
|
return None, e
|
||||||
|
|
||||||
time_left = 'n/a'
|
time_left = 'n/a'
|
||||||
if parts.group(4):
|
if parts.group(4):
|
||||||
time_left = parse_systemctl_time_delta(parts.group(4))
|
time_left = parse_systemctl_time_delta(parts.group(4))
|
||||||
if isinstance(time_left, humanfriendly.InvalidTimespan):
|
if isinstance(time_left, humanfriendly.InvalidTimespan):
|
||||||
return None, humanfriendly.InvalidTimespan
|
return None, humanfriendly.InvalidTimespan
|
||||||
|
|
||||||
time_passed = 'n/a'
|
time_passed = 'n/a'
|
||||||
if parts.group(9):
|
if parts.group(9):
|
||||||
time_passed = parse_systemctl_time_delta(parts.group(9))
|
time_passed = parse_systemctl_time_delta(parts.group(9))
|
||||||
if isinstance(time_passed, humanfriendly.InvalidTimespan):
|
if isinstance(time_passed, humanfriendly.InvalidTimespan):
|
||||||
return None, humanfriendly.InvalidTimespan
|
return None, humanfriendly.InvalidTimespan
|
||||||
|
|
||||||
timer_info = {
|
timer_info = {
|
||||||
'next': datetime_object,
|
'next': datetime_object,
|
||||||
'left': time_left,
|
'left': time_left,
|
||||||
'last': parts.group(7),
|
'last': parts.group(7),
|
||||||
'passed': time_passed,
|
'passed': time_passed,
|
||||||
'unit': parts.group(10),
|
'unit': parts.group(10),
|
||||||
'activates': parts.group(12)
|
'activates': parts.group(12)
|
||||||
}
|
}
|
||||||
return timer_info, None
|
return timer_info, None
|
||||||
|
except Exception:
|
||||||
|
print(output)
|
||||||
|
traceback.print_exc()
|
||||||
|
sys.exit(nagios.STATE_UNKNOWN)
|
||||||
return None, ValueError('Timer not found')
|
return None, ValueError('Timer not found')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return None, e
|
return None, e
|
||||||
|
|
Loading…
Reference in New Issue