aboutsummaryrefslogtreecommitdiff
path: root/modules/private/monitoring/plugins/check_git
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-01-05 17:08:32 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-01-05 17:08:32 +0100
commite820134d38c3b7470ea5112f40a6dc967f039878 (patch)
treef05a5cefe285d060aa0ebf52829bcfcd35549f8b /modules/private/monitoring/plugins/check_git
parentb22ce4895ef1e9723a02061f7293e528cfbf9754 (diff)
downloadNix-e820134d38c3b7470ea5112f40a6dc967f039878.tar.gz
Nix-e820134d38c3b7470ea5112f40a6dc967f039878.tar.zst
Nix-e820134d38c3b7470ea5112f40a6dc967f039878.zip
Add monitoring host
Diffstat (limited to 'modules/private/monitoring/plugins/check_git')
-rwxr-xr-xmodules/private/monitoring/plugins/check_git68
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
3SSH_KEY="$1"
4
5TMPDIR=$(mktemp -d)
6
7if [ ! -d "$TMPDIR" ]; then
8 echo "gitolite UNKNOWN - impossible to create temp dir"
9 exit 3
10fi
11
12trap "rm -rf $TMPDIR" EXIT
13
14ERRORS=""
15OUTPUT=""
16
17cd "$TMPDIR"
18OUT=$(git clone -q git://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1)
19ERR=$?
20if [ -n "$OUT" ]; then
21OUTPUT="$OUTPUT
22$OUT"
23fi
24if [ "$ERR" != 0 ]; then
25 ERRORS="$ERRORS git://"
26fi
27rm -rf Monitor
28
29OUT=$(git clone -q http://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1)
30ERR=$?
31if [ -n "$OUT" ]; then
32OUTPUT="$OUTPUT
33$OUT"
34fi
35if [ "$ERR" != 0 ]; then
36 ERRORS="$ERRORS http://"
37fi
38rm -rf Monitor
39
40OUT=$(git clone -q https://git.immae.eu/perso/Immae/Projets/Ruby/Monitor.git 2>&1)
41ERR=$?
42if [ -n "$OUT" ]; then
43OUTPUT="$OUTPUT
44$OUT"
45fi
46if [ "$ERR" != 0 ]; then
47 ERRORS="$ERRORS https://"
48fi
49rm -rf Monitor
50
51OUT=$(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)
52ERR=$?
53if [ -n "$OUT" ]; then
54OUTPUT="$OUTPUT
55$OUT"
56fi
57if [ "$ERR" != 0 ]; then
58 ERRORS="$ERRORS ssh"
59fi
60rm -rf Monitor
61
62if [ -n "$ERRORS" ]; then
63 echo "gitolite CRITICAL - impossible to clone via$ERRORS|$OUTPUT"
64 exit 2
65else
66 echo "gitolite OK - ssh, git, http and https work|$OUTPUT"
67 exit 0
68fi