core detection and alerting fixes

This commit is contained in:
Brian Rasmusson
2016-07-09 14:22:46 +02:00
parent da4e1b8522
commit acd685186a

@ -23,15 +23,18 @@ function get_cpu_affinity() {
function send_alert() {
# if slacktee is present, send alert using Slack
if [ -f "slacktee.sh" ] && [ -f "slacktee.conf" ]; then
echo -e "`hostname`:`pwd`: $1\n\n" > lastcore.alert.txt
# ls -tr log*|tail -1|xargs tail -30 >> lastcore.alert.txt
# Send single-line alert to make sure it is received
echo -e "`hostname`:`pwd`: $1" | ./slacktee.sh --config ./slacktee.conf
echo > lastcore.alert.txt
ls -tr log*|tail -1|xargs tail -100 >> lastcore.alert.txt
# if core is there, send first 20 lines of backtrace
if [ -f "core" ]; then
gdb --batch --quiet -ex "bt full" -ex "quit" ./gb ./core | grep -v LWP | head -20 >> lastcore.alert.txt
echo -e "\nStack trace:\n" >> lastcore.alert.txt
gdb --batch --quiet -ex "bt" -ex "quit" ./gb ./core | grep -v LWP | head -20 >> lastcore.alert.txt
fi
cat lastcore.alert.txt | ./slacktee.sh --config ./slacktee.conf
cat lastcore.alert.txt | ./slacktee.sh --config ./slacktee.conf --plain-text
fi
}
@ -49,7 +52,8 @@ function backup_core() {
function backup_core_and_alert_if_found() {
if [ -f "core" ]; then
file core|grep ./gb
# Use gdb to determine core creator. file was not reliable.
gdb --batch --quiet -ex "bt" -ex "quit" ./gb ./core 2>/dev/null|grep -i "generated by"|grep ./gb
EXITSTATUS=$?
if [ $EXITSTATUS = 0 ]; then
# core is ours