fix last_sched TS for process that exist at statedump
[deliverable/lttng-analyses.git] / lttng-analyses-record
CommitLineData
06919f70
JD
1#!/bin/bash
2
3# Helper to setup a local LTTng tracing session with the appropriate
4# settings for the lttng analyses scripts
5
6SESSION_NAME="lttng-analysis-$RANDOM"
7
8destroy()
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
16if test "$1" = "-h" -o "$1" = "--help"; then
17 echo "usage : $0"
18 exit 0
19fi
20
21pgrep -u root lttng-sessiond >/dev/null
22if test $? != 0; then
23 echo "Starting lttng-sessiond as root (trying sudo, start manually if \
24it fails)"
25 sudo lttng-sessiond -d
26 if test $? != 0; then
27 exit 1
28 fi
29fi
30
31SUDO=""
32groups|grep tracing >/dev/null
33if test $? != 0; then
34 echo "You are not a member of the tracing group, so you need root \
35access, the script will try with sudo"
36 SUDO="sudo"
37fi
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
43if test $? != 0; then
44 echo "Something went wrong executing \"$SUDO lttng list -k | grep sched_switch\", \
45try to fix the problem manually and then start the script again"
46fi
47
48# if our random session name was already in use, add more randomness...
49$SUDO lttng list | grep $SESSION_NAME
50if test $? = 0; then
51 SESSION_NAME="$SESSION_NAME-$RANDOM"
52fi
53$SUDO lttng list | grep $SESSION_NAME
54if test $? = 0; then
55 echo "Cannot create a random session name, something must be wrong"
56 exit 2
57fi
58
59lttng create $SESSION_NAME >/tmp/lttngout
60[[ $? != 0 ]] && exit 2
61TRACEPATH=$(grep Traces /tmp/lttngout | cut -d'/' -f2-)
62rm /tmp/lttngout
63
64trap "destroy" SIGINT SIGTERM
65
01ca9f2f 66lttng enable-channel -k chan1 --subbuf-size=8M >/dev/null
06919f70
JD
67lttng 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
69lttng 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
74lttng start $SESSION_NAME >/dev/null
75[[ $? != 0 ]] && exit 2
76
77echo -n "The trace is now recording, press ctrl+c to stop it "
78
79while true; do
80 echo -n "."
81 sleep 1
82done
83
84destroy
This page took 0.04112 seconds and 5 git commands to generate.