File: l2tpns-monitor

package info (click to toggle)
l2tpns 2.4.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,892 kB
  • sloc: ansic: 22,125; sh: 177; perl: 139; makefile: 132
file content (28 lines) | stat: -rw-r--r-- 633 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh
stopfile=/tmp/l2tpns.stop
first=`date +%s`
min_first_time=3
restart_delay=5
prog=${0##*/}

while :
do
	echo "`date`: Starting l2tpns $@"
	start=`date +%s`
	/usr/sbin/l2tpns ${1+"$@"}
	RETVAL=$?
	stop=`date +%s`
	t=$(($stop - $start));
	first=$(($stop - $first));
	echo "`date`: l2tpns exited after $t seconds, status $RETVAL"
	if [ $first -lt $min_first_time ]; then
		echo "`date`: l2tpns exited immediately, $prog exiting"
		exit $RETVAL
	fi
	if [ -f $stopfile ]; then
		ls -l $stopfile
		echo "`date`: stop file found, $prog exiting"
		exit
	fi
	sleep $restart_delay
done >>/var/log/$prog 2>&1	&	# execute in background