remove output
[deliverable/lttng-analyses.git] / lttng-analyses-record
1 #!/bin/bash
2
3 # Helper to setup a local LTTng tracing session with the appropriate
4 # settings for the lttng analyses scripts
5
6 SESSION_NAME="lttng-analysis-$RANDOM"
7
8 destroy()
9 {
10 lttng destroy $SESSION_NAME >/dev/null
11 echo ""
12 echo "You can now launch the analyses scripts on /$TRACEPATH"
13 exit 0
14 }
15
16 if test "$1" = "-h" -o "$1" = "--help"; then
17 echo "usage : $0"
18 exit 0
19 fi
20
21 pgrep -u root lttng-sessiond >/dev/null
22 if test $? != 0; then
23 echo "Starting lttng-sessiond as root (trying sudo, start manually if \
24 it fails)"
25 sudo lttng-sessiond -d
26 if test $? != 0; then
27 exit 1
28 fi
29 fi
30
31 SUDO=""
32 groups|grep tracing >/dev/null
33 if test $? != 0; then
34 echo "You are not a member of the tracing group, so you need root \
35 access, the script will try with sudo"
36 SUDO="sudo"
37 fi
38
39 # check if lttng command if in the path
40 # check if the user can execute the command (with sudo if not in tracing group)
41 # check if lttng-modules is installed
42 $SUDO lttng list -k | grep sched_switch >/dev/null
43 if test $? != 0; then
44 echo "Something went wrong executing \"$SUDO lttng list -k | grep sched_switch\", \
45 try to fix the problem manually and then start the script again"
46 fi
47
48 # if our random session name was already in use, add more randomness...
49 $SUDO lttng list | grep $SESSION_NAME
50 if test $? = 0; then
51 SESSION_NAME="$SESSION_NAME-$RANDOM"
52 fi
53 $SUDO lttng list | grep $SESSION_NAME
54 if test $? = 0; then
55 echo "Cannot create a random session name, something must be wrong"
56 exit 2
57 fi
58
59 lttng create $SESSION_NAME >/tmp/lttngout
60 [[ $? != 0 ]] && exit 2
61 TRACEPATH=$(grep Traces /tmp/lttngout | cut -d'/' -f2-)
62 rm /tmp/lttngout
63
64 trap "destroy" SIGINT SIGTERM
65
66 lttng enable-channel -k chan1 --subbuf-size=8M >/dev/null
67 lttng enable-event -s $SESSION_NAME -k sched_switch,block_rq_complete,block_rq_issue,block_bio_remap,block_bio_backmerge,netif_receive_skb,net_dev_xmit,sched_process_fork,sched_process_exec,lttng_statedump_process_state,lttng_statedump_file_descriptor,lttng_statedump_block_device,writeback_pages_written,mm_vmscan_wakeup_kswapd,mm_page_free,mm_page_alloc,block_dirty_buffer,irq_handler_entry,irq_handler_exit,softirq_entry,softirq_exit,softirq_raise -c chan1 >/dev/null
68 [[ $? != 0 ]] && exit 2
69 lttng enable-event -s $SESSION_NAME -k -c chan1 --syscall -a >/dev/null
70 [[ $? != 0 ]] && exit 2
71 # if you want to add Perf counters, do something like that :
72 #lttng add-context -s $SESSION_NAME -k -t perf:cache-misses -t perf:major-faults -t perf:branch-load-misses >/dev/null
73
74 lttng start $SESSION_NAME >/dev/null
75 [[ $? != 0 ]] && exit 2
76
77 echo -n "The trace is now recording, press ctrl+c to stop it "
78
79 while true; do
80 echo -n "."
81 sleep 1
82 done
83
84 destroy
This page took 0.033086 seconds and 6 git commands to generate.