diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-01-05 17:08:32 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-01-05 17:08:32 +0100 |
commit | e820134d38c3b7470ea5112f40a6dc967f039878 (patch) | |
tree | f05a5cefe285d060aa0ebf52829bcfcd35549f8b /modules/private/monitoring/plugins/check_git | |
parent | b22ce4895ef1e9723a02061f7293e528cfbf9754 (diff) | |
download | Nix-e820134d38c3b7470ea5112f40a6dc967f039878.tar.gz Nix-e820134d38c3b7470ea5112f40a6dc967f039878.tar.zst Nix-e820134d38c3b7470ea5112f40a6dc967f039878.zip |
Add monitoring host
Diffstat (limited to 'modules/private/monitoring/plugins/check_git')
-rwxr-xr-x | modules/private/monitoring/plugins/check_git | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/modules/private/monitoring/plugins/check_git b/modules/private/monitoring/plugins/check_git new file mode 100755 index 0000000..8c09925 --- /dev/null +++ b/modules/private/monitoring/plugins/check_git | |||
@@ -0,0 +1,68 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | SSH_KEY="$1" | ||
4 | |||
5 | TMPDIR=$(mktemp -d) | ||
6 | |||
7 | if [ ! -d "$TMPDIR" ]; then | ||
8 | echo "gitolite UNKNOWN - impossible to create temp dir" | ||
9 | exit 3 | ||
10 | fi | ||
11 | |||
12 | trap "rm -rf $TMPDIR" EXIT | ||
13 | |||
14 | ERRORS="" | ||
15 | OUTPUT="" | ||
16 | |||
17 | cd "$TMPDIR" | ||
18 | OUT=$(git clone -q git://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1) | ||
19 | ERR=$? | ||
20 | if [ -n "$OUT" ]; then | ||
21 | OUTPUT="$OUTPUT | ||
22 | $OUT" | ||
23 | fi | ||
24 | if [ "$ERR" != 0 ]; then | ||
25 | ERRORS="$ERRORS git://" | ||
26 | fi | ||
27 | rm -rf Monitor | ||
28 | |||
29 | OUT=$(git clone -q http://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1) | ||
30 | ERR=$? | ||
31 | if [ -n "$OUT" ]; then | ||
32 | OUTPUT="$OUTPUT | ||
33 | $OUT" | ||
34 | fi | ||
35 | if [ "$ERR" != 0 ]; then | ||
36 | ERRORS="$ERRORS http://" | ||
37 | fi | ||
38 | rm -rf Monitor | ||
39 | |||
40 | OUT=$(git clone -q https://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1) | ||
41 | ERR=$? | ||
42 | if [ -n "$OUT" ]; then | ||
43 | OUTPUT="$OUTPUT | ||
44 | $OUT" | ||
45 | fi | ||
46 | if [ "$ERR" != 0 ]; then | ||
47 | ERRORS="$ERRORS https://" | ||
48 | fi | ||
49 | rm -rf Monitor | ||
50 | |||
51 | OUT=$(GIT_SSH_COMMAND="ssh -i $SSH_KEY -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no" git clone -q gitolite@git.immae.eu:perso/Immae/Projets/Ruby/Monitor 2>&1) | ||
52 | ERR=$? | ||
53 | if [ -n "$OUT" ]; then | ||
54 | OUTPUT="$OUTPUT | ||
55 | $OUT" | ||
56 | fi | ||
57 | if [ "$ERR" != 0 ]; then | ||
58 | ERRORS="$ERRORS ssh" | ||
59 | fi | ||
60 | rm -rf Monitor | ||
61 | |||
62 | if [ -n "$ERRORS" ]; then | ||
63 | echo "gitolite CRITICAL - impossible to clone via$ERRORS|$OUTPUT" | ||
64 | exit 2 | ||
65 | else | ||
66 | echo "gitolite OK - ssh, git, http and https work|$OUTPUT" | ||
67 | exit 0 | ||
68 | fi | ||