diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | changes/feature_nice-process | 1 | ||||
| -rwxr-xr-x | pkg/scripts/monitor_resource.zsh | 26 | ||||
| -rw-r--r-- | src/leap/bitmask/app.py | 5 | 
5 files changed, 47 insertions, 1 deletions
| @@ -4,6 +4,7 @@  *.log  *.lprof  *.pstats +*.data  *.*~  .*  *_rc.py @@ -33,3 +34,4 @@ config/*  CHANGELOG~  data/bitmask.pro +bitmask-resources.png @@ -43,6 +43,10 @@ ifndef EDITOR  	export EDITOR=vim  endif +ifndef RESOURCE_TIME +	export RESOURCE_TIME=10 +endif +  #  all : resources ui @@ -72,10 +76,18 @@ mailprofile:  	gprof2dot -f pstats /tmp/leap_mail_profile.pstats -n 0.2 -e 0.2 | dot -Tpdf -o /tmp/leap_mail_profile.pdf  do_lineprof: -	LEAP_PROFILE_IMAPCMD=1 LEAP_MAIL_MANHOLE=1 kernprof.py -l src/leap/bitmask/app.py --offline --debug +	LEAP_PROFILE_IMAPCMD=1 LEAP_MAIL_MANHOLE=1 kernprof.py -l src/leap/bitmask/app.py --debug + +do_lineprof_offline: +	LEAP_PROFILE_IMAPCMD=1 LEAP_MAIL_MANHOLE=1 kernprof.py -l src/leap/bitmask/app.py --offline --debug -N  view_lineprof:  	@python -m line_profiler app.py.lprof | $(EDITOR) - +resource_graph: +	#./pkg/scripts/monitor_resource.zsh `ps aux | grep app.py | head -1 | awk '{print $$2}'` $(RESOURCE_TIME) +	./pkg/scripts/monitor_resource.zsh `pgrep bitmask` $(RESOURCE_TIME) +	display bitmask-resources.png +  clean :  	$(RM) $(COMPILED_UI) $(COMPILED_RESOURCES) $(COMPILED_UI:.py=.pyc) $(COMPILED_RESOURCES:.py=.pyc) diff --git a/changes/feature_nice-process b/changes/feature_nice-process new file mode 100644 index 00000000..3de26e75 --- /dev/null +++ b/changes/feature_nice-process @@ -0,0 +1 @@ +- Add ability to nice application via environment variable. diff --git a/pkg/scripts/monitor_resource.zsh b/pkg/scripts/monitor_resource.zsh new file mode 100755 index 00000000..ac468e34 --- /dev/null +++ b/pkg/scripts/monitor_resource.zsh @@ -0,0 +1,26 @@ +#!/bin/zsh +if (( ! $# )); then +    echo "Usage: $0:t <PID> <minutes to monitor>" >&2 +    return 1; +fi + +OUT="$1-usage.data" +GRAPH="bitmask-resources.png" +MAX=150 +let "ticks=$2*60/3" +echo "cpu mem" >> $OUT +for i in {1..$ticks}; do; +    cpu=$(ps -p $1 -o pcpu | grep -v %) +    mem=$(ps wuh -p $1 | awk '{print $4}') +    echo "$cpu $mem" >> $OUT; +    sleep 3; +    echo $i / $ticks; +done; + +gnuplot -e "set term dumb; \ +set key outside; set yrange [0:$MAX]; \ +plot for [col=1:2] '$OUT' using 0:col title columnheader s c" + +gnuplot -e "set term png; set output '$GRAPH'; \ +set key outside; set yrange [0:$MAX]; \ +plot for [col=1:2] '$OUT' using 0:col with lines title columnheader" diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py index a1f3a69f..124671b3 100644 --- a/src/leap/bitmask/app.py +++ b/src/leap/bitmask/app.py @@ -233,6 +233,11 @@ def main():          # We don't even have logger configured in here          print "Could not ensure server: %r" % (e,) +    PLAY_NICE = os.environ.get("LEAP_NICE") +    if PLAY_NICE and PLAY_NICE.isdigit(): +        nice = os.nice(int(PLAY_NICE)) +        logger.info("Setting NICE: %s" % nice) +      # And then we import all the other stuff      # I think it's safe to import at the top by now -- kali      from leap.bitmask.gui import locale_rc | 
