extras: core-handler: simplify, allow usage from tracing group
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 19 Jul 2013 21:55:00 +0000 (17:55 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 19 Jul 2013 21:55:00 +0000 (17:55 -0400)
Allow managing the coredump handler tracing session from the tracing
group. Use create --snapshot.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
extras/core-handler/README
extras/core-handler/handler.sh
extras/core-handler/install.sh
extras/core-handler/test.sh

index 4482fd15b2952d3505ed8ac2a8abb23a6d5de03c..039ce3b5b2a5a16600cd91d751185d24f80bf9df 100644 (file)
@@ -23,36 +23,34 @@ You can use the provided test.sh script to test that the core dump snapshot
 handler is working properly:
 
 # ./test.sh
 handler is working properly:
 
 # ./test.sh
-Setup...
-Spawning a session daemon
-Session auto-20130626-224838 created.
-Kernel channel chan enabled for session auto-20130626-224838
-kernel event sched_switch created in channel chan
-Tracing started for session auto-20130626-224838
+Setup coredump-handler...
+Session coredump-handler created.
+Default snapshot output set to: /tmp/lttng/snapshot
+Snapshot mode set. Every channel enabled for that session will be set in overwrite mode and mmap output
+kernel event sched_switch created in channel channel0
+Tracing started for session coredump-handler
 Sleeping...
 Crashing...
 Sleeping...
 Crashing...
-./test.sh: line 35: 16980 Segmentation fault      (core dumped)
-$(dirname $0)/crash
+Segmentation fault (core dumped)
+Sleeping...
 Waiting for data availability
 Waiting for data availability
-Tracing stopped for session auto-20130626-224838
-Session auto-20130626-224838 destroyed
-Core dump and snapshot will be available in /tmp/lttng/{core,snapshot}.
+Tracing stopped for session coredump-handler
+Session coredump-handler destroyed
+Core dump will be available in /tmp/lttng/core.
+Snapshot will be available in /tmp/lttng/snapshot.
 
 # tree /tmp/lttng
 /tmp/lttng
 
 # tree /tmp/lttng
 /tmp/lttng
-|-- core
-|   `-- core.16980
-`-- snapshot
-    `-- snapshot
-        |-- chan_0
-        |-- chan_1
-        |-- chan_2
-        |-- chan_3
-        |-- chan_4
-        |-- chan_5
-        |-- chan_6
-        |-- chan_7
-        `-- metadata
+├── core
+│   └── core.29085
+└── snapshot
+    └── snapshot-1-20130719-175041-0
+        └── kernel
+            ├── channel0_0
+            ├── channel0_1
+            ├── channel0_2
+            ├── channel0_3
+            └── metadata
 
 Chaining with other core dump handler:
 
 
 Chaining with other core dump handler:
 
@@ -72,7 +70,8 @@ In LTTng handler.sh script:
 
 [...]
 # Save core dump from stdin.
 
 [...]
 # Save core dump from stdin.
-$MKDIR_BIN -p "${CORE_PATH}"
+#$MKDIR_BIN -p "${CORE_PATH}"
+#$CAT_BIN - > "${CORE_PATH}/${CORE_PREFIX}.$p"
 
 # Optional, chain core dump handler with original systemd script.
 $CAT_BIN - | /usr/lib/systemd/systemd-coredump $p $u $g $s $t $e
 
 # Optional, chain core dump handler with original systemd script.
 $CAT_BIN - | /usr/lib/systemd/systemd-coredump $p $u $g $s $t $e
index 3026e52f9a90baeae8bdf4d0f3f18b2d983a4195..781728223bd64b50355a022bc0cf8d24a1348e5c 100755 (executable)
@@ -23,18 +23,16 @@ PGREP_BIN="pgrep"
 MKDIR_BIN="mkdir"
 LTTNG_BIN="lttng"
 
 MKDIR_BIN="mkdir"
 LTTNG_BIN="lttng"
 
-# Core file settings.
-CORE_PATH="/tmp/lttng/core"
-CORE_PREFIX="core"
-
-# Folder where to save snapshot output.
-# Can also be a remote URI.
-SNAPSHOT_PATH="/tmp/lttng/snapshot"
-SNAPSHOT_OUTPUT="file://${SNAPSHOT_PATH}"
+# Session name
+SESSION_NAME="coredump-handler"
 
 # Sessiond binary name.
 SESSIOND_BIN_NAME="lttng-sessiond"
 
 
 # Sessiond binary name.
 SESSIOND_BIN_NAME="lttng-sessiond"
 
+# Core file settings.
+CORE_PATH="/tmp/lttng/core"
+CORE_PREFIX="core"
+
 # Core specifiers, see man core(5)
 
 p=$1 # PID of dumped process
 # Core specifiers, see man core(5)
 
 p=$1 # PID of dumped process
@@ -60,13 +58,5 @@ $CAT_BIN - > "${CORE_PATH}/${CORE_PREFIX}.$p"
 # TODO: Checking for a sessiond lockfile would be more appropriate.
 if $PGREP_BIN -u root "${SESSIOND_BIN_NAME}" > /dev/null 2>&1
 then
 # TODO: Checking for a sessiond lockfile would be more appropriate.
 if $PGREP_BIN -u root "${SESSIOND_BIN_NAME}" > /dev/null 2>&1
 then
-    # Since we are called via the kernel coredump mechanism, we need to
-    # setup our environment manually.
-    #
-    # The lttng command line tool lookup $HOME to adjust the .lttngrc
-    # path. This is useful to have automatic session name lookup.
-    export HOME="/root"
-    $MKDIR_BIN -p "${SNAPSHOT_PATH}"
-    $LTTNG_BIN snapshot add-output "${SNAPSHOT_OUTPUT}" > /dev/null 2>&1
-    $LTTNG_BIN snapshot record > /dev/null 2>&1
+    $LTTNG_BIN snapshot record -s ${SESSION_NAME} > /dev/null 2>&1
 fi
 fi
index 4e8d8443f05af868924f2859b995887757872ad5..8116805fdd314396177b05514826092dca390431 100755 (executable)
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
 
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
 
-CORE_PATTERN="/proc/sys/kernel/core_pattern"
+CORE_PATTERN_PATH="/proc/sys/kernel/core_pattern"
 CORE_HANDLER_PATH="$(dirname $(readlink -e $0))/handler.sh"
 CORE_HANDLER_PATH="$(dirname $(readlink -e $0))/handler.sh"
+CORE_PATTERN="$(cat ${CORE_PATTERN_PATH})"
 
 
-cat ${CORE_PATTERN} > core_pattern.bkp
+echo ${CORE_PATTERN} > core_pattern.bkp
 
 echo "Backup current core_pattern in core_pattern.bkp."
 
 
 echo "Backup current core_pattern in core_pattern.bkp."
 
-echo "|$CORE_HANDLER_PATH %p %u %g %s %t %h %e %E %c" > ${CORE_PATTERN}
+echo "|$CORE_HANDLER_PATH %p %u %g %s %t %h %e %E %c" > ${CORE_PATTERN_PATH}
 
 if [ $? -eq 0 ]
 then
 
 if [ $? -eq 0 ]
 then
-    echo "Successfully installed core_pattern."
+       echo "Successfully installed core_pattern."
 else
 else
-    echo "Installation of core_pattern failed."
+       echo "Installation of core_pattern failed."
+       exit 1
 fi
 fi
index 0c04bcd97fed9f2153238a17a31793f09098226d..c36fdf78c7c28a80fb93c82368cbbc7126bc5102 100755 (executable)
 
 LTTNG_BIN="lttng"
 
 
 LTTNG_BIN="lttng"
 
-CHANNEL_NAME="chan"
+SESSION_NAME="coredump-handler"
+
+# Just recording kernel event sched_switch as an example, but we can as
+# well record user-space events from UST domain.
 EVENT_NAME="sched_switch"
 
 EVENT_NAME="sched_switch"
 
-echo "Setup..."
-$LTTNG_BIN create --no-output
-$LTTNG_BIN enable-channel "${CHANNEL_NAME}" -k --overwrite --output mmap
-$LTTNG_BIN enable-event "${EVENT_NAME}" -c "${CHANNEL_NAME}" -k
-$LTTNG_BIN start
+SNAPSHOT_PATH="/tmp/lttng/snapshot"
+SNAPSHOT_URI="file://${SNAPSHOT_PATH}"
+
+echo "Setup ${SESSION_NAME}..."
+$LTTNG_BIN create ${SESSION_NAME} --snapshot -U ${SNAPSHOT_PATH}
+$LTTNG_BIN enable-event ${EVENT_NAME} -k -s ${SESSION_NAME}
+$LTTNG_BIN start ${SESSION_NAME}
 
 echo "Sleeping..."
 sleep 10
 
 echo "Sleeping..."
 sleep 10
@@ -37,7 +42,8 @@ $(dirname $0)/crash
 echo "Sleeping..."
 sleep 10
 
 echo "Sleeping..."
 sleep 10
 
-$LTTNG_BIN stop
-$LTTNG_BIN destroy
+$LTTNG_BIN stop ${SESSION_NAME}
+$LTTNG_BIN destroy ${SESSION_NAME}
 
 
-echo "Core dump and snapshot will be available in /tmp/lttng/{core,snapshot}."
+echo "Core dump will be available in /tmp/lttng/core."
+echo "Snapshot will be available in ${SNAPSHOT_PATH}."
This page took 0.028855 seconds and 4 git commands to generate.