2012-01-05 16:24:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-04-19 22:09:01 +00:00
|
|
|
## ----------------------------------------------------------------------------
|
|
|
|
##
|
2012-04-21 19:20:39 +00:00
|
|
|
## hanoi: LSM-trees (Log-Structured Merge Trees) Indexed Storage
|
2012-04-19 22:09:01 +00:00
|
|
|
##
|
|
|
|
## Copyright 2011-2012 (c) Trifork A/S. All Rights Reserved.
|
|
|
|
## http://trifork.com/ info@trifork.com
|
|
|
|
##
|
|
|
|
## Copyright 2012 (c) Basho Technologies, Inc. All Rights Reserved.
|
|
|
|
## http://basho.com/ info@basho.com
|
|
|
|
##
|
|
|
|
## This file is provided to you under the Apache License, Version 2.0 (the
|
|
|
|
## "License"); you may not use this file except in compliance with the License.
|
|
|
|
## You may obtain a copy of the License at
|
|
|
|
##
|
|
|
|
## http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
##
|
|
|
|
## Unless required by applicable law or agreed to in writing, software
|
|
|
|
## distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
## WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
## License for the specific language governing permissions and limitations
|
|
|
|
## under the License.
|
|
|
|
##
|
|
|
|
## ----------------------------------------------------------------------------
|
|
|
|
|
2012-01-06 12:56:52 +00:00
|
|
|
function periodic() {
|
|
|
|
t=0
|
|
|
|
while sleep 1 ; do
|
2012-04-19 22:09:01 +00:00
|
|
|
let "t=t+1"
|
|
|
|
printf "%5d [" "$t"
|
2012-01-05 16:50:33 +00:00
|
|
|
|
2012-04-19 22:09:01 +00:00
|
|
|
for ((i=0; i<35; i++)) ; do
|
|
|
|
if ! [ -f "A-$i.data" ] ; then
|
|
|
|
echo -n " "
|
|
|
|
elif ! [ -f "B-$i.data" ] ; then
|
|
|
|
echo -n "-"
|
|
|
|
elif ! [ -f "C-$i.data" ] ; then
|
|
|
|
echo -n "#"
|
|
|
|
elif ! [ -f "X-$i.data" ] ; then
|
|
|
|
echo -n "="
|
|
|
|
else
|
|
|
|
echo -n "*"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo
|
2012-01-06 12:56:52 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-04-23 23:43:53 +00:00
|
|
|
merge_diff() {
|
|
|
|
SA=`ls -l A-${ID}.data 2> /dev/null | awk '{print $5}'`
|
|
|
|
SB=`ls -l B-${ID}.data 2> /dev/null | awk '{print $5}'`
|
|
|
|
SX=`ls -l X-${ID}.data 2> /dev/null | awk '{print $5}'`
|
|
|
|
if [ \( -n "$SA" \) -a \( -n "$SB" \) -a \( -n "$SX" \) ]; then
|
|
|
|
export RES=`expr ${SX}0 / \( $SA + $SB \)`
|
|
|
|
else
|
|
|
|
export RES="?"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-01-06 12:56:52 +00:00
|
|
|
function dynamic() {
|
|
|
|
local old s t start now
|
|
|
|
t=0
|
|
|
|
start=`date +%s`
|
|
|
|
while true ; do
|
2012-04-19 22:09:01 +00:00
|
|
|
s=""
|
2012-04-23 23:43:53 +00:00
|
|
|
for ((i=8; i<22; i++)) ; do
|
2012-04-22 21:53:31 +00:00
|
|
|
if [ -f "C-$i.data" ] ; then
|
|
|
|
s="${s}C"
|
2012-04-22 13:14:14 +00:00
|
|
|
else
|
2012-04-19 22:09:01 +00:00
|
|
|
s="$s "
|
2012-04-22 13:14:14 +00:00
|
|
|
fi
|
|
|
|
if [ -f "B-$i.data" ] ; then
|
|
|
|
s="${s}B"
|
2012-04-19 22:09:01 +00:00
|
|
|
else
|
2012-04-22 13:14:14 +00:00
|
|
|
s="$s "
|
|
|
|
fi
|
2012-04-22 21:53:31 +00:00
|
|
|
if [ -f "A-$i.data" ] ; then
|
|
|
|
s="${s}A"
|
2012-04-22 13:14:14 +00:00
|
|
|
else
|
|
|
|
s="$s "
|
|
|
|
fi
|
|
|
|
if [ -f "X-$i.data" ] ; then
|
2012-04-23 23:43:53 +00:00
|
|
|
export ID="$i"
|
|
|
|
merge_diff
|
|
|
|
s="${s}$RES"
|
2012-04-22 13:14:14 +00:00
|
|
|
elif [ -f "M-$i.data" ] ; then
|
|
|
|
s="${s}M"
|
|
|
|
else
|
|
|
|
s="$s "
|
2012-04-19 22:09:01 +00:00
|
|
|
fi
|
2012-04-22 13:14:14 +00:00
|
|
|
s="$s|"
|
2012-04-19 22:09:01 +00:00
|
|
|
done
|
2012-01-06 12:56:52 +00:00
|
|
|
|
2012-04-19 22:09:01 +00:00
|
|
|
if [[ "$s" != "$old" ]] ; then
|
|
|
|
let "t=t+1"
|
|
|
|
now=`date +%s`
|
|
|
|
let "now=now-start"
|
2012-04-30 21:34:27 +00:00
|
|
|
free=`df -m . 2> /dev/null | tail -1 | awk '{print $4}'`
|
|
|
|
used=`du -m 2> /dev/null | awk '{print $1}' `
|
2012-04-23 23:43:53 +00:00
|
|
|
printf "%5d %6d [%s\n" "$t" "$now" "$s ${used}Mb (${free}Mb free)"
|
2012-04-19 22:09:01 +00:00
|
|
|
old="$s"
|
|
|
|
else
|
|
|
|
# Sleep a little bit:
|
2012-04-30 21:34:27 +00:00
|
|
|
sleep 1
|
2012-04-19 22:09:01 +00:00
|
|
|
fi
|
2012-01-05 16:24:58 +00:00
|
|
|
done
|
2012-01-06 12:56:52 +00:00
|
|
|
}
|
2012-01-05 16:24:58 +00:00
|
|
|
|
2012-01-06 12:56:52 +00:00
|
|
|
dynamic
|