Added some additional checks and variables
This commit is contained in:
parent
dba0ec87de
commit
3d22824472
@ -7,21 +7,43 @@
|
|||||||
# > nagios ALL=(root) NOPASSWD: /usr/local/lib/nagios/plugins/check_git_status /etc
|
# > nagios ALL=(root) NOPASSWD: /usr/local/lib/nagios/plugins/check_git_status /etc
|
||||||
# should do the job.
|
# should do the job.
|
||||||
|
|
||||||
|
STATE_OK=0
|
||||||
|
STATE_WARNING=1
|
||||||
|
STATE_CRITICAL=2
|
||||||
|
STATE_UNKNOWN=3
|
||||||
|
|
||||||
|
GIT="/usr/bin/git"
|
||||||
|
|
||||||
REPO="${1}"
|
REPO="${1}"
|
||||||
|
|
||||||
if [ -z "${REPO}" -o ! -d "${REPO}" ]
|
if [ ! -x ${GIT} ]
|
||||||
then
|
then
|
||||||
echo 'No repo specified or no such repo';
|
echo "Can't execute ${GIT}"
|
||||||
exit 3
|
exit $STATE_UNKNOWN
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${REPO}" || exit 3
|
if [ $# -lt 1 ]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 <repo>"
|
||||||
|
exit $STATE_UNKNOWN
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$(git ls-files --modified --deleted --others --exclude-standard)" ]
|
if [ -z "${REPO}/.git" -o ! -d "${REPO}/.git" ]
|
||||||
|
then
|
||||||
|
echo "No repo specified or ${REPO} is not a git repo";
|
||||||
|
exit $STATE_UNKNOWN
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "${REPO}" || exit $STATE_UNKNOWN
|
||||||
|
|
||||||
|
if [ -z "$(${GIT} ls-files --modified --deleted --others --exclude-standard)" ]
|
||||||
then
|
then
|
||||||
echo "No uncommited changes in ${REPO}"
|
echo "No uncommited changes in ${REPO}"
|
||||||
exit 0
|
exit $STATE_OK
|
||||||
else
|
else
|
||||||
echo "Uncommited changes in ${REPO}"
|
echo "Uncommited changes in ${REPO}"
|
||||||
exit 1
|
exit $STATE_WARNING
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Someting went wrong"
|
||||||
|
exit $STATE_UNKNOWN
|
||||||
|
Loading…
x
Reference in New Issue
Block a user