By gtam
Hello
I’m writing a script to get content of web pages on different machines and compare them using their md5 hash
hear is my code
#!/bin/bash
# Cluster 1
CLUSTER1_SERVERS=”srv01:7051 srv02:7052 srv03:7053 srv04:7054″
CLUSTER1_APPLIS=”test/version.html test2/version.html test3/version.jsp test4/version.html test5/version.jsp”
# Cluster 2
CLUSTER2_SERVERS=”srv01:7055 srv02:7056 srv03:7057 srv04:7058″
CLUSTER2_APPLIS=”test/version.html test2/version.html test3/version.jsp test4/version.html”
# Cluster 4
CLUSTER4_SERVERS=”srv01:7063 srv02:7064 srv03:7065 srv04:7066″
CLUSTER4_APPLIS=”test/version.html test2/version.html”
# Liste des clusters ?* tester
CLUSTERS=”CLUSTER1 CLUSTER2 CLUSTER4″
# init vars
CRITICAL=2
WARNING=1
OK=0
for cluster in $CLUSTERS
do
for server in $(eval echo $${cluster}_SERVERS)
do
server_name=`echo $server | cut -d’:’ -f1,1`
server_port=`echo $server | cut -d’:’ -f2,2`
for applis in $(eval echo $${cluster}_APPLIS)
do
checksum=`curl –silent –write-out ‘%{http_code}n’ “http://$server_name:$server_port/$applis” | md5sum`
if [[ ( “$checksum” -ne “$checksum1” ) ]]
then
exit_code=2
else
exit_code=0
fi
done
done
done
case $exit_code in
“2”)
echo “CRITICAL – App Version Mismatch”
exit $CRITICAL
;;
“0”)
echo “OK – All apps deployed are identical”
exit $OK
;;
*)
echo “CRITICAL – there’s something wrong with this script …”
exit $CRITICAL
…read more
Source: FULL ARTICLE at The UNIX and Linux Forums