mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
60 lines
1.3 KiB
Bash
Executable file
60 lines
1.3 KiB
Bash
Executable file
#! /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
|
|
}
|
|
|
|
fill_in_default()
|
|
{
|
|
/sbin/uci add system log
|
|
/sbin/uci rename system.@log[-1]=corelog
|
|
/sbin/uci set system.corelog.enable=no
|
|
/sbin/uci set system.corelog.server="crash.inteno.se"
|
|
/sbin/uci commit
|
|
}
|
|
|
|
# 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
|
|
;;
|
|
"")
|
|
fill_in_default
|
|
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.serial_number)
|
|
hw=$(db get hw.board.model_name)
|
|
fam=$(hw.board.iopVerFam)
|
|
sw=$(db get hw.board.iopVersion)
|
|
|
|
scp -S /usr/sbin/logssh $TMP_CORE log@${server}:log/core_${1}_${2}_${fam}_${hw}_${sw}_${nr}
|
|
rm $TMP_CORE
|
|
|