Skip to content

Commit

Permalink
- fix mount of /sys for getting IO statistics
Browse files Browse the repository at this point in the history
- adapt it for more udev versions
- make statistics code a bit more robust
  • Loading branch information
adrianschroeter committed May 17, 2013
1 parent 3ca1fef commit 23029f4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions build
Expand Up @@ -720,7 +720,7 @@ background_monitor_process()

if [ ${memtotal} -gt $max_mem ]; then
max_mem="${memtotal}"
echo -n $(( $max_mem / 1024 )) > /.build/_statistics.memory
echo -n $(( $max_mem / 1024 )) > /.build/_statistics.memory.new && mv /.build/_statistics.memory.new /.build/_statistics.memory
fi
fi

Expand All @@ -730,7 +730,7 @@ background_monitor_process()

if [ ${c[2]} -gt $max_disk ]; then
max_disk="${c[2]}"
echo -n $max_disk > /.build/_statistics.df
echo -n $max_disk > /.build/_statistics.df.new && mv /.build/_statistics.df.new /.build/_statistics.df
fi
fi

Expand Down Expand Up @@ -2514,6 +2514,7 @@ for SPECFILE in "${SPECFILES[@]}" ; do
done
if test "$statistics" = 1; then
mkdir -p OTHER
[ -e _statistics ] && mv _statistics OTHER/
[ -n "$TIME_PREINSTALL" ] && echo "TIME_preinstall: $TIME_PREINSTALL" >> OTHER/_statistics
TIME_TOTAL=$(( `date +%s` - $TIME_START_TIME ))
echo "TIME_total: $TIME_TOTAL" >> OTHER/_statistics
Expand Down Expand Up @@ -3139,15 +3140,22 @@ if test -n "$RUNNING_IN_VM"; then
echo "" >> $TOPDIR/OTHER/_statistics
rm /.build/_statistics.memory
fi
mkdir -p /sys
mount -n sys /sys -t sysfs
device="sda"
device="hda1"
[ -e /dev/sda ] && device="sda"
[ -e /dev/vda ] && device="vda"
[ -e /dev/dasda ] && device="dasda" # in z/VM
disk=(`cat /sys/block/${device}/stat`)
[ "0${disk[0]}" -gt 0 ] && echo "IO_requests_read: ${disk[0]}" >> $TOPDIR/OTHER/_statistics
[ "0${disk[2]}" -gt 0 ] && echo "IO_sectors_read: ${disk[2]}" >> $TOPDIR/OTHER/_statistics
[ "0${disk[4]}" -gt 0 ] && echo "IO_requests_write: ${disk[4]}" >> $TOPDIR/OTHER/_statistics
[ "0${disk[6]}" -gt 0 ] && echo "IO_sectors_write: ${disk[6]}" >> $TOPDIR/OTHER/_statistics
if [ -e /sys/block/${device}/stat ]; then
disk=(`cat /sys/block/${device}/stat`)
[ "0${disk[0]}" -gt 0 ] && echo "IO_requests_read: ${disk[0]}" >> $TOPDIR/OTHER/_statistics
[ "0${disk[2]}" -gt 0 ] && echo "IO_sectors_read: ${disk[2]}" >> $TOPDIR/OTHER/_statistics
[ "0${disk[4]}" -gt 0 ] && echo "IO_requests_write: ${disk[4]}" >> $TOPDIR/OTHER/_statistics
[ "0${disk[6]}" -gt 0 ] && echo "IO_sectors_write: ${disk[6]}" >> $TOPDIR/OTHER/_statistics
else
echo "ERROR: no root disk device found, yet another new device name?"
ls -l /sys/block/
fi
umount /sys
fi

Expand Down

0 comments on commit 23029f4

Please sign in to comment.