Compare commits
No commits in common. "36dd1b797321024343c59e7d009b98d9fad2bcff" and "afdb3892145c817445a2390670d009c5cb446341" have entirely different histories.
36dd1b7973
...
afdb389214
2 changed files with 14 additions and 45 deletions
30
README.md
30
README.md
|
@ -1,38 +1,24 @@
|
|||
# Nagios plugin to check Git Repository status
|
||||
Nagios plugin to check Git Repository status
|
||||
============================================
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
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
|
||||
-----
|
||||
|
||||
```
|
||||
Usage : check_git_config -g [directory] [-c|-r remote] [-d]
|
||||
-g [directory] Specify Git root directory (default : /srv/common)
|
||||
-c Check Git remote state
|
||||
-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
|
||||
```
|
||||
|
||||
## Copyright
|
||||
Copyright
|
||||
---------
|
||||
|
||||
Copyright (c) 2018 Benjamin Renard
|
||||
|
||||
## License
|
||||
License
|
||||
-------
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
|
|
|
@ -11,20 +11,16 @@ GIT_ROOT=/srv/common
|
|||
GIT_REMOTE=origin
|
||||
DEBUG=0
|
||||
CHECK_REMOTE=0
|
||||
HIDE_CHANGES=0
|
||||
FULL_DIFF=0
|
||||
|
||||
function usage() {
|
||||
echo "Usage : $0 -g [directory] [-c|-r remote] [-d]
|
||||
-g [directory] Specify Git root directory (default : $GIT_ROOT)
|
||||
-c Check Git remote state
|
||||
-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"
|
||||
}
|
||||
|
||||
while getopts "g:r:cdFHh-:" OPTION
|
||||
while getopts "g:r:cdh-:" OPTION
|
||||
do
|
||||
case "$OPTION" in
|
||||
c)
|
||||
|
@ -40,12 +36,6 @@ do
|
|||
d)
|
||||
DEBUG=1
|
||||
;;
|
||||
H)
|
||||
HIDE_CHANGES=1
|
||||
;;
|
||||
F)
|
||||
FULL_DIFF=1
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
|
@ -76,13 +66,6 @@ then
|
|||
elif [ -n "$STATUS" ]
|
||||
then
|
||||
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
|
||||
elif [ $CHECK_REMOTE -eq 1 ]
|
||||
then
|
||||
|
|
Loading…
Reference in a new issue