diff --git a/tools/dbench_monitor b/tools/dbench_monitor new file mode 100755 index 000000000..10726dc23 --- /dev/null +++ b/tools/dbench_monitor @@ -0,0 +1,102 @@ +#!/bin/bash +# +#(c) 2004-present, Facebook Inc. All rights reserved. +# +#see LICENSE file for more information on use/redistribution rights. +# + +# +#dbench_monitor: monitor db_bench process for violation of memory utilization +# +#default usage will monitor 'virtual memory size'. See below for standard options +#passed to db_bench during this test. +# +# See also: ./pflag for the actual monitoring script that does the work +# +#NOTE: +# You may end up with some /tmp/ files if db_bench OR +# this script OR ./pflag was killed unceremoniously +# +# If you see the script taking a long time, trying "kill" +# will usually cleanly exit. +# +# +DIR=`dirname $0` +LOG=/tmp/`basename $0`.$$ +DB_BENCH="$DIR/../db_bench"; +PFLAG=${DIR}/pflag + +usage() { + cat <$LOG 2>&1 & + +if [ $? -ne 0 ]; then + warn "WARNING: ${DB_BENCH} did not launch successfully! Abort!"; + exit; +fi +PID=$! + +# +#Start the monitoring. Default is "vsz" monitoring for upto cache_size ($cs) value of virtual mem +#You could also monitor RSS and CPUTIME (bsdtime). Try 'pflag -h' for how to do this +# +${PFLAG} -p $PID -v + +rm -f $LOG; diff --git a/tools/pflag b/tools/pflag new file mode 100755 index 000000000..adfac23bc --- /dev/null +++ b/tools/pflag @@ -0,0 +1,217 @@ +#!/bin/bash +# +#(c) 2004-present, Facebook, all rights reserved. +# See the LICENSE file for usage and distribution rights. +# + +trap 'echo "Caught exception, dying"; exit' 1 2 3 15 + +ME=`basename $0` +SERVER=`hostname` + +#parameters used +# +Dump_Config=0 +DEBUG= +OS=`/bin/uname -s` +VMEM= +RSS= +CPU= +VERBOSE= +VAR= +LIMIT= +ACTION= +N= +WAIT= + +# +#supported OS: Linux only for now. Easy to add +# +oscheck() { + case ${OS} in + Linux) + VMEM=vsz + RSS=rss + CPU=bsdtime + ;; + *) + die "Unsupported OS ${OS}. Send a bug report with OS you need supported. Thanks." + ;; + esac +} + + +verbose() { + if [ "x$DEBUG" != "x" ]; then + echo "$@" >&2 + fi +} + +warn() { + echo "$@" >&2 +} + +die() { + echo "ERROR: " "$@" >&2; + exit; +} + +dump_config() { + cat <