forked from nirmannarang/parseTPCDSlogsMongoDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_cluster_conf.sh
executable file
·31 lines (30 loc) · 1.23 KB
/
get_cluster_conf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash -l
WORKDIR=${HOME}
SLAVES=`cat ${HADOOP_HOME}/etc/hadoop/slaves | tr "\n" " "`
echo "Collecting hardware config details for Master machine `hostname`"
ip=`hostname --ip-address`
hostname=`hostname`
ram=`free -g | head -2 | tail -1 | awk {'print $2'}`
vcpu=`cat /proc/cpuinfo | grep processor | wc -l`
echo "{" > ${WORKDIR}/cluster_info
echo "\"master\": {\"ip\":\"$ip\",\"hostname\":\"$hostname\",\"vcpus\":$vcpu,\"ram\":\"${ram}GB\"}," >> ${WORKDIR}/cluster_info
echo "\"slaves\": [" >> ${WORKDIR}/cluster_info
#echo "$ip,$hostname,${RAM}GB,$vcpu" >> cluster_info
count=`cat ${HADOOP_HOME}/etc/hadoop/slaves | wc -l`
for server in $SLAVES
do
echo "Collecting hardware config details for slave machine ${server}"
ip=$( ssh $server "hostname --ip-address")
hostname=$(ssh $server "hostname")
ram=$(ssh $server "free -g" | head -2 | tail -1 | awk {'print $2'})
vcpu=$(ssh $server "cat /proc/cpuinfo | grep processor | wc -l")
#echo "$ip,$hostname,${RAM}GB,$vcpu">>cluster_info
echo "{\"ip\":\"$ip\",\"hostname\":\"$hostname\",\"vcpus\":$vcpu,\"ram\":\"${ram}GB\"}" >> ${WORKDIR}/cluster_info
if [ $count -ne 1 ]
then
echo "," >> ${WORKDIR}/cluster_info
fi
((count=count-1))
done
echo "]" >> ${WORKDIR}/cluster_info
echo "}" >> ${WORKDIR}/cluster_info