Last active
August 29, 2015 14:16
-
-
Save jrohland/1f7ec0d49c633782bf5d to your computer and use it in GitHub Desktop.
Sensu plugin for checking yarn for running application
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 | |
# | |
# Check yarn for running application | |
# | |
# === | |
# | |
# Examples: | |
# | |
# # check by application name | |
# check-yarn.sh -a JobName | |
# | |
# Date: 2015-03-02 | |
# Author: Jesse Rohland <jesse.rohland@gmail.com> | |
# | |
# Released under the same terms as Sensu (the MIT license); see LICENSE | |
# for details. | |
# get arguments | |
while getopts 'a:h' OPT; do | |
case $OPT in | |
a) APPLICATION=$OPTARG;; | |
h) hlp="yes";; | |
*) unknown="yes";; | |
esac | |
done | |
# usage | |
HELP=" | |
usage: $0 [ -a value -h ] | |
-a --> application name | |
-h --> print this help screen | |
" | |
if [ "$hlp" = "yes" ]; then | |
echo "$HELP" | |
exit 0 | |
fi | |
if [ ${APPLICATION} ]; then | |
ret=`yarn application -list -appStates RUNNING | grep "${APPLICATION}"` | |
if [ ! "${ret}" ]; then | |
echo "CRITICAL - application ${APPLICATION} does not exist" | |
exit 2 | |
fi | |
echo "APPLICATION OK - ${APPLICATION}" | |
exit 0 | |
fi | |
echo "$HELP" | |
exit 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment