#!/bin/bash
read -p "`echo -e \"\e[31mplease input server_source name: \e[0m\"`" source_1 source_2 source_3 source_4 source_5
read -p "`echo -e \"\e[31mPlease input server_target name: \e[0m\"` " target_1 target_2 target_3 target_4 target_5
read -p "`echo -e \"\e[31mPlease input afterward name: \e[0m\"`" d
source=($source_1 $source_2 $source_3 $source_4 $source_5)
target=($target_1 $target_2 $target_3 $target_4 $target_5)
range=$((${#source[*]}-1))
function first () {
for i in `seq 0 $range`
do
source1="`ssh -o StrictHostKeyChecking=no ${user} ${source[$i]} sudo grep -m 1 flags /proc/cpuinfo 2>/dev/null |awk -F ':' '{print $2}' 2>/dev/null`"
target1="`ssh -o StrictHostKeyChecking=no ${user} ${target[$i]} sudo grep -m 1 flags /proc/cpuinfo 2>/dev/null |awk -F ':' '{print $2}' 2>/dev/null`"
for j in $source1
do
if [[ "$target1" =~ "$j" ]];then
+ continue
else
echo "${source[$i]} and ${target[$i]} is not matched"
fi
done
done
}
function second () {
for i in `seq 0 $range`
do
source1="`ssh -o StrictHostKeyChecking=no ${user} ${source[$i]}.$d sudo grep -m 1 flags /proc/cpuinfo 2>/dev/null |awk -F ':' '{print $2}' 2>/dev/null`"
target1="`ssh -o StrictHostKeyChecking=no ${user} ${target[$i]}.$d sudo grep -m 1 flags /proc/cpuinfo 2>/dev/null |awk -F ':' '{print $2}' 2>/dev/null`"
for j in $source1
do
if [[ "$target1" =~ "$j" ]];then
continue
else
echo "${source[$i]} and ${target[$i]} is not matched"
fi
done
done
}
if [ $d = "" ];then
first
else
second
fi
匹配多台服务器的cpu flag
于 2018-05-30 15:30:19 首次发布