check_systemd_service: handle nfs mounts

This commit is contained in:
Cyberes 2024-09-17 18:56:27 -06:00
parent 2055e4161e
commit 0eab3624e8
1 changed files with 9 additions and 4 deletions

View File

@ -77,18 +77,23 @@ current_time=$(date +%s)
start_time_diff_perf="" start_time_diff_perf=""
end_time_diff_perf="" end_time_diff_perf=""
if [ -n "$start_time" ] && [ "$start_time" != "n/a" ]; then start_time_str=""
if [ -n "$start_time" ] && [ "$start_time" != "n/a" ] && [ -z "$start_time" ]; then
start_time_diff=$((current_time - $(date -d "$start_time" +%s))) start_time_diff=$((current_time - $(date -d "$start_time" +%s)))
start_time_diff_perf="| uptime=${start_time_diff}s" start_time_diff_perf="| uptime=${start_time_diff}s"
start_time_str=" Started at $start_time."
fi fi
if [ -n "$end_time" ] && [ "$end_time" != "n/a" ]; then
end_time_str=""
if [ -n "$end_time" ] && [ "$end_time" != "n/a" ] && [ -z "$end_time" ]; then
end_time_diff=$((current_time - $(date -d "$end_time" +%s))) end_time_diff=$((current_time - $(date -d "$end_time" +%s)))
end_time_diff_perf="| downtime=${end_time_diff}s" end_time_diff_perf="| downtime=${end_time_diff}s"
end_time_str=" Exited at $end_time."
fi fi
if [ "$IS_TIMER" = true ] && { [ "$substate" = "exited" ] || [ "$active" = "inactive" ]; }; then if [ "$IS_TIMER" = true ] && { [ "$substate" = "exited" ] || [ "$active" = "inactive" ]; }; then
echo "OK - $UNIT_NAME is active and exited (returned $exit_code) and enabled. Exited at $end_time. $end_time_diff_perf" echo "OK - $UNIT_NAME is active and exited (returned $exit_code) and enabled.$end_time_str $end_time_diff_perf"
else else
echo "OK - $UNIT_NAME is active and enabled. Started at $start_time. $start_time_diff_perf" echo "OK - $UNIT_NAME is active and enabled.$start_time_str $start_time_diff_perf"
fi fi
exit 0 exit 0