Browse code

Initial version of a bash script which uses sipsak to check if ser is still responding.

Nils Ohlmeier authored on 12/06/2002 23:04:56
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,40 @@
1
+#!/bin/sh 
2
+#
3
+# $Id$
4
+#
5
+# use to check whether ser is still responding; if not mail an alert
6
+#
7
+
8
+
9
+NOTIFY=sr@iptel.org
10
+SERHOME=/home/srouter
11
+SERDIR=$SERHOME/sip_router
12
+TESTDIR=$SERDIR/test
13
+BIN=$TESTDIR/sipsak
14
+MESSAGE=$TESTDIR/sipsak.sip
15
+SERHOST=sip:iptel.org
16
+LOCKFILE=/var/lock/serresponse
17
+TMP=/tmp/serresponse.$$
18
+MAILCOMMAND=/usr/bin/mail
19
+
20
+if [ ! -e $LOCKFILE ] ; then
21
+	if [ ! -f $MESSAGE ] ; then
22
+		echo "serresponse did not find the required message $MESSAGE" > $TMP
23
+	elif [ ! -x $BIN ] ; then
24
+		echo "serresponse did not find the required sipsak executable $BIN" > $TMP
25
+	else
26
+		echo "The execution of this command:" > $TMP
27
+		echo "  $BIN -f $MESSAGE -s $SERHOST" >> $TMP
28
+		echo "produced this output:" >> $TMP
29
+		$BIN -f $MESSAGE -s $SERHOST >> $TMP 2>&1
30
+		if [ $? -eq 0 ] ; then
31
+			rm -f $TMP
32
+		fi
33
+	fi
34
+	
35
+	if [ -e $TMP ] ; then
36
+		$MAILCOMMAND -s "serresponse failed" $NOTIFY < $TMP
37
+		touch $LOCKFILE
38
+		rm -f $TMP
39
+	fi
40
+fi