#!/bin/bash

# Creates core files for all running celery processes
# Can be large in size (multi-GB)

DUMPDIR=/var/tmp/pulp-celery-cores/
rm -rf $DUMPDIR
mkdir $DUMPDIR
for pid in $(ps -awfux| grep celery | grep "@" | awk '{ print $2 }'); do  gcore -o $DUMPDIR/core $pid; done
TGZ="/var/tmp/pulp-celery-cores.tar.gz"

tar cvzf $TGZ $DUMPDIR/*
echo "Core files saved to $TGZ"
rm -rf $DUMPDIR


