Skip to content

Commit

Permalink
Add warning if NRestarts > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
eaudetcobello committed May 2, 2024
1 parent e425bd6 commit 1eca07f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion k8s/scripts/inspect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ function collect_service_diagnostics {

systemctl status "snap.$service" &>"$status_file"

printf -- "%s $(systemctl show "snap.$service" -p NRestarts)\n" "$service" >>"$INSPECT_DUMP/nrestarts.log"
local n_restarts
n_restarts=$(systemctl show "snap.$service" -p NRestarts | cut -d'=' -f2)

printf -- "%s NRestarts=%s" "$service" "$n_restarts" >> "$INSPECT_DUMP/nrestarts.log"

if [[ $n_restarts -gt 0 ]]; then
log_warning "Service $service has restarted $n_restarts times due to errors."
fi

journalctl -n 100000 -u "snap.$service" &>"$INSPECT_DUMP/$service/journal.log"
}
Expand Down

0 comments on commit 1eca07f

Please sign in to comment.