Created
October 1, 2015 09:57
-
-
Save t-cyrill/46c8460966efd340bd9f to your computer and use it in GitHub Desktop.
sidekiq enqueued check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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