updated on Sun Jan 22 08:00:21 UTC 2012
[aur-mirror.git] / oprofile-cli / oprofile
blob140530dd2f712f22fa5982d0a9702e424302eb69
1 #!/bin/bash
2 # Contributed by basilburn
4 . /etc/rc.conf
5 . /etc/rc.d/functions
6 . /etc/conf.d/oprofile
8 PID=`pidof -o %PPID /usr/sbin/oprofiled`
9 case "$1" in
10 start)
11 stat_busy "Starting Profiler"
12 [ -z "$PID" ] && /usr/bin/opcontrol --init && \
13 /usr/bin/opcontrol --start $OPTIONS &>/dev/null
14 if [ $? -gt 0 ]; then
15 stat_fail
16 else
17 echo $PID > /var/run/oprofiled.pid
18 add_daemon oprofiled
19 stat_done
22 stop)
23 stat_busy "Stopping Profiler"
24 [ ! -z "$PID" ] && /usr/bin/opcontrol --shutdown &>/dev/null
25 if [ $? -gt 0 ]; then
26 stat_fail
27 else
28 rm /var/run/oprofiled.pid
29 rm_daemon oprofiled
30 stat_done
33 restart)
34 $0 stop
35 sleep 2
36 $0 start
38 reset)
39 /usr/bin/opcontrol --reset
40 $0 restart
43 echo "usage: $0 {start|stop|restart|reset}"
44 esac
45 exit 0