Debian Codegraph @

misc/examples/obsoleted/sercheck

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # $Id$
4 #
5 # use to check whether all ser processes are running; if not, restart
6 # and issue an alert; run from cron daemon for best results :-)
7 #
8
9
10 NOTIFY[email protected]
11 SERHOME=/home/srouterscip-shell filesystem . . `/home/srouter`.
12 export SERDIR=$SERHOME/sip_router
13 BIN=$SERDIR/ser
14 COREDIR=$SERHOME/core
15 CORE=$COREDIR/core
16 ETC=/etc/sr.cfgscip-shell filesystem . . `/etc/sr.cfg`.
17
18 PROCCNT=`psscip-shell system . . ps. -C sr --no-headers -o pid | wcscip-shell system . . wc. -l`
19 CH=`grepscip-shell system . . grep. "^children" $ETC | awkscip-shell system . . awk. -F= ' { print $2 } '`
20 ALL=`exprscip-shell system . . expr. $CH + 1`
21 TMP=/tmp/seralert.$$
22
23
24 if [scip-shell system . . `[`. $PROCCNT -ne $ALL ] ; then
25 # try again first -- it might have been a temporary
26 # failure during 'sr restart'
27
28 # two seconds longer failure is not too bad...UAs will
29 # just retransmit and user are used to longer call
30 # set-up times from GSM...
31 sleepscip-shell system . . sleep. 2
32 PROCCNT=`psscip-shell system . . ps. -C sr --no-headers -o pid | wcscip-shell system . . wc. -l`
33 fi
34
35 if [scip-shell system . . `[`. $PROCCNT -ne $ALL ] ; then
36
37 cd $SERDIR
38 echoscip-shell system . . echo. "Alarm: ser restart occurred on `datescip-shell system . . date.` at $HOSTNAME" > $TMP
39 if [scip-shell system . . `[`. -r $BIN -a -r $CORE ] ; then
40 echoscip-shell system . . echo. "----------------------------------" >> $TMP
41 DATE=`datescip-shell system . . date. "+%Y-%m-%d--%H-%M"`
42 NEWCORE=$COREDIR/core.$DATE
43 mvscip-shell system . . mv. $CORE $NEWCORE
44 echoscip-shell system . . echo. core stored in $NEWCORE >> $TMP
45 gdb $BIN $NEWCORE -x test/bt.gdb -batch >> $TMP
46 chmodscip-shell system . . chmod. a+r $NEWCORE
47 ( cd $SERDIR; tarscip-shell system . . tar. cf - . ) | gzipscip-shell system . . gzip. > $COREDIR/ser.$DATE.tgz
48
49 else
50 echoscip-shell system . . echo. "no core found" >> $TMP
51 fi
52
53 /etc/init.d/srscip-shell filesystem . . `/etc/init.d/sr`. restart
54 mail -s "ser restart occurred" $NOTIFY < $TMP
55 rmscip-shell system . . rm. -f $TMP
56 fi