PERFORCE change 188203 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Wed Jan 26 19:38:36 UTC 2011
http://p4web.freebsd.org/@@188203?ac=10
Change 188203 by trasz at trasz_victim on 2011/01/26 19:38:04
Optimize a little, using shell string manipulation instead of sed.
Affected files ...
.. //depot/projects/soc2009/trasz_limits/usr.bin/jailstat/jailstat.sh#2 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/usr.bin/jailstat/jailstat.sh#2 (text+ko) ====
@@ -34,6 +34,16 @@
exit 1
}
+get_limit() {
+ rule=`rctl $hflag $1`
+ if [ -z "$rule" ]; then
+ echo "-"
+ else
+ amount="${rule##*=}"
+ echo "$amount"
+ fi
+}
+
hflag="-h"
while getopts 's' cmd_arg; do
@@ -66,14 +76,10 @@
# Put resource=value pairs into environment variables.
eval `rctl $hflag -u j:$jail`
- pctcpulimit=`rctl $hflag j:$jail:pctcpu:deny=/jail | sed 's/.*=//'`
- : ${pctcpulimit:="-"}
- rsslimit=`rctl $hflag j:$jail:rss:deny=/jail | sed 's/.*=//'`
- : ${rsslimit:="-"}
- vmemlimit=`rctl $hflag j:$jail:vmem:deny=/jail | sed 's/.*=//'`
- : ${vmemlimit:="-"}
- swaplimit=`rctl $hflag j:$jail:swap:deny=/jail | sed 's/.*=//'`
- : ${swaplimit:="-"}
+ pctcpulimit=`get_limit j:$jail:pctcpu:deny=/jail`
+ rsslimit=`get_limit j:$jail:rss:deny=/jail`
+ vmemlimit=`get_limit j:$jail:vmem:deny=/jail`
+ swaplimit=`get_limit j:$jail:swap:deny=/jail`
printf "%s\t\%s\t\%s\t\%s\t\%s\t\%s\t\%s\t\%s\t\%s\n" "$jail" "$pctcpu" "$pctcpulimit" "$rss" "$rsslimit" "$vmem" "$vmemlimit" "$swap" "$swaplimit"
done
@@ -85,14 +91,10 @@
# Put resource=value pairs into environment variables.
eval `rctl $hflag -u u:$user`
- pctcpulimit=`rctl $hflag u:$user:pctcpu:deny=/user | sed 's/.*=//'`
- : ${pctcpulimit:="-"}
- rsslimit=`rctl $hflag u:$user:rss:deny=/user | sed 's/.*=//'`
- : ${rsslimit:="-"}
- vmemlimit=`rctl $hflag u:$user:vmem:deny=/user | sed 's/.*=//'`
- : ${vmemlimit:="-"}
- swaplimit=`rctl $hflag u:$user:swap:deny=/user | sed 's/.*=//'`
- : ${swaplimit:="-"}
+ pctcpulimit=`get_limit u:$user:pctcpu:deny=/user`
+ rsslimit=`get_limit u:$user:rss:deny=/user`
+ vmemlimit=`get_limit u:$user:vmem:deny=/user`
+ swaplimit=`get_limit u:$user:swap:deny=/user`
printf "%s\t\%s\t\%s\t\%s\t\%s\t\%s\t\%s\t\%s\t\%s\n" "$user" "$pctcpu" "$pctcpulimit" "$rss" "$rsslimit" "$vmem" "$vmemlimit" "$swap" "$swaplimit"
done
@@ -109,4 +111,3 @@
[ "$count" -gt 0 -a "$n" -ge "$count" ] && break
sleep "$wait"
done
-
More information about the p4-projects
mailing list