#!/bin/sh
#
# This script is used to watch for slab leaks when the
# kernel is built with CONFIG_DEBUG_SLAB_LEAK=y.
#
# Steve Grubb <sgrubb@redhat.com>
#

if [ ! -e /proc/slab_allocators ] ; then
	echo "Kernel does not seem to be compiled with CONFIG_DEBUG_SLAB_LEAK=y"
	exit 1
fi

trap "rm -f slab.tmp; exit 1" 1 2 3 5 15

while [ 1 ]
do
	echo -e "\n"
	cat /proc/slab_allocators > slab.tmp
	diff -u --minimal slab_last.tmp slab.tmp > slab.diff
	mv slab.tmp slab_last.tmp
	cat slab.diff | egrep -v '^ |^@' | awk 'NR > 2 { printf "%-25s %-8s\t%s\n", $1, $2, $3 }'
	sleep 5
done