Browse code

ser maintenance commands added

Jiri Kuthan authored on 12/04/2002 06:48:08
Showing 3 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,27 @@
0
+#!/bin/sh
1
+
2
+NOTIFY=sr@iptel.org
3
+SERDIR=/home/srouter/sip_router
4
+BIN=./ser
5
+CORE=../core/core
6
+
7
+PROCCNT=`ps -C sr --no-headers -o pid | wc -l`
8
+CH=`grep "^children" /etc/sr.cfg | awk -F= ' { print $2 } '`
9
+ALL=`expr $CH + 1`
10
+TMP=/tmp/seralert.$$
11
+
12
+if [ $PROCCNT -ne $ALL ] ; then 
13
+
14
+	echo "Alarm: ser restart occured on `date` at $HOSTNAME" > $TMP
15
+	cd $SERDIR
16
+	if [ -r $BIN -a -r $CORE ] ; then
17
+		echo "----------------------------------" >> $TMP
18
+		gdb $BIN $CORE -f test/bt.gdb -batch >> $TMP
19
+	else
20
+		echo "no core found" >> $TMP
21
+	fi
22
+
23
+	/etc/init.d/sr restart
24
+	mail -s "ser restart occured" $NOTIFY < $TMP
25
+	rm $TMP
26
+fi
0 27
new file mode 100755
... ...
@@ -0,0 +1,12 @@
0
+#!/bin/sh
1
+
2
+#ps -ef|grep '/sr'| grep -v grep
3
+PIDS=`ps --no-headers -o "pid" -C sr`
4
+for i in $PIDS ;  do
5
+	ps -o "pid,user,group,euser,egroup,fuser,fgroup,args" $i
6
+	echo "WD: `ls -ld /proc/$i/cwd`"
7
+done
8
+
9
+#ps  -wwwwww -o "drs,pid,user,group,euser,egroup,fuser,fgroup,args" -C sr 
10
+
11
+mysql -h dbhost -u csps -p -e "select * from location;" csps107
0 12
new file mode 100755
... ...
@@ -0,0 +1,69 @@
0
+#!/bin/sh 
1
+#
2
+# 3w-xxxx:      Starts the sip_router process
3
+#
4
+# Version:      @(#) /etc/rc.d/init.d/3w-xxxx
5
+#
6
+# chkconfig: 2345 20 80
7
+# description: controls execution of SIP router
8
+# processname: sip_router
9
+# config: /etc/sip_router.cfg
10
+
11
+# Source function library.
12
+. /etc/rc.d/init.d/functions
13
+
14
+#BIN=sip_router
15
+#ETC=sip_router.cfg
16
+
17
+# we use a ser symlink -- that allows us to have a different name
18
+# in process table so that killalls does not start other sers
19
+# run from somewhere else
20
+
21
+BIN=sr
22
+ETC=sr.cfg
23
+HM=/home/srouter
24
+USR=510
25
+GRP=510
26
+
27
+RETVAL=0
28
+
29
+MYDIR=$HM/core
30
+CORE=$MYDIR/core
31
+cd $MYDIR
32
+
33
+# See how we were called.
34
+case "$1" in
35
+  start)
36
+	echo -n "Starting SIP router: "
37
+	if [ -f $CORE ] ; then
38
+		chmod a+r $CORE
39
+		DATE=`date "+%Y-%m-%d--%H-%M"`
40
+		mv $CORE $CORE.$DATE
41
+		( cd ../sip_router; tar cf - . ) | gzip > ser.$DATE.tgz
42
+	fi
43
+	$HM/bin/$BIN -f $HM/etc/$ETC -w $MYDIR
44
+	# man setuid: If uid is different from the old effective uid, 
45
+    # the process will be forbidden from eaving core dumps.
46
+	# -> don't set uid, we want to collect core dumps
47
+	# -u $USR -g $GRP 
48
+	RETVAL=$?
49
+	echo
50
+	;;
51
+  stop)
52
+	echo "Stopping SIP router: "
53
+	killproc $BIN
54
+	RETVAL=$?
55
+        echo
56
+	;;
57
+  restart)
58
+	$0 stop
59
+	$0 start
60
+	RETVAL=$?
61
+	;;
62
+  *)
63
+	echo "Usage: $0 {start|stop|restart}"
64
+	exit 1
65
+esac
66
+
67
+exit $RETVAL
68
+