Hooking up core dump before apport [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm hooked up coredump generation for my application on remote Ubuntu system.



I did it with adding into /proc/sys/kernel/core_pattern path to my coredumper bash script.



"|/some/.../path/my_coredump_collector.sh %P %p %s %c %d %e %E %t %g %h %i %I %u"


This script writing coredump to the file, packing it to the tar.gz archive with generated info file and sending it to my remote machine using scp.



Script should work only for my application and should call default coredump handler for others.



To achive this I stored previous content of /proc/sys/kernel/core_pattern with all flags in the variable. For this particular system default handler was apport:



"|/usr/share/apport/apport %p %s %c %d %P"


I make substitution for command line variables with sed to replace %symbol with actual value of given variable.



At the end I just call default handler with replaces and piping coredump file content into this handler.



But seems like apport don't wan't to work this way. I can't understand what I did wrong. I provided valid parameters and coredump input.



My scrip looks like this:



#!/bin/sh

PREV_COMMAND="|/usr/share/apport/apport %p %s %c %d %P"
WORK_DIR="/path/to/my/script/file"
DESTINATION="username@hostname:/path/to/store/core/dumps"
SSH_KEY="/path/to/ssh/key"

COREDIR_NAME="$6.$1.$8.core"
TIMESTAMP=$(date --date="@$8")

COREDIR="$WORK_DIR/$COREDIR_NAME"

INFOHEADER_FILE="$COREDIR/core.info"
COREFILE="$COREDIR/core.dump"

###############################
## 1 P
## 2 p
## 3 s
## 4 c
## 5 d
## 6 e
## 7 E
## 8 t
## 9 g
## 10 h
## 11 i
## 12 I
## 13 u
###############################

PREV_COMMAND=$(echo $PREV_COMMAND | sed 's/|//g')
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%P/$1/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%p/$2/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%s/$3/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%c/$4/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%d/$5/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%e/$6/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%E/$7/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%t/$8/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%g/$9/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%h/$10/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%i/$11/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%I/$12/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%u/$13/g")

if [ "$6" != "my_app1" -a "$6" != "my_app2" -a "$6" != "my_app3" ]
then
cat | "$PREV_COMMAND" # don't work
exit 0
fi

mkdir $COREDIR

echo "PID: $1" > $INFOHEADER_FILE
echo "pid: $2" >> $INFOHEADER_FILE
echo "SIGNALCODE: $3" >> $INFOHEADER_FILE
echo "DumpSize: $4" >> $INFOHEADER_FILE
echo "DumpMode: $5" >> $INFOHEADER_FILE
echo "Executable: $6" >> $INFOHEADER_FILE
echo "Path: $(echo $7 | sed 's/!///g')" >> $INFOHEADER_FILE
echo "Date: $TIMESTAMP" >> $INFOHEADER_FILE
echo "GID: $9" >> $INFOHEADER_FILE
echo "Hostname: $10" >> $INFOHEADER_FILE
echo "tid: $11" >> $INFOHEADER_FILE
echo "TID: $12" >> $INFOHEADER_FILE
echo "UID: $13" >> $INFOHEADER_FILE

cat > $COREFILE

cd $WORK_DIR
tar -zcf $COREDIR.tar.gz $COREDIR_NAME
cd -

#rsync -av -e "ssh -i $SSH_KEY" $COREDIR.tar.gz $DESTINATION &> $WORK_DIR/rsync.log # rsync don't want work here :(
scp -i $SSH_KEY $COREDIR.tar.gz $DESTINATION

cat $COREFILE | "$PREV_COMMAND" # don't work too.

rm -rf $COREDIR.tar.gz $COREDIR


I don't want use apport generated coredump for my purposes. This script in ideal case should work on any system wich support /proc/sys/kernel/core_pattern with any default coredump handler.







share|improve this question












closed as off-topic by sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller Nov 30 '17 at 11:38


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller
If this question can be reworded to fit the rules in the help center, please edit the question.












  • How can I delete the question? Probably question become useless for other people now.
    – Yuri Dolotkazin
    Nov 29 '17 at 19:32











  • Not surely, I suggest to leave open. You should first delete your answer, then you will be able to delete the question. But I think you shouldn't.
    – peterh
    Nov 29 '17 at 23:26














up vote
1
down vote

favorite












I'm hooked up coredump generation for my application on remote Ubuntu system.



I did it with adding into /proc/sys/kernel/core_pattern path to my coredumper bash script.



"|/some/.../path/my_coredump_collector.sh %P %p %s %c %d %e %E %t %g %h %i %I %u"


This script writing coredump to the file, packing it to the tar.gz archive with generated info file and sending it to my remote machine using scp.



Script should work only for my application and should call default coredump handler for others.



To achive this I stored previous content of /proc/sys/kernel/core_pattern with all flags in the variable. For this particular system default handler was apport:



"|/usr/share/apport/apport %p %s %c %d %P"


I make substitution for command line variables with sed to replace %symbol with actual value of given variable.



At the end I just call default handler with replaces and piping coredump file content into this handler.



But seems like apport don't wan't to work this way. I can't understand what I did wrong. I provided valid parameters and coredump input.



My scrip looks like this:



#!/bin/sh

PREV_COMMAND="|/usr/share/apport/apport %p %s %c %d %P"
WORK_DIR="/path/to/my/script/file"
DESTINATION="username@hostname:/path/to/store/core/dumps"
SSH_KEY="/path/to/ssh/key"

COREDIR_NAME="$6.$1.$8.core"
TIMESTAMP=$(date --date="@$8")

COREDIR="$WORK_DIR/$COREDIR_NAME"

INFOHEADER_FILE="$COREDIR/core.info"
COREFILE="$COREDIR/core.dump"

###############################
## 1 P
## 2 p
## 3 s
## 4 c
## 5 d
## 6 e
## 7 E
## 8 t
## 9 g
## 10 h
## 11 i
## 12 I
## 13 u
###############################

PREV_COMMAND=$(echo $PREV_COMMAND | sed 's/|//g')
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%P/$1/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%p/$2/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%s/$3/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%c/$4/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%d/$5/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%e/$6/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%E/$7/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%t/$8/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%g/$9/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%h/$10/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%i/$11/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%I/$12/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%u/$13/g")

if [ "$6" != "my_app1" -a "$6" != "my_app2" -a "$6" != "my_app3" ]
then
cat | "$PREV_COMMAND" # don't work
exit 0
fi

mkdir $COREDIR

echo "PID: $1" > $INFOHEADER_FILE
echo "pid: $2" >> $INFOHEADER_FILE
echo "SIGNALCODE: $3" >> $INFOHEADER_FILE
echo "DumpSize: $4" >> $INFOHEADER_FILE
echo "DumpMode: $5" >> $INFOHEADER_FILE
echo "Executable: $6" >> $INFOHEADER_FILE
echo "Path: $(echo $7 | sed 's/!///g')" >> $INFOHEADER_FILE
echo "Date: $TIMESTAMP" >> $INFOHEADER_FILE
echo "GID: $9" >> $INFOHEADER_FILE
echo "Hostname: $10" >> $INFOHEADER_FILE
echo "tid: $11" >> $INFOHEADER_FILE
echo "TID: $12" >> $INFOHEADER_FILE
echo "UID: $13" >> $INFOHEADER_FILE

cat > $COREFILE

cd $WORK_DIR
tar -zcf $COREDIR.tar.gz $COREDIR_NAME
cd -

#rsync -av -e "ssh -i $SSH_KEY" $COREDIR.tar.gz $DESTINATION &> $WORK_DIR/rsync.log # rsync don't want work here :(
scp -i $SSH_KEY $COREDIR.tar.gz $DESTINATION

cat $COREFILE | "$PREV_COMMAND" # don't work too.

rm -rf $COREDIR.tar.gz $COREDIR


I don't want use apport generated coredump for my purposes. This script in ideal case should work on any system wich support /proc/sys/kernel/core_pattern with any default coredump handler.







share|improve this question












closed as off-topic by sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller Nov 30 '17 at 11:38


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller
If this question can be reworded to fit the rules in the help center, please edit the question.












  • How can I delete the question? Probably question become useless for other people now.
    – Yuri Dolotkazin
    Nov 29 '17 at 19:32











  • Not surely, I suggest to leave open. You should first delete your answer, then you will be able to delete the question. But I think you shouldn't.
    – peterh
    Nov 29 '17 at 23:26












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm hooked up coredump generation for my application on remote Ubuntu system.



I did it with adding into /proc/sys/kernel/core_pattern path to my coredumper bash script.



"|/some/.../path/my_coredump_collector.sh %P %p %s %c %d %e %E %t %g %h %i %I %u"


This script writing coredump to the file, packing it to the tar.gz archive with generated info file and sending it to my remote machine using scp.



Script should work only for my application and should call default coredump handler for others.



To achive this I stored previous content of /proc/sys/kernel/core_pattern with all flags in the variable. For this particular system default handler was apport:



"|/usr/share/apport/apport %p %s %c %d %P"


I make substitution for command line variables with sed to replace %symbol with actual value of given variable.



At the end I just call default handler with replaces and piping coredump file content into this handler.



But seems like apport don't wan't to work this way. I can't understand what I did wrong. I provided valid parameters and coredump input.



My scrip looks like this:



#!/bin/sh

PREV_COMMAND="|/usr/share/apport/apport %p %s %c %d %P"
WORK_DIR="/path/to/my/script/file"
DESTINATION="username@hostname:/path/to/store/core/dumps"
SSH_KEY="/path/to/ssh/key"

COREDIR_NAME="$6.$1.$8.core"
TIMESTAMP=$(date --date="@$8")

COREDIR="$WORK_DIR/$COREDIR_NAME"

INFOHEADER_FILE="$COREDIR/core.info"
COREFILE="$COREDIR/core.dump"

###############################
## 1 P
## 2 p
## 3 s
## 4 c
## 5 d
## 6 e
## 7 E
## 8 t
## 9 g
## 10 h
## 11 i
## 12 I
## 13 u
###############################

PREV_COMMAND=$(echo $PREV_COMMAND | sed 's/|//g')
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%P/$1/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%p/$2/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%s/$3/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%c/$4/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%d/$5/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%e/$6/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%E/$7/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%t/$8/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%g/$9/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%h/$10/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%i/$11/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%I/$12/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%u/$13/g")

if [ "$6" != "my_app1" -a "$6" != "my_app2" -a "$6" != "my_app3" ]
then
cat | "$PREV_COMMAND" # don't work
exit 0
fi

mkdir $COREDIR

echo "PID: $1" > $INFOHEADER_FILE
echo "pid: $2" >> $INFOHEADER_FILE
echo "SIGNALCODE: $3" >> $INFOHEADER_FILE
echo "DumpSize: $4" >> $INFOHEADER_FILE
echo "DumpMode: $5" >> $INFOHEADER_FILE
echo "Executable: $6" >> $INFOHEADER_FILE
echo "Path: $(echo $7 | sed 's/!///g')" >> $INFOHEADER_FILE
echo "Date: $TIMESTAMP" >> $INFOHEADER_FILE
echo "GID: $9" >> $INFOHEADER_FILE
echo "Hostname: $10" >> $INFOHEADER_FILE
echo "tid: $11" >> $INFOHEADER_FILE
echo "TID: $12" >> $INFOHEADER_FILE
echo "UID: $13" >> $INFOHEADER_FILE

cat > $COREFILE

cd $WORK_DIR
tar -zcf $COREDIR.tar.gz $COREDIR_NAME
cd -

#rsync -av -e "ssh -i $SSH_KEY" $COREDIR.tar.gz $DESTINATION &> $WORK_DIR/rsync.log # rsync don't want work here :(
scp -i $SSH_KEY $COREDIR.tar.gz $DESTINATION

cat $COREFILE | "$PREV_COMMAND" # don't work too.

rm -rf $COREDIR.tar.gz $COREDIR


I don't want use apport generated coredump for my purposes. This script in ideal case should work on any system wich support /proc/sys/kernel/core_pattern with any default coredump handler.







share|improve this question












I'm hooked up coredump generation for my application on remote Ubuntu system.



I did it with adding into /proc/sys/kernel/core_pattern path to my coredumper bash script.



"|/some/.../path/my_coredump_collector.sh %P %p %s %c %d %e %E %t %g %h %i %I %u"


This script writing coredump to the file, packing it to the tar.gz archive with generated info file and sending it to my remote machine using scp.



Script should work only for my application and should call default coredump handler for others.



To achive this I stored previous content of /proc/sys/kernel/core_pattern with all flags in the variable. For this particular system default handler was apport:



"|/usr/share/apport/apport %p %s %c %d %P"


I make substitution for command line variables with sed to replace %symbol with actual value of given variable.



At the end I just call default handler with replaces and piping coredump file content into this handler.



But seems like apport don't wan't to work this way. I can't understand what I did wrong. I provided valid parameters and coredump input.



My scrip looks like this:



#!/bin/sh

PREV_COMMAND="|/usr/share/apport/apport %p %s %c %d %P"
WORK_DIR="/path/to/my/script/file"
DESTINATION="username@hostname:/path/to/store/core/dumps"
SSH_KEY="/path/to/ssh/key"

COREDIR_NAME="$6.$1.$8.core"
TIMESTAMP=$(date --date="@$8")

COREDIR="$WORK_DIR/$COREDIR_NAME"

INFOHEADER_FILE="$COREDIR/core.info"
COREFILE="$COREDIR/core.dump"

###############################
## 1 P
## 2 p
## 3 s
## 4 c
## 5 d
## 6 e
## 7 E
## 8 t
## 9 g
## 10 h
## 11 i
## 12 I
## 13 u
###############################

PREV_COMMAND=$(echo $PREV_COMMAND | sed 's/|//g')
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%P/$1/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%p/$2/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%s/$3/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%c/$4/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%d/$5/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%e/$6/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%E/$7/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%t/$8/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%g/$9/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%h/$10/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%i/$11/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%I/$12/g")
PREV_COMMAND=$(echo $PREV_COMMAND | sed "s/%u/$13/g")

if [ "$6" != "my_app1" -a "$6" != "my_app2" -a "$6" != "my_app3" ]
then
cat | "$PREV_COMMAND" # don't work
exit 0
fi

mkdir $COREDIR

echo "PID: $1" > $INFOHEADER_FILE
echo "pid: $2" >> $INFOHEADER_FILE
echo "SIGNALCODE: $3" >> $INFOHEADER_FILE
echo "DumpSize: $4" >> $INFOHEADER_FILE
echo "DumpMode: $5" >> $INFOHEADER_FILE
echo "Executable: $6" >> $INFOHEADER_FILE
echo "Path: $(echo $7 | sed 's/!///g')" >> $INFOHEADER_FILE
echo "Date: $TIMESTAMP" >> $INFOHEADER_FILE
echo "GID: $9" >> $INFOHEADER_FILE
echo "Hostname: $10" >> $INFOHEADER_FILE
echo "tid: $11" >> $INFOHEADER_FILE
echo "TID: $12" >> $INFOHEADER_FILE
echo "UID: $13" >> $INFOHEADER_FILE

cat > $COREFILE

cd $WORK_DIR
tar -zcf $COREDIR.tar.gz $COREDIR_NAME
cd -

#rsync -av -e "ssh -i $SSH_KEY" $COREDIR.tar.gz $DESTINATION &> $WORK_DIR/rsync.log # rsync don't want work here :(
scp -i $SSH_KEY $COREDIR.tar.gz $DESTINATION

cat $COREFILE | "$PREV_COMMAND" # don't work too.

rm -rf $COREDIR.tar.gz $COREDIR


I don't want use apport generated coredump for my purposes. This script in ideal case should work on any system wich support /proc/sys/kernel/core_pattern with any default coredump handler.









share|improve this question











share|improve this question




share|improve this question










asked Nov 29 '17 at 15:15









Yuri Dolotkazin

163




163




closed as off-topic by sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller Nov 30 '17 at 11:38


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller Nov 30 '17 at 11:38


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – sebasth, Stephen Rauch, Rahul, Archemar, Jeff Schaller
If this question can be reworded to fit the rules in the help center, please edit the question.











  • How can I delete the question? Probably question become useless for other people now.
    – Yuri Dolotkazin
    Nov 29 '17 at 19:32











  • Not surely, I suggest to leave open. You should first delete your answer, then you will be able to delete the question. But I think you shouldn't.
    – peterh
    Nov 29 '17 at 23:26
















  • How can I delete the question? Probably question become useless for other people now.
    – Yuri Dolotkazin
    Nov 29 '17 at 19:32











  • Not surely, I suggest to leave open. You should first delete your answer, then you will be able to delete the question. But I think you shouldn't.
    – peterh
    Nov 29 '17 at 23:26















How can I delete the question? Probably question become useless for other people now.
– Yuri Dolotkazin
Nov 29 '17 at 19:32





How can I delete the question? Probably question become useless for other people now.
– Yuri Dolotkazin
Nov 29 '17 at 19:32













Not surely, I suggest to leave open. You should first delete your answer, then you will be able to delete the question. But I think you shouldn't.
– peterh
Nov 29 '17 at 23:26




Not surely, I suggest to leave open. You should first delete your answer, then you will be able to delete the question. But I think you shouldn't.
– peterh
Nov 29 '17 at 23:26










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Problem was in quotes here:



cat | "$PREV_COMMAND"



Without quotes, everything work great.






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Problem was in quotes here:



    cat | "$PREV_COMMAND"



    Without quotes, everything work great.






    share|improve this answer


























      up vote
      1
      down vote













      Problem was in quotes here:



      cat | "$PREV_COMMAND"



      Without quotes, everything work great.






      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        Problem was in quotes here:



        cat | "$PREV_COMMAND"



        Without quotes, everything work great.






        share|improve this answer














        Problem was in quotes here:



        cat | "$PREV_COMMAND"



        Without quotes, everything work great.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 30 '17 at 11:38









        Jeff Schaller

        32.1k849109




        32.1k849109










        answered Nov 29 '17 at 19:32









        Yuri Dolotkazin

        163




        163












            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)