minor adjustments to check_systemd things
This commit is contained in:
parent
76b1ef24b7
commit
cc7044a100
|
@ -42,7 +42,7 @@ if [ -z "$UNIT_NAME" ]; then
|
|||
fi
|
||||
|
||||
# Check if the unit exists
|
||||
if ! systemctl list-units --full -all | grep -Fq "\b$UNIT_NAME.service\b"; then
|
||||
if ! systemctl list-units --full -all 2>/dev/null | grep -Pq "\b$UNIT_NAME\b"; then
|
||||
echo "CRITICAL - $UNIT_NAME does not exist"
|
||||
exit 2
|
||||
fi
|
||||
|
|
|
@ -17,7 +17,8 @@ sys.path.insert(0, "/usr/lib/python3/dist-packages")
|
|||
import dbus
|
||||
|
||||
SYSTEMCTL_TIMERS_RE = re.compile(
|
||||
r'^(([A-Za-z]*\s[0-9]{4}-[0-9]{2}-[0-9]{2}\s*[0-9]{2}:[0-9]{2}:[0-9]{2}\s[A-Z]*)|n\/a|-)\s*((([0-9]*[a-z]*\s)*left)|n\/a|-)\s*(([A-Za-z]*\s[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[A-Z]*)|n\/a|-)\s*(([0-9A-Za-z\s]*\sago)|n\/a|-)\s*([A-Za-z\-_]*.timer)\s*(([A-Za-z\-_]*.service)|\s*)')
|
||||
r'^(([A-Za-z]*\s[0-9]{4}-[0-9]{2}-[0-9]{2}\s*[0-9]{2}:[0-9]{2}:[0-9]{2}\s[A-Z]*)|n\/a|-)\s*((([0-9]*[a-z]*\s)*left)|n\/a|-)\s*(([A-Za-z]*\s[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[A-Z]*)|n\/a|-)\s*(([0-9A-Za-z\s]*\sago)|n\/a|-)\s*([A-Za-z\-_]*.timer)\s*(([A-Za-z\-_]*.service)|\s*)'
|
||||
)
|
||||
|
||||
|
||||
def get_next_elapse(timer_name):
|
||||
|
@ -115,9 +116,9 @@ def check_timer(timer_name):
|
|||
}
|
||||
quit_check(f'{timer_name} is active. Trigger time: {next_elapse_str}. Remaining time: {remaining_time_human}. Time since last trigger: {passed_time_human}.', nagios.STATE_OK, perfdata_dict)
|
||||
else:
|
||||
quit_check(f'{timer_name} is not active.', nagios.STATE_CRIT)
|
||||
quit_check(f'{timer_name} is not active', nagios.STATE_CRIT)
|
||||
except dbus.exceptions.DBusException:
|
||||
quit_check(f'{timer_name} could not be found.', nagios.STATE_CRIT)
|
||||
quit_check(f'{timer_name} does not exist', nagios.STATE_CRIT)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue