有人可以帮助/纠正我写一个shell脚本,这是我试图做的事情
这是我的代码
for cluster in $CLUSTERS
do
for applis in $(eval echo \$${cluster}_APPLIS)
do
CONTENT=$(wget -q -O - "http://$server/$applis")
if [ "$CONTENT" -eq 1 ]
then
exit_code=0
else
exit_code=2
fi
done
done
[[ -z "$error_server" ]] && error_server="aucune"
case $exit_code in
"2")
echo "CRITICAL - App Version Mismatch"
exit 2
;;
"1")
echo "WARNING - instance(s) indisponible(s)"
exit 1
;;
"0")
echo "OK - All apps have the save version"
exit 0
;;
*)
echo "CRITICAL - there's something wrong with this script ..."
exit 2
;;
esac
非常感谢任何帮助或建议
此致 FAB
答案 0 :(得分:0)
您可以使用diff来比较文件的两个版本。第一个变量用于获取网页的第一个版本。我不确定首先应该在第一个循环内部还是外部初始化。
first=1
for cluster in $CLUSTERS
do
for applis in $(eval echo \$${cluster}_APPLIS)
do
if [ $first -eq 1 ];then
first=0
PREV_CONTENT=$(wget -q -O - "http://$server/$applis")
else
CONTENT=$(wget -q -O - "http://$server/$applis")
diff $PREV_CONTENT $CONTENT
PREV_CONTENT=$CONTENT
result=$?
fi
if [ "$result" -eq 0 ]
then
exit_code=0
else
exit_code=2
fi
done
完成