diff options
author | Adrian Schröter <adrian@suse.de> | 2012-10-15 15:24:54 +0200 |
---|---|---|
committer | Adrian Schröter <adrian@suse.de> | 2012-10-15 15:24:54 +0200 |
commit | 0cc887a7ee24d23d4dbf7a275843c5535826ceec (patch) | |
tree | 19fb1e49b2ee707886369ada6ad277bc55e9bc80 | |
parent | f58b01d670ddb9e14920e2e6f65a094c46def28d (diff) | |
download | build-0cc887a7ee24d23d4dbf7a275843c5535826ceec.tar.gz build-0cc887a7ee24d23d4dbf7a275843c5535826ceec.tar.bz2 build-0cc887a7ee24d23d4dbf7a275843c5535826ceec.zip |
monitor also memory usage in vm builds
-rwxr-xr-x | build | 40 |
1 files changed, 35 insertions, 5 deletions
@@ -606,13 +606,37 @@ vm_img_mkfs() background_monitor_process() { max=0 + max_mem=0 while sleep 5; do - - c=(`df -m $1 | tail -n 1`) - if [ ${c[2]} -gt $max ]; then - max="${c[2]}" - echo $max > /.build/_statistics.df + # memory usage + if [ -e /proc/meminfo ]; then + memtotal=0 + while read key value unit; do + case $key in + MemTotal:|SwapTotal:) + memtotal=$(( $memtotal + $value )) + ;; + MemFree:|SwapFree:|SwapCached:|Cached:|Buffers:) + memtotal=$(( $memtotal - $value )) + ;; + esac + done < /proc/meminfo + + if [ ${memtotal} -gt $max_mem ]; then + max_mem="${memtotal}" + echo $(( $max_mem / 1024 )) > /.build/_statistics.memory + fi + fi + + # disk storage usage + if [ -x /usr/bin/df ]; then + c=(`/usr/bin/df -m $1 | tail -n 1`) + + if [ ${c[2]} -gt $max ]; then + max="${c[2]}" + echo $max > /.build/_statistics.df + fi fi done } @@ -2362,6 +2386,12 @@ if test -n "$RUNNING_IN_VM" -a -n "$VM_SWAP"; then if [ -e /.build/_statistics.df ]; then echo -n "MAX_mb_used_on_disk: " >> $TOPDIR/OTHER/_statistics cat /.build/_statistics.df >> $TOPDIR/OTHER/_statistics + rm /.build/_statistics.df + fi + if [ -e /.build/_statistics.memory ]; then + echo -n "MAX_mb_used_memory: " >> $TOPDIR/OTHER/_statistics + cat /.build/_statistics.memory >> $TOPDIR/OTHER/_statistics + rm /.build/_statistics.memory fi mount -n sys /sys -t sysfs device="sda" |