PERFORCE change 187783 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Thu Jan 13 22:34:09 UTC 2011
http://p4web.freebsd.org/@@187783?ac=10
Change 187783 by trasz at trasz_victim on 2011/01/13 22:33:09
u
Affected files ...
.. //depot/projects/soc2009/trasz_limits/usr.bin/userstat/userstat.sh#4 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/usr.bin/userstat/userstat.sh#4 (text+ko) ====
@@ -29,10 +29,6 @@
#
# $FreeBSD$
-format_stats() {
- awk -F= '/^pctcpu/ { pctcpu=$2 } /^rss/ { rss=$2 } /^vmem/ { vmem=$2 } /^swap/ { swap=$2 } END { printf "%s\t%s\t%s\t%s\n", pctcpu, rss, vmem, swap }'
-}
-
usage() {
echo "usage: `basename $0` [-h] [wait [count]]"
exit 1
@@ -57,18 +53,32 @@
while :; do
if [ "`basename $0`" = "jailstat" ]; then
jails="`ps ax -o jid= | sort -u | sed 1d`"
- printf "JID\t%%CPU\tRSS\tVSIZE\tSWAP\n"
+ printf "JID\t%%CPU\tLIMIT\tRSS\tLIMIT\tVMEM\tLIMIT\tSWAP\tLIMIT\n"
for jail in $jails; do
- printf "$jail\t"
- rctl $hflag -u j:$jail | format_stats
+ # Put resource=value pairs into environment variables.
+ eval `rctl $hflag -u j:$jail`
+
+ pctcpulimit=`rctl j:$jail:pctcpu:deny=/jail | sed 's/.*=//'`
+ rsslimit=`rctl j:$jail:rss:deny=/jail | sed 's/.*=//'`
+ vmemlimit=`rctl j:$jail:vmem:deny=/jail | sed 's/.*=//'`
+ swaplimit=`rctl j:$jail:swap:deny=/jail | sed 's/.*=//'`
+
+ 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
else
users="`ps ax -o user= | sort -u`"
- printf "USER\t%%CPU\tRSS\tVSIZE\tSWAP\n"
+ printf "USER\t%%CPU\tLIMIT\tRSS\tLIMIT\tVMEM\tLIMIT\tSWAP\tLIMIT\n"
for user in $users; do
- printf "$user\t"
- rctl $hflag -u u:$user | format_stats
+ # Put resource=value pairs into environment variables.
+ eval `rctl $hflag -u u:$user`
+
+ pctcpulimit=`rctl u:$user:pctcpu:deny=/user | sed 's/.*=//'`
+ rsslimit=`rctl u:$user:rss:deny=/user | sed 's/.*=//'`
+ vmemlimit=`rctl u:$user:vmem:deny=/user | sed 's/.*=//'`
+ swaplimit=`rctl u:$user:swap:deny=/user | sed 's/.*=//'`
+
+ 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
fi
More information about the p4-projects
mailing list