未验证 提交 e548dd70 编写于 作者: Q QinZuoyan 提交者: GitHub

scripts: improve scripts/pegasus_stat_available.sh (#191)

上级 bcdb11a8
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
PID=$$ PID=$$
if [ $# -ne 2 ]; then if [ $# -lt 2 ]; then
echo "USGAE: $0 <cluster> <filter>" echo "USGAE: $0 <cluster> <filter1> [<filter2> ...]"
echo " eg: $0 onebox 2017-07" echo " eg: $0 onebox 2017-07 2017-08 2017-09"
echo echo
echo "Result: <cluster> <filter> <day_count> <available>" echo "Result: <cluster> <serve_days> <available>"
exit 1 exit 1
fi fi
cluster=$1 cluster=$1
filter=$2 shift
pwd="$( cd "$( dirname "$0" )" && pwd )" pwd="$( cd "$( dirname "$0" )" && pwd )"
shell_dir="$( cd $pwd/.. && pwd )" shell_dir="$( cd $pwd/.. && pwd )"
...@@ -30,25 +30,28 @@ if [ "$detect_table" == "" ]; then ...@@ -30,25 +30,28 @@ if [ "$detect_table" == "" ]; then
exit 1 exit 1
fi fi
result_file="pegasus.stat_available.scan_result" all_result="pegasus.stat_available.all_result"
tmp_file="/tmp/$UID.$PID.pegasus.stat_available.scan" rm -f $all_result
echo -e "use $detect_table\nhash_scan detect_available_day '' '' -s prefix -y \"$filter\" -o $result_file" | ./run.sh shell -n $cluster &>$tmp_file for filter in $*; do
scan_ok=`grep 'key-value pairs got' $tmp_file | wc -l` result_file="pegasus.stat_available.scan_result.$filter"
if [ $scan_ok -ne 1 ]; then tmp_file="/tmp/$UID.$PID.pegasus.stat_available.scan"
echo "ERROR: scan detect table failed, refer error to $tmp_file" echo -e "use $detect_table\nhash_scan detect_available_day '' '' -s prefix -y \"$filter\" -o $result_file" | ./run.sh shell -n $cluster &>$tmp_file
rm -f $result_file scan_ok=`grep 'key-value pairs got' $tmp_file | wc -l`
exit 1 if [ $scan_ok -ne 1 ]; then
fi echo "ERROR: scan detect table failed, refer error to $tmp_file"
rm -f $result_file
days=`cat $result_file | wc -l` exit 1
fi
cat $result_file >>$all_result
done
days=`cat $all_result | wc -l`
if [ $days -eq 0 ]; then if [ $days -eq 0 ]; then
echo "ERROR: no detect data found for filter \"$filter\", refer to $tmp_file" available="0.000000"
rm -f $result_file else
exit 1 available=`cat $all_result | grep -o '[0-9]*,[0-9]*,[0-9]*' | awk -F, '{a+=$1;b+=$2}END{printf("%f\n",(double)b/a);}'`
fi fi
echo "$cluster $days $available"
available=`cat $result_file | grep -o '[0-9]*,[0-9]*,[0-9]*' | awk -F, '{a+=$1;b+=$2}END{printf("%f\n",(double)b/a);}'` rm -f pegasus.stat_available.scan_result.* $all_result
rm -f $result_file
echo "$cluster $filter $days $available"
rm -f /tmp/$UID.$PID.pegasus.* &>/dev/null rm -f /tmp/$UID.$PID.pegasus.* &>/dev/null
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册