3 # Helper to setup a local LTTng tracing session with the appropriate
4 # settings for the lttng analyses scripts
6 SESSION_NAME
="lttng-analysis-$RANDOM"
10 lttng destroy
$SESSION_NAME >/dev
/null
12 echo "You can now launch the analyses scripts on /$TRACEPATH"
16 if test "$1" = "-h" -o "$1" = "--help"; then
21 pgrep
-u root lttng-sessiond
>/dev
/null
23 echo "Starting lttng-sessiond as root (trying sudo, start manually if \
25 sudo lttng-sessiond
-d
32 groups|
grep tracing
>/dev
/null
34 echo "You are not a member of the tracing group, so you need root \
35 access, the script will try with sudo"
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
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"
48 # if our random session name was already in use, add more randomness...
49 $SUDO lttng list |
grep $SESSION_NAME
51 SESSION_NAME
="$SESSION_NAME-$RANDOM"
53 $SUDO lttng list |
grep $SESSION_NAME
55 echo "Cannot create a random session name, something must be wrong"
59 lttng create
$SESSION_NAME >/tmp
/lttngout
60 [[ $?
!= 0 ]] && exit 2
61 TRACEPATH
=$
(grep Traces
/tmp
/lttngout | cut
-d'/' -f2-)
64 trap "destroy" SIGINT SIGTERM
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
74 lttng start
$SESSION_NAME >/dev
/null
75 [[ $?
!= 0 ]] && exit 2
77 echo -n "The trace is now recording, press ctrl+c to stop it "