On Mar 6, 2008, at 5:27 PM, Dustin Sallings wrote:
For those of us who haven't truly unleashed the power of dtrace,
can you describe the kinds of things we can learn from this (perhaps
with scripts)?
The following script will monitor the hash-table and dump out the "top
ten" requested keys and the distribution in of the "search-depth"
every 10 seconds:
#! /usr/bin/ksh
pid=`pgrep -x memcached`
if [ -z "${pid}" ]
then
echo memcached not running
exit 1
fi
file /proc/${pid}/path/a.out | grep "ELF 64" > /dev/zero 2>&1
if [ $? -ne 0 ]
then
mode="-32"
else
mode="-64"
fi
/usr/sbin/dtrace ${mode} -n '
#pragma D option quiet
memcached'${pid}':::assoc-find
{
@assK[copyinstr(arg0)] = count();
@assD = quantize(arg1);
}
tick-10s
{
printf("Top 10 keys\n");
trunc(@assK, 10);
printa(@assK);
trunc(@assK, 0);
printf("assoc-find depth\n");
printa(@assD);
clear(@assD);
}
END {
trunc(@assK, 10);
printa(@assK);
trunc(@assK, 0);
printf("assoc-find depth\n");
printa(@assD);
clear(@assD);
}
'