Commit | Line | Data |
---|---|---|
fd06db21 JD |
1 | #!/bin/bash |
2 | ||
3 | # Setup a live LTTng session on localhost | |
4 | ||
5 | SESSION_NAME="lttngtop-live-simple" | |
6 | DEBUG=">/dev/null" | |
7 | ||
8 | pgrep -u root lttng-sessiond >/dev/null | |
9 | if test $? != 0; then | |
10 | echo "Starting lttng-sessiond as root (trying sudo, start manually if \ | |
11 | it fails)" | |
12 | sudo lttng-sessiond -d | |
13 | if test $? != 0; then | |
14 | exit 1 | |
15 | fi | |
16 | fi | |
17 | ||
18 | pgrep lttng-relayd >/dev/null | |
19 | if test $? != 0; then | |
20 | echo "Starting lttng-relayd as your current user, start manually if \ | |
21 | it fails" | |
22 | lttng-relayd -d | |
23 | if test $? != 0; then | |
24 | exit 1 | |
25 | fi | |
26 | fi | |
27 | ||
28 | SUDO="" | |
29 | groups|grep tracing >/dev/null | |
30 | if test $? != 0; then | |
31 | echo "You are not a member of the tracing group, so you need root \ | |
32 | access, the script will try with sudo" | |
33 | SUDO="sudo" | |
34 | fi | |
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 | |
40 | if test $? != 0; then | |
41 | echo "Something went wrong executing \"$SUDO lttng list -k | grep sched_switch\", \ | |
42 | try to fix the problem manually and then start the script again" | |
43 | fi | |
44 | ||
45 | lttng create $SESSION_NAME --live 1000000 -U net://localhost >/dev/null | |
46 | [[ $? != 0 ]] && exit 2 | |
47 | lttng 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 >/dev/null | |
48 | [[ $? != 0 ]] && exit 2 | |
49 | lttng enable-event -s $SESSION_NAME -k --syscall -a >/dev/null | |
50 | [[ $? != 0 ]] && exit 2 | |
51 | lttng 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 | |
53 | lttng start $SESSION_NAME >/dev/null | |
54 | [[ $? != 0 ]] && exit 2 | |
55 | ||
56 | s=$(lttngtop -r net://localhost | grep $SESSION_NAME) | |
57 | if test $? != 0; then | |
58 | echo "Problem executing lttngtop -r net://localhost | grep $SESSION_NAME" | |
59 | exit 1 | |
60 | fi | |
61 | ||
62 | lttngtop -r $(echo $s|cut -d' ' -f1) | |
63 | ||
64 | lttng destroy $SESSION_NAME >/dev/null | |
65 | echo -n "Destroy $HOME/lttng-traces/$HOSTNAME/${SESSION_NAME}* (Y/n) ? " | |
66 | read a | |
67 | if test $a = 'y' -o $a = 'Y'; then | |
68 | rm -rf $HOME/lttng-traces/$HOSTNAME/${SESSION_NAME}* | |
69 | fi |