Skip to content

Commit

Permalink
Add namespace of the process in the coredump filename. (sonic-net#1091)
Browse files Browse the repository at this point in the history
Look for namespace of this process in crashing process's environ file.If any, add it to core filename as
< binary name >.< timestamp >.< local pid inside container >.< ns > .core.gz.
e.g. orchagent.1599073263.45.5.core.gz <-- 5 is the asic namespace.

For processes that don't have asic namespace, there is no change.
e.g. snmpd.1599073245.27.core.gz

The /etc/sysctl.conf kernel.core_pattern is set to pass pid in host
as last arg.
  • Loading branch information
renukamanavalan authored Sep 3, 2020
1 parent 12f0d07 commit 5aa3e88
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/coredump-compress
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

# Collect all parameters in order and build a file name prefix
PREFIX=""
while [[ $# > 0 ]]; do
while [[ $# > 1 ]]; do
PREFIX=${PREFIX}$1.
shift
done

if [ $# > 0 ]; then
ns=`xargs -0 -L1 -a /proc/${1}/environ | grep -e "^NAMESPACE_ID" | cut -f2 -d'='`
if [ ! -z ${ns} ]; then
PREFIX=${PREFIX}${ns}.
fi
fi

/bin/gzip -1 - > /var/core/${PREFIX}core.gz

0 comments on commit 5aa3e88

Please sign in to comment.