Fix: update tests for --no-intersection
[deliverable/lttng-analyses.git] / lttng-analyses-record
CommitLineData
06919f70 1#!/bin/bash
4ed24f86
JD
2#
3# The MIT License (MIT)
4#
a3fa57c0 5# Copyright (C) 2015 - Julien Desfossez <jdesfossez@efficios.com>
4ed24f86
JD
6#
7# Permission is hereby granted, free of charge, to any person obtaining a copy
8# of this software and associated documentation files (the "Software"), to deal
9# in the Software without restriction, including without limitation the rights
10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11# copies of the Software, and to permit persons to whom the Software is
12# furnished to do so, subject to the following conditions:
13#
14# The above copyright notice and this permission notice shall be included in
15# all copies or substantial portions of the Software.
16#
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23# SOFTWARE.
06919f70
JD
24
25# Helper to setup a local LTTng tracing session with the appropriate
26# settings for the lttng analyses scripts
27
28SESSION_NAME="lttng-analysis-$RANDOM"
29
30destroy()
31{
32 lttng destroy $SESSION_NAME >/dev/null
33 echo ""
34 echo "You can now launch the analyses scripts on /$TRACEPATH"
35 exit 0
36}
37
38if test "$1" = "-h" -o "$1" = "--help"; then
39 echo "usage : $0"
40 exit 0
41fi
42
43pgrep -u root lttng-sessiond >/dev/null
44if test $? != 0; then
45 echo "Starting lttng-sessiond as root (trying sudo, start manually if \
46it fails)"
47 sudo lttng-sessiond -d
48 if test $? != 0; then
49 exit 1
50 fi
51fi
52
53SUDO=""
54groups|grep tracing >/dev/null
55if test $? != 0; then
56 echo "You are not a member of the tracing group, so you need root \
57access, the script will try with sudo"
58 SUDO="sudo"
59fi
60
61# check if lttng command if in the path
62# check if the user can execute the command (with sudo if not in tracing group)
63# check if lttng-modules is installed
64$SUDO lttng list -k | grep sched_switch >/dev/null
65if test $? != 0; then
66 echo "Something went wrong executing \"$SUDO lttng list -k | grep sched_switch\", \
67try to fix the problem manually and then start the script again"
68fi
69
70# if our random session name was already in use, add more randomness...
71$SUDO lttng list | grep $SESSION_NAME
72if test $? = 0; then
73 SESSION_NAME="$SESSION_NAME-$RANDOM"
74fi
75$SUDO lttng list | grep $SESSION_NAME
76if test $? = 0; then
77 echo "Cannot create a random session name, something must be wrong"
78 exit 2
79fi
80
81lttng create $SESSION_NAME >/tmp/lttngout
82[[ $? != 0 ]] && exit 2
83TRACEPATH=$(grep Traces /tmp/lttngout | cut -d'/' -f2-)
84rm /tmp/lttngout
85
86trap "destroy" SIGINT SIGTERM
87
01ca9f2f 88lttng enable-channel -k chan1 --subbuf-size=8M >/dev/null
a8d0b962
JD
89
90# events that always work
f056f7aa 91lttng enable-event -s $SESSION_NAME -k sched_switch,sched_wakeup,sched_waking,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,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,kmem_mm_page_alloc,kmem_mm_page_free -c chan1 >/dev/null
0e903d62 92[[ $? != 0 ]] && echo "Warning: some events were not enabled, some analyses might not be complete"
a8d0b962
JD
93
94# events that might fail on specific kernels and that are not mandatory
95lttng enable-event -s $SESSION_NAME -k writeback_pages_written -c chan1 >/dev/null 2>&1
94cdc371 96[[ $? != 0 ]] && echo "Warning: Optional event writeback_pages_written could not be enabled, everything will still work (experimental feature)"
a8d0b962 97
06919f70
JD
98lttng enable-event -s $SESSION_NAME -k -c chan1 --syscall -a >/dev/null
99[[ $? != 0 ]] && exit 2
100# if you want to add Perf counters, do something like that :
101#lttng add-context -s $SESSION_NAME -k -t perf:cache-misses -t perf:major-faults -t perf:branch-load-misses >/dev/null
102
103lttng start $SESSION_NAME >/dev/null
104[[ $? != 0 ]] && exit 2
105
106echo -n "The trace is now recording, press ctrl+c to stop it "
107
108while true; do
109 echo -n "."
110 sleep 1
111done
112
113destroy
This page took 0.027695 seconds and 5 git commands to generate.