« first day (11 days earlier)    last day (14 days later) » 

5:19 AM
Hi
 
 
1 hour later…
6:24 AM
Hi
TOTAL_WORKER_MEMORY=`curl -u $CLUSTER_USERNAME:$CLUSTER_PASSWORD -sS -G "https://$CLUSTER_NAME.azurehdinsight.net/api/v1/clusters/$CLUSTER_NAME/services/HDFS/components/DATANODE" | grep mem_total|head -1|awk -F: '{print $2}'|sed 's/\,//g'`

echo $TOTAL_WORKER_MEMORY| grep E
flag=`echo $?`

echo "--$flag"

if [ $flag -ne 0 ]; then
mem_total=`expr $TOTAL_WORKER_MEMORY * 0.6`
echo "222222-- $mem_total"
else

s=$(perl -e "print $TOTAL_WORKER_MEMORY")
n=$((($s* 6/10) / (1024*1024)))
echo " $n"
fi
 
mem_total=expr $TOTAL_WORKER_MEMORY * 0.6
It has some grammatical errors
 
my control doesn't pass through after this line "echo $TOTAL_WORKER_MEMORY| grep E "
 
Could you sh -x yourscript
 
when I use TOTAL_WORKER_MEMORY=7134416.0
 
Give me the log.
 
6:28 AM
My code
TOTAL_WORKER_MEMORY=`curl -u $CLUSTER_USERNAME:$CLUSTER_PASSWORD -sS -G "https://$CLUSTER_NAME.azurehdinsight.net/api/v1/clusters/$CLUSTER_NAME/services/HDFS/components/DATANODE" | grep mem_total|head -1|awk -F: '{print $2}'|sed 's/\,//g'`
TOTAL_WORKER_MEMORY=7134416.0
echo $TOTAL_WORKER_MEMORY

echo "11111"
echo $TOTAL_WORKER_MEMORY| grep E
flag=`echo $?`

echo "--$flag"

if [ $flag -ne 0 ]; then
mem_total=`expr $TOTAL_WORKER_MEMORY * 0.6`
echo "222222-- $mem_total"
else
#s=$(awk -v var="$TOTAL_WORKER_MEMORY" 'BEGIN {print var}')
sh -x common-install.sh
+ set -e
+ CLUSTER_NAME=*************
+ CLUSTER_USERNAME=*******
+ CLUSTER_PASSWORD=***********
+ + sedawk -F: s/\,//g {print $2}

+ head -1
+ grep mem_total
+ curl -u ******:********* -sS -G https://**********.azurehdinsight.net/api/v1/clusters/**********/services/HDFS/components/DATANODE
+ TOTAL_WORKER_MEMORY= 2.881036E7
+ TOTAL_WORKER_MEMORY=7134416.0
+ echo 7134416.0
7134416.0
+ echo 11111
11111
+ echo 7134416.0
+ grep E
 
set -x on the top of script
Other result?
 
sh -x common-install.sh
+ set -e
+ set -x
+ CLUSTER_NAME=***************
+ CLUSTER_USERNAME=***************
+ CLUSTER_PASSWORD=***************
+ + grepcurl -u ***************:*************** -sS -G mem_total
https://***************.azurehdinsight.net/api/v1/clusters/***************/services/HDFS/components/DATANODE
+ head -1
+ awk -F: {print $2}
+ sed s/\,//g
+ TOTAL_WORKER_MEMORY= 2.881036E7
+ TOTAL_WORKER_MEMORY=7134416.0
+ echo 7134416.0
7134416.0
+ echo 11111
11111
+ grep E
+ echo 7134416.0
 
echo "--$flag"
Why not this?
 
I didn't get. What you want me to do with "echo "--$flag""
 
It's strange. It seems when execute echo $TOTAL_WORKER_MEMORY| grep E it quit your script.
It is all log?
 
6:43 AM
how to solve this?
 
No, I test in my lab, I don't meet your issue.
[root@localhost ~]# ls
anaconda-ks.cfg bin file1 file2 file3 lib pipework test.sh y
[root@localhost ~]# sh -x test.sh
+ TOTAL_WORKER_MEMORY=7134416.0
+ echo 7134416.0
+ grep E
++ echo 1
+ flag=1
+ echo --1
--1
+ '[' 1 -ne 0 ']'
++ 7134416.0 anaconda-ks.cfg bin file1 file2 file3 lib pipework test.sh y 0.6
test.sh: line 9: 7134416.0: command not found
++ bc
+ mem_total=
+ echo '222222-- '
222222--
#!/bin/bash
TOTAL_WORKER_MEMORY=7134416.0
echo $TOTAL_WORKER_MEMORY| grep E
flag=`echo $?`

echo "--$flag"

if [ $flag -ne 0 ]; then
mem_total=`${TOTAL_WORKER_MEMORY} * 0.6|bc`
echo "222222-- $mem_total"
else

s=$(perl -e "print $TOTAL_WORKER_MEMORY")
n=$((($s* 6/10) / (1024*1024)))
echo " $n"
fi
 
hi
 
When I use your code. I get this
sh -x common-install.sh
+ TOTAL_WORKER_MEMORY=7134416.0
+ echo 7134416.0
+ grep E
+ echo 1
+ flag=1
+ echo --1
--1
+ [ 1 -ne 0 ]
+ 7134416.0 README.md common-install.sh edge-nodeip.sh hdi-spark-cluster publishing-app test vm-rhel 0.6
common-install.sh: 1: common-install.sh: 7134416.0: not found
+ bc
+ mem_total=
+ echo 222222--
222222--
 
Do you have bc on your VM?
bc command
 
6:59 AM
bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
 
Yes, bc is installed.
if [ $flag -ne 0 ]; then
mem_total=`${TOTAL_WORKER_MEMORY} * 0.6|bc`
echo "222222-- $mem_total"
No, it has enter this loop.
Now , we should check script here.
 
7:30 AM
what should I do now?
 
Could you show the loop?
 
I executed your above code only
 
+ 7134416.0 README.md common-install.sh edge-nodeip.sh hdi-spark-cluster publishing-app test vm-rhel 0.6
common-install.sh: 1: common-install.sh: 7134416.0: not found
Wait for a moment
 
If I comment this line "mem_total=${TOTAL_WORKER_MEMORY} * 0.6|bc". I didn't see above issue
 
#!/bin/bash
TOTAL_WORKER_MEMORY=7134416.0
echo $TOTAL_WORKER_MEMORY| grep E
flag=`echo $?`

echo "--$flag"

if [ $flag -ne 0 ]; then
mem_total=`echo ${TOTAL_WORKER_MEMORY}*0.6|bc`
echo "222222-- $mem_total"
else

s=$(perl -e "print $TOTAL_WORKER_MEMORY")
n=$((($s* 6/10) / (1024*1024)))
echo " $n"
fi
Sorry for my mistake, my script has one wrong.
 
7:43 AM
Ok. thanks.
 
Does it work?
 
I need divide by (1024*1024) in this line - mem_total=echo ${TOTAL_WORKER_MEMORY}*0.6|bc
How can i do it?
Yes . it works
bc is installed by default in all Linux machines. Right/
 
n=$((($s* 6/10) / (1024*1024)))
I think they should be same.
n=$((($s* 6/10) / (1024*1024)))
 
sh -x common-install.sh
+ TOTAL_WORKER_MEMORY=7134416.0
+ echo 7134416.0
+ grep E
+ echo 1
+ flag=1
+ echo --1
--1
+ [ 1 -ne 0 ]
common-install.sh: 1: common-install.sh: arithmetic expression: expecting ')': "(7134416.0*0.6)/ (1024*1024)"
+ bc
+ mem_total=
+ echo 222222--
222222--
 
Thanks.
 
7:48 AM
TOTAL_WORKER_MEMORY=7134416.0
echo $TOTAL_WORKER_MEMORY| grep E
flag=`echo $?`

echo "--$flag"

if [ $flag -ne 0 ]; then
mem_total=`echo $(((${TOTAL_WORKER_MEMORY}*0.6)/ (1024*1024)))|bc`
echo "222222-- $mem_total"
else
s=$(perl -e "print $TOTAL_WORKER_MEMORY")
n=$((($s* 6/10) / (1024*1024)))
echo " $n"
fi
What is wrong in this line - mem_total=echo $(((${TOTAL_WORKER_MEMORY}*0.6)/ (1024*1024)))|bc
 
``
before echo
mem_total=echo ${TOTAL_WORKER_MEMORY}*0.6|bc
I send e-mail to you.
On this chat room, ``will be converted.
 
ok. send it in email
 
I have send it.
 
There is something wrong in this line - mem_total=echo $(((${TOTAL_WORKER_MEMORY}*0.6)/ (1024*1024)))|bc
I get this error- common-install.sh: 1: common-install.sh: arithmetic expression: expecting ')': "(7134416.0*0.6)/ (1024*1024)"
 
I suggest you could try below:
s=echo $(((${TOTAL_WORKER_MEMORY}*0.6)/ (1024*1024)))|bc
`` after =
Wait for a moment, I test in my lab.
 
7:54 AM
I am using ` only.
sent in email
 
mem_total=echo ${TOTAL_WORKER_MEMORY}*0.6/1024/1024|bc
Hi it works for me.
I send e-mail to you.
 
8:49 AM
thanks. it works for me as well
 

« first day (11 days earlier)    last day (14 days later) »