su - ossadm << EOF
sh /opt/oss/manager/apps/ZookeeperService/bin/start_zkCli.sh -server x.x.x.x:32041
ls /routes/SOP-Gamma/services
close
EOF
su - ossadm << EOF
sh /opt/oss/manager/apps/ZookeeperService/bin/start_zkCli.sh -server zkip:32041
ls /routes/SOP_Gamma/nodes
get_service_version.sh
#!/bin/bash
rm -rf *log
rm -rf *txt
rm -rf *list
rm -rf *properties
sh get_service.sh > service_temp.log
grep CSB service_temp.log > service_temp.txt
sed -i 's#\[##g' service_temp.txt
sed -i 's#\]##g' service_temp.txt
sed -i 's#,##g' service_temp.txt
cat service_temp.txt
list=`cat service_temp.txt`
cp get_version.sh get_version_copy.sh
chmod 777 get_version_copy.sh
for name in $list
do
str=`echo ${name:0:3}`
if [ "$str"x = "CSB"x ];then
echo $name >> service.list
echo "ls /routes/SOP-Gamma/services/$name/versions" >> get_version_copy.sh
fi
done
echo "close" >> get_version_copy.sh
echo "EOF" >> get_version_copy.sh
sh get_version_copy.sh > version.log
#grep "[0-9]\{1,2\}\.[0-9]\{1,2\}\.[0-9]\{1,3\}.[0-9]\{1,14\}" version.log > version.list
sed -i 's#\[##g' version.log
sed -i 's#\]##g' version.log
nl version.log > version_num.log
nl service.list | awk '{print $1}' > size.txt
cat size.txt | while read line
do
serviceName=`sed -n ''"$line"'p' service.list`
number=`sed -n '/'"$serviceName"'/p' version_num.log | awk '{print $1}'`
number=$((number + 3))
version=`sed -n ''"$number"'p' version_num.log | awk '{print $2}'`
#找到下一行即可 serviceVersion=`awk '-v Name="$serviceName" {a[NR]=$0;if(a[NR-1]~/''"$serviceName"''/){print a[NR]}}' version.log `
# 已经验证ok 参数传输注意要 "'$xxx'" serviceVersion=`echo | awk 'BEGIN {Name="'$serviceName'"} {a[NR]=$0;if(a[NR-1]~Name){print a[NR]}}' version.log`
serviceVersion=`sed -n ''"$number"'p' version.log`
length=`echo ${#version}`
if [ $length -gt 4 ];then
echo "$serviceName=$serviceVersion" >> service_version.properties
else
echo "$serviceName=" >> service_version.properties
fi
done
cat service_version.properties
mkdir history
date=`date +%Y%m%d%H%M%S`
cp service_version.properties $date.properties
mv $date.properties history/