From c9f8a17880835ddd8a38d426808e46848d8a4743 Mon Sep 17 00:00:00 2001 From: Kenneth Johansson Date: Thu, 17 Sep 2015 19:23:59 +0200 Subject: [PATCH] crashlog: catch and store any code dump file. store the core on the crashlog server. --- bcmkernel/416030.mk | 2 +- crashlog/files/etc/init.d/corelog | 11 +++++++ crashlog/files/etc/init.d/crashlog | 4 +-- crashlog/files/sbin/logcore | 49 ++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100755 crashlog/files/etc/init.d/corelog create mode 100755 crashlog/files/sbin/logcore diff --git a/bcmkernel/416030.mk b/bcmkernel/416030.mk index bb54b5728..462023fd3 100644 --- a/bcmkernel/416030.mk +++ b/bcmkernel/416030.mk @@ -16,7 +16,7 @@ PKG_RELEASE:=1 PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.03 PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=c6cd2eb6b194e5a387949f59cbb1d754686e97ea +PKG_SOURCE_VERSION:=18d21ddf30d920cb8e6d2e9dd073ed10903deb20 PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz endif diff --git a/crashlog/files/etc/init.d/corelog b/crashlog/files/etc/init.d/corelog new file mode 100755 index 000000000..d312e6381 --- /dev/null +++ b/crashlog/files/etc/init.d/corelog @@ -0,0 +1,11 @@ +#!/bin/sh /etc/rc.common + +START=01 + +start() +{ + if [ -e /proc/sys/kernel/core_pattern ] + then + echo "|/sbin/logcore %e %s" > /proc/sys/kernel/core_pattern + fi +} diff --git a/crashlog/files/etc/init.d/crashlog b/crashlog/files/etc/init.d/crashlog index 51b16ba0b..ca030050c 100755 --- a/crashlog/files/etc/init.d/crashlog +++ b/crashlog/files/etc/init.d/crashlog @@ -9,7 +9,7 @@ send_log() hwv=$(db get hw.board.hardwareVersion) bid=$(db get hw.board.boardId) sw=$(db get hw.board.iopVersion) - server=$(/sbin/uci get system.cashlog.server) + server=$(/sbin/uci get system.crashlog.server) while true do @@ -26,7 +26,7 @@ send_log() boot() { # is crashlog enabled ? - enable=$(/sbin/uci get system.cashlog.enable) + enable=$(/sbin/uci get system.crashlog.enable) case $enable in 0|no|NO|false|FALSE) exit 0 diff --git a/crashlog/files/sbin/logcore b/crashlog/files/sbin/logcore new file mode 100755 index 000000000..d65bd2bfd --- /dev/null +++ b/crashlog/files/sbin/logcore @@ -0,0 +1,49 @@ +#! /bin/sh + +TMP_CORE=/tmp/new_core +# first test if we can contact the log server. +# if not abort directly the core file takes up memory +alive() +{ + ping -c1 $server + + if [ $? != 0 ] + then + # drain core file from kernel + cat >/dev/null + exit 0 + fi +} + + +# is corelog enabled ? +enable=$(/sbin/uci get system.corelog.enable) +case $enable in + 0|no|NO|false|FALSE|"") + # drain core file from kernel + cat >/dev/null + exit 0 + ;; +esac + +server=$(/sbin/uci get system.corelog.server) + +alive + +# dump out the core to disk we need this as scp needs a size before we send data +# and this is the only way to know how much data there is +cat >$TMP_CORE + +# in case filesystem/memory is full at least kill the core in the kernel memory should give us some +# more memory to work with. normally this would do nothing. +cat >/dev/null + +nr=$(db get hw.board.serialNumber) +hw=$(db get hw.board.hardware) +hwv=$(db get hw.board.hardwareVersion) +bid=$(db get hw.board.boardId) +sw=$(db get hw.board.iopVersion) + +scp -S /usr/sbin/logssh $TMP_CORE log@${server}:log/core_${1}_${2}_${bid}_${hwv}_${hw}_${sw}_${nr} +rm $TMP_CORE +