Commit | Line | Data |
---|---|---|
045880fb | 1 | # Copyright (C) 2009 Benjamin Poirier |
36cf2b17 | 2 | # Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
045880fb BP |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | ||
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | ||
14 | # You should have received a copy of the GNU General Public License along | |
15 | # with this program; if not, write to the Free Software Foundation, Inc., | |
16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | ||
36cf2b17 | 18 | DEBUGFSROOT=$(awk '{if ($3 == "debugfs") print $2}' /proc/mounts | head -n 1) |
80bb2806 | 19 | MARKERSROOT=${DEBUGFSROOT}/ltt/markers |
88f304c9 AM |
20 | DEFAULTMODULES="ltt-trace-control ltt-marker-control ltt-kprobes ltt-userspace-event ltt-statedump ipc-trace kernel-trace mm-trace net-trace fs-trace jbd2-trace syscall-trace trap-trace block-trace rcu-trace ltt-relay ltt-tracer" |
21 | EXTRAMODULES="lockdep-trace net-extended-trace" | |
024405bd | 22 | |
045880fb | 23 | usage () { |
cdfcd011 JW |
24 | echo "Usage: $0 [OPTION]..." 1>&2 |
25 | echo "Disconnect lttng markers" 1>&2 | |
26 | echo "" 1>&2 | |
27 | echo "Options:" 1>&2 | |
28 | printf "\t-q Quiet mode, suppress output\n" 1>&2 | |
29 | printf "\t-h Print this help\n" 1>&2 | |
30 | echo "" 1>&2 | |
045880fb BP |
31 | } |
32 | ||
88f304c9 | 33 | if [ "$(id -u)" != "0" ]; then |
cdfcd011 | 34 | echo "Error: This script needs to be run as root." 1>&2 |
88f304c9 AM |
35 | exit 1; |
36 | fi | |
37 | ||
fde9c319 | 38 | if [ ! "${DEBUGFSROOT}" ]; then |
cdfcd011 | 39 | echo "Error: debugfs not mounted" 1>&2 |
045880fb BP |
40 | exit 1; |
41 | fi | |
42 | ||
fde9c319 | 43 | if [ ! -d "${MARKERSROOT}" ]; then |
cdfcd011 | 44 | echo "Error: LTT trace controller not found (did you compile and load LTTng?)" 1>&2 |
045880fb BP |
45 | exit 1; |
46 | fi | |
47 | ||
48 | while getopts "qh" options; do | |
fde9c319 | 49 | case ${options} in |
045880fb BP |
50 | q) QUIET="0";; |
51 | h) usage; | |
52 | exit 0;; | |
53 | \?) usage; | |
54 | exit 1;; | |
80bb2806 | 55 | esac |
024405bd | 56 | done |
fde9c319 | 57 | shift $((${OPTIND} - 1)) |
045880fb | 58 | |
6e8902bf | 59 | (eval "find '${MARKERSROOT}' -name metadata -prune -o -name enable -print") | while read -r marker; do |
fde9c319 | 60 | grep "^1$" "${marker}" -q |
045880fb BP |
61 | if [ $? -ne 0 ]; then |
62 | continue | |
63 | fi | |
fde9c319 | 64 | if [ ! ${QUIET} ]; then |
045880fb BP |
65 | echo "Disconnecting ${marker%/enable}" |
66 | fi | |
fde9c319 | 67 | echo 0 > ${marker} |
d7a3410b | 68 | done |
88f304c9 AM |
69 | |
70 | #Unload the kernel modules | |
71 | for i in ${EXTRAMODULES}; do | |
72 | rmmod $i 2> /dev/null | |
73 | done | |
74 | for i in ${DEFAULTMODULES}; do | |
75 | rmmod $i | |
76 | done | |
77 |