Initial commit
Benjamin Renard

Benjamin Renard commited on 2013-12-03 15:05:37
Showing 3 changed files, with 103 additions and 0 deletions.

... ...
@@ -0,0 +1 @@
1
+*~
... ...
@@ -0,0 +1,30 @@
1
+Nagios plugin to check Git Repository status
2
+============================================
3
+
4
+Usage
5
+-----
6
+
7
+  Usage : ./check_git_config [directory] [-d]
8
+          [directory]     Git root directory (default : /srv/common)
9
+          [-d]            Enable debug mode
10
+
11
+Copyright
12
+---------
13
+
14
+Copyright (c) 2013 Benjamin Renard 
15
+
16
+License
17
+-------
18
+
19
+This program is free software; you can redistribute it and/or
20
+modify it under the terms of the GNU General Public License version 2
21
+as published by the Free Software Foundation.
22
+
23
+This program is distributed in the hope that it will be useful,
24
+but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
+GNU General Public License for more details.
27
+
28
+You should have received a copy of the GNU General Public License
29
+along with this program; if not, write to the Free Software
30
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
... ...
@@ -0,0 +1,72 @@
1
+#!/bin/bash
2
+#
3
+# Nagios plugin to check Postgresql streamin replication state
4
+#
5
+# Could be use on Master or on standby node
6
+#
7
+# Requirement :
8
+#
9
+#     On master node : Slaves must be able to connect with user PG_USER
10
+#                      to database postgres as trust
11
+#
12
+#     On standby node : PG_USER must be able to connect localy as trust
13
+#
14
+# Author : Benjamin Renard <brenard@easter-eggs.com>
15
+# Date : Wed, 14 Mar 2012 14:45:55 +0000
16
+# Source : http://git.zionetrix.net/check_pg_streaming_replication
17
+#
18
+
19
+GIT_ROOT=/srv/common
20
+
21
+if [ "$1" == "-h" ]
22
+then
23
+	echo "Usage : $0 [directory] [-d]
24
+	[directory]	Git root directory (default : $GIT_ROOT)
25
+	[-d]		Enable debug mode"
26
+	exit 0
27
+fi
28
+
29
+[ -n "$1" -a "$1" != "-d" ] && GIT_ROOT="$1"
30
+[ ! -d "$GIT_ROOT" ] && echo "UNKNOWN : Git root directory does not exists !" && exit 3
31
+[ ! -d "$GIT_ROOT/.git" ] && echo "UNKNOWN : Git root directory seem to not being a git repository." && exit 3
32
+
33
+cd $GIT_ROOT
34
+
35
+DEBUG=0
36
+[ "$1" == "-d" -o "$2" == "-d" ] && DEBUG=1
37
+
38
+STATUS=$( git status -s )
39
+
40
+[ $DEBUG -eq 1 ] && echo -e "Status : $STATUS"
41
+
42
+if [ -n "$STATUS" ]
43
+then
44
+	echo "WARNING : Git config repo on $( hostname ) not clean"
45
+	exit 1
46
+else
47
+	[ $DEBUG -eq 1 ] && echo -n "Fecth : "
48
+	git fetch > /dev/null 2>&1
49
+	res=$?
50
+	[ $DEBUG -eq 1 ] && echo "done. (Return $?)"
51
+
52
+	if [ $res -ne 0 ]
53
+	then
54
+		echo "UNKNOWN : Error fetching remote"
55
+		exit 3
56
+	fi
57
+
58
+	HEAD="$( git show HEAD|grep ^commit )"
59
+	[ $DEBUG -eq 1 ] && echo "Local : $HEAD"
60
+
61
+	ORIGIN="$( git show origin|grep ^commit )"
62
+	[ $DEBUG -eq 1 ] && echo "Remote : $ORIGIN"
63
+	
64
+	if [ "$HEAD" != "$ORIGIN" ]
65
+	then
66
+		echo "CRITICAL : Git config not uptodate"
67
+		exit 2
68
+	else
69
+		echo "OK"
70
+		exit 0
71
+	fi
72
+fi
0 73