-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrep.sh
71 lines (57 loc) · 1.32 KB
/
grep.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#env=$1
env="prod"
string=$1
time=$2
color=$3
tmp=$(($time))
#echo time=$time
if [ $tmp -ge 0 ]; then
time=-$((60*$time))
fi
#echo $string
#echo $time
targetDir='/gemfire-logs/logs/*'
RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'
middle="rhgemfirev"
locatorMiddle="rhlocatorv"
sshLog="-o LogLevel=Error"
if [ $env == "sbx" ]; then
env="sb"
servermax=3
locatormax=1
elif [ $env == "dev" ]; then
servermax=6
locatormax=1
elif [ $env == "sit" ]; then
servermax=12
locatormax=2
elif [ $env == "uat" ]; then
servermax=19
locatormax=2
elif [ $env == "prod" ]; then
servermax=21
locatormax=2
middle="rhgfxdv"
fi
for i in $(seq 1 $servermax)
do
hostName=$env$middle$i
if [ ! -z "$color" ]; then
printf "${GREEN}$hostName${NC}\n"
else
printf "$hostName\n"
fi
ssh $sshLog $hostName "find ${targetDir} -mmin $time|xargs grep -i -E '$string'"
done
for i in $(seq 1 $locatormax)
do
hostName=$env$locatorMiddle$i
if [ ! -z "$color" ]; then
printf "${GREEN}$hostName${NC}\n"
else
printf "$hostName\n"
fi
ssh $sshLog $hostName "find ${targetDir} -mmin $time|xargs grep -i -E '$string'"
done