fix: cleanup the lttngtop-live-simple traces
[lttngtop.git] / utils / lttngtop-live-simple.sh
CommitLineData
fd06db21
JD
1#!/bin/bash
2
3# Setup a live LTTng session on localhost
4
5SESSION_NAME="lttngtop-live-simple"
6DEBUG=">/dev/null"
7
8pgrep -u root lttng-sessiond >/dev/null
9if test $? != 0; then
10 echo "Starting lttng-sessiond as root (trying sudo, start manually if \
11it fails)"
12 sudo lttng-sessiond -d
13 if test $? != 0; then
14 exit 1
15 fi
16fi
17
18pgrep lttng-relayd >/dev/null
19if test $? != 0; then
20 echo "Starting lttng-relayd as your current user, start manually if \
21it fails"
22 lttng-relayd -d
23 if test $? != 0; then
24 exit 1
25 fi
26fi
27
28SUDO=""
29groups|grep tracing >/dev/null
30if test $? != 0; then
31 echo "You are not a member of the tracing group, so you need root \
32access, the script will try with sudo"
33 SUDO="sudo"
34fi
35
36# check if lttng command if in the path
37# check if the user can execute the command (with sudo if not in tracing group)
38# check if lttng-modules is installed
39$SUDO lttng list -k | grep sched_switch >/dev/null
40if test $? != 0; then
41 echo "Something went wrong executing \"$SUDO lttng list -k | grep sched_switch\", \
42try to fix the problem manually and then start the script again"
43fi
44
45lttng create $SESSION_NAME --live 1000000 -U net://localhost >/dev/null
46[[ $? != 0 ]] && exit 2
6e11e0d0 47lttng enable-event -s $SESSION_NAME -k lttng_statedump_start,lttng_statedump_end,lttng_statedump_process_state,lttng_statedump_file_descriptor,lttng_statedump_vm_map,lttng_statedump_network_interface,lttng_statedump_interrupt,sched_process_free,sched_switch,sched_process_fork >/dev/null
fd06db21
JD
48[[ $? != 0 ]] && exit 2
49lttng enable-event -s $SESSION_NAME -k --syscall -a >/dev/null
50[[ $? != 0 ]] && exit 2
51lttng add-context -s $SESSION_NAME -k -t pid -t procname -t tid -t ppid -t perf:cache-misses -t perf:major-faults -t perf:branch-load-misses >/dev/null
52[[ $? != 0 ]] && exit 2
53lttng start $SESSION_NAME >/dev/null
54[[ $? != 0 ]] && exit 2
55
56s=$(lttngtop -r net://localhost | grep $SESSION_NAME)
57if test $? != 0; then
58 echo "Problem executing lttngtop -r net://localhost | grep $SESSION_NAME"
59 exit 1
60fi
61
62lttngtop -r $(echo $s|cut -d' ' -f1)
63
64lttng destroy $SESSION_NAME >/dev/null
65echo -n "Destroy $HOME/lttng-traces/$HOSTNAME/${SESSION_NAME}* (Y/n) ? "
66read a
d0377b66 67if test -z "$a" -o "$a" = 'y' -o "$a" = 'Y'; then
fd06db21
JD
68 rm -rf $HOME/lttng-traces/$HOSTNAME/${SESSION_NAME}*
69fi
This page took 0.034026 seconds and 4 git commands to generate.