socsvn commit: r238763 - soc2012/rudot/aux
rudot at FreeBSD.org
rudot at FreeBSD.org
Mon Jul 2 07:26:31 UTC 2012
Author: rudot
Date: Mon Jul 2 07:26:29 2012
New Revision: 238763
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238763
Log:
small fixes
Modified:
soc2012/rudot/aux/psSum.sh
Modified: soc2012/rudot/aux/psSum.sh
==============================================================================
--- soc2012/rudot/aux/psSum.sh Mon Jul 2 07:25:17 2012 (r238762)
+++ soc2012/rudot/aux/psSum.sh Mon Jul 2 07:26:29 2012 (r238763)
@@ -1,5 +1,7 @@
FILE_UNSORTED=data.txt
FILE_SORTED=dataSorted.txt
+FILE_PLOT=plot.eps
+DELAY_SLOT=10
if [ -z "$1" ]; then
echo "Usage: $0 user"
@@ -26,6 +28,7 @@
{
sort_results
command -v gnuplot > /dev/null && plot_graph
+ echo "Exiting..."
exit 0
}
@@ -39,7 +42,7 @@
XLIMITB=`echo $PCPU_MAX | awk '{print int($1) + 1}'`
- gnuplot > plot.eps <<-EOF
+ gnuplot > $FILE_PLOT <<-EOF
set term postscript eps enhanced color
set style line 1 lt 1 lw 1
set xlabel "CPU percentage"
@@ -52,15 +55,24 @@
trap finalize SIGINT
+rm -f $FILE_UNSORTED
+rm -f $FILE_SORTED
+rm -f $FILE_PLOT
+
echo "Type [Ctrl + c] to exit"
echo "Scanning..."
while :
do
PCPU=`user_pcpu "$USER"`
+
+ if [ "$PCPU" = "0" ]; then
+ sleep $DELAY_SLOT
+ continue
+ fi
# Escape the decimal point because grep treats it as meta-character.
- PCPU_GREP=`echo $PCPU | sed 's:\.:\\\.:'`
+ PCPU_ESC=`echo $PCPU | sed 's:\.:\\\.:'`
[ -z "$PCPU_MIN" ] && PCPU_MIN=$PCPU
[ -z "$PCPU_MAX" ] && PCPU_MAX=$PCPU
@@ -74,18 +86,26 @@
`IFS=:; echo $PCPU_MIN_MAX`
EOF
- LINE=`cat $FILE_UNSORTED 2> /dev/null | grep "^${PCPU_GREP}:"`
+ LINE=`cat $FILE_UNSORTED 2> /dev/null | grep "^${PCPU_ESC}:"`
+
+ NLINES=`echo "$LINE" | wc -l`
+ if [ "$NLINES" -gt 1 ]; then
+ cat $FILE_UNSORTED > debug
+ echo "$PCPU" >> debug
+ echo "$PCPU_ESC" >> debug
+ echo "$LINE" >> debug
+ fi
if [ -n "$LINE" ]; then
CNT=`echo "$LINE" | cut -d : -f 2`
NEW_CNT=`expr "$CNT" + 1`
ed -s data.txt <<-EOF
- ,s/${PCPU}:${CNT}/${PCPU}:${NEW_CNT}/
+ ,s/^${PCPU_ESC}:${CNT}/${PCPU}:${NEW_CNT}/
wq
EOF
else
echo "$PCPU:1" >> $FILE_UNSORTED
fi
- sleep 10
+ sleep $DELAY_SLOT
done
More information about the svn-soc-all
mailing list