Compare commits
2 commits
afdb389214
...
36dd1b7973
Author | SHA1 | Date | |
---|---|---|---|
|
36dd1b7973 | ||
|
20e5fc23ca |
2 changed files with 45 additions and 14 deletions
32
README.md
32
README.md
|
@ -1,24 +1,38 @@
|
||||||
Nagios plugin to check Git Repository status
|
# Nagios plugin to check Git Repository status
|
||||||
============================================
|
|
||||||
|
|
||||||
Usage
|
## Installation
|
||||||
-----
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage : check_git_config -g [directory] [-c|-r remote] [-d]
|
apt-get install git
|
||||||
|
git clone https://gitea.zionetrix.net/bn8/check_git_config.git /usr/local/src/check_git_config
|
||||||
|
mkdir -p /usr/local/lib/nagios/plugins
|
||||||
|
ln -s /usr/local/src/check_git_config/check_git_config /usr/local/lib/nagios/plugins/
|
||||||
|
|
||||||
|
# To add check on /var/www/website status (owned by www-data)
|
||||||
|
echo "nagios ALL= (www-data) NOPASSWD: /usr/local/lib/nagios/plugins/check_git_config -g /var/www/website" > /etc/sudoers.d/nagios-git-website
|
||||||
|
chmod 0400 /etc/sudoers.d/nagios-git-website
|
||||||
|
echo "command[check_git_website]=sudo -u www-data /usr/local/lib/nagios/plugins/check_git_config -g /var/www/website" > /etc/nagios/nrpe.d/git-website.cfg
|
||||||
|
service nagios-nrpe-server reload
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage : check_git_config -g [directory] [-c|-r remote] [-d]
|
||||||
-g [directory] Specify Git root directory (default : /srv/common)
|
-g [directory] Specify Git root directory (default : /srv/common)
|
||||||
-c Check Git remote state
|
-c Check Git remote state
|
||||||
-r [remote] Specify Git remote to check (default : origin)
|
-r [remote] Specify Git remote to check (default : origin)
|
||||||
|
-H Hide detected changes
|
||||||
|
-F Show full diff in case of changes detected (default: short)
|
||||||
-d Enable debug mode
|
-d Enable debug mode
|
||||||
```
|
```
|
||||||
|
|
||||||
Copyright
|
## Copyright
|
||||||
---------
|
|
||||||
|
|
||||||
Copyright (c) 2018 Benjamin Renard
|
Copyright (c) 2018 Benjamin Renard
|
||||||
|
|
||||||
License
|
## License
|
||||||
-------
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License version 2
|
modify it under the terms of the GNU General Public License version 2
|
||||||
|
|
|
@ -11,16 +11,20 @@ GIT_ROOT=/srv/common
|
||||||
GIT_REMOTE=origin
|
GIT_REMOTE=origin
|
||||||
DEBUG=0
|
DEBUG=0
|
||||||
CHECK_REMOTE=0
|
CHECK_REMOTE=0
|
||||||
|
HIDE_CHANGES=0
|
||||||
|
FULL_DIFF=0
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "Usage : $0 -g [directory] [-c|-r remote] [-d]
|
echo "Usage : $0 -g [directory] [-c|-r remote] [-d]
|
||||||
-g [directory] Specify Git root directory (default : $GIT_ROOT)
|
-g [directory] Specify Git root directory (default : $GIT_ROOT)
|
||||||
-c Check Git remote state
|
-c Check Git remote state
|
||||||
-r [remote] Specify Git remote to check (default : $GIT_REMOTE)
|
-r [remote] Specify Git remote to check (default : $GIT_REMOTE)
|
||||||
|
-H Hide detected changes
|
||||||
|
-F Show full diff in case of changes detected (default: short)
|
||||||
-d Enable debug mode"
|
-d Enable debug mode"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "g:r:cdh-:" OPTION
|
while getopts "g:r:cdFHh-:" OPTION
|
||||||
do
|
do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
c)
|
c)
|
||||||
|
@ -36,6 +40,12 @@ do
|
||||||
d)
|
d)
|
||||||
DEBUG=1
|
DEBUG=1
|
||||||
;;
|
;;
|
||||||
|
H)
|
||||||
|
HIDE_CHANGES=1
|
||||||
|
;;
|
||||||
|
F)
|
||||||
|
FULL_DIFF=1
|
||||||
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -66,6 +76,13 @@ then
|
||||||
elif [ -n "$STATUS" ]
|
elif [ -n "$STATUS" ]
|
||||||
then
|
then
|
||||||
echo "WARNING : Git config repo on $( hostname ) not clean"
|
echo "WARNING : Git config repo on $( hostname ) not clean"
|
||||||
|
if [ $FULL_DIFF -eq 1 ]
|
||||||
|
then
|
||||||
|
git diff
|
||||||
|
elif [ $HIDE_CHANGES -ne 1 ]
|
||||||
|
then
|
||||||
|
echo -e "$STATUS"
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
elif [ $CHECK_REMOTE -eq 1 ]
|
elif [ $CHECK_REMOTE -eq 1 ]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in a new issue