Tag Archives: CRITICAL

While loop problem taking too long

By SkySmart

Code:

while read myhosts
do
while read discovered
do
echo "$discovered"

done < $LOGFILE | grep -Pi "[a-z]|[A-Z]" | egrep "${myhosts}" | egrep "CRITICAL" | awk -F";" '{print $3}' | sort -n | uniq

done < $SERVERS | egrep -v "#"


can the above be fixed? for some weird reason it’s taking forever to complete.

the logfile is only 31MB. the list of servers in “SERVERS” is only 10.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Get web pages and compare

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

Selective printing

By anil510

I have the following contents in a file

Code:

---- CRITICAL: altered for /usr/bin/bin1 ---- OK: /usr/sbin/bin2 result fine ---- OK: /usr/sbin/bin3 result fine ---- CRITICAL: altered for /usr/bin/bin4 ---- OK: /usr/bin/bin5 result fine ---- OK: /usr/bin/bin6 result fine ---- CRITICAL: altered for /usr/bin/bin7


I just need to output the following with sed/awk operation on file

Code:

---- CRITICAL: altered for /usr/bin/bin1 ---- CRITICAL: altered for /usr/bin/bin4 ---- CRITICAL: altered for /usr/bin/bin7


…read more
Source: FULL ARTICLE at The UNIX and Linux Forums