-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor-bw.init
executable file
·56 lines (50 loc) · 1.24 KB
/
monitor-bw.init
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
### BEGIN INIT INFO
# Provides: monitor-bw
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Should-Start: network-manager
# Should-Stop: network-manager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Available Bandwidth Monitoring Tool
# Description: This collection of scripts measures and monitors
# the available throughput on a given interface
# via a certain router
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=monitor-bw
DAEMON=/usr/local/bin/$NAME.sh
DAEMON_ARGS="/var/log/rrd/monitor-bw.rrd"
PIDFILE=/var/run/$NAME.pid
do_start() {
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon -b -m --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS
}
do_stop() {
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME.sh
RETVAL="$?"
[ "$RETVAL" = 2 ] && exit 2
rm -f $PIDFILE
return "$RETVAL"
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart)
do_stop
sleep 3
do_start
;;
*)
echo "Usage: $0 {start|stop|restart|}" >&2
exit 1
;;
esac
exit 0