Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sidekiq enqueued check
#!/bin/bash
PROJECT_ROOT="/var/www/current"
WARN_LIMIT=64
CRIT_LIMIT=128
export RAILS_ENV=production
### rbenvを使う場合、RBENV_ROOTとPATHを適切に設定する必要がある
# export RBENV_ROOT="/usr/local/rbenv"
# export PATH="${RBENV_ROOT}/bin:${RBENV_ROOT}/shims:${PATH}"
# eval "$(rbenv init -)"
cd $PROJECT_ROOT
ENQUEUED=`bundle exec rails runner 'puts Sidekiq::Stats.new.enqueued' 2>/dev/null`
if [ "$ENQUEUED" -ge "$CRIT_LIMIT" ]; then
echo "Enqueued jobs = $ENQUEUED > Critical limit $CRIT_LIMIT"
exit 2
elif [ "$ENQUEUED" -ge "$WARN_LIMIT" ]; then
echo "Enqueued jobs = $ENQUEUED > Warning limit $WARN_LIMIT"
exit 1
else
echo "Enqueued jobs = $ENQUEUED OK"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.