-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_webpagevalues.sh
More file actions
171 lines (141 loc) · 5.17 KB
/
Copy pathcheck_webpagevalues.sh
File metadata and controls
171 lines (141 loc) · 5.17 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
#set -x
wgetcmd="/usr/bin/wget"
grepcmd="/bin/grep"
URL="https://mywebsite.com/healthMonitor.do?token=healthMonitorToken&compact=1"
tempfile="/tmp/jmsresp"
ST_OK=0
ST_WR=1
ST_CR=2
ST_UK=3
targetname=
warning=
critical=
###########################
usage() {
echo ""
echo "$0 [-t targetname ] [-w warning ] [-c critical ] [-h/v]"
echo ""
echo "Options:"
echo " -t) Defines the jms target either 00, 01, 02, 03"
echo " -w) Sets a warning level for jms ping time"
echo " -c) Sets a critical level for jms ping time"
echo " -h/-v) Help"
echo " ?) Help"
#exit $ST_UK
}
find_value() {
###calling function "target_name" which determines what are other targets needs to be checked based on the target value that was passed as option####
target_name $targetname
####WGET Command to get the URL and save it in a temp file
wgetoutput=`$wgetcmd -O $tempfile $URL`
###find the which message bus the target is connected to###
CMD_OUT1=`$grepcmd "jmsTargetName${targetname}" $tempfile | cut -f2 -d '='`
###find the jms ping time from provided target name to 1st target###
CMD_OUT2=`$grepcmd "jmsPing${targetname}to${target1}" $tempfile | cut -f2 -d '='`
###find the jms ping time from provided target name to 2nd target###
CMD_OUT3=`$grepcmd "jmsPing${targetname}to${target2}" $tempfile | cut -f2 -d '='`
###find the jms ping time from provided target name to 3rd target###
CMD_OUT4=`$grepcmd "jmsPing${targetname}to${target3}" $tempfile | cut -f2 -d '='`
###find the jms ping time from provided target name to itself###
CMD_OUT5=`$grepcmd "jmsPing${targetname}to${targetname}" $tempfile | cut -f2 -d '='`
compare
}
compare() {
echo $targetname,$warning,$critical,$CMD_OUT1,$CMD_OUT2,$CMD_OUT3,$CMD_OUT4,$CMD_OUT5
if [ "$warning" -a -n "$critical" ]; then
if [ "$CMD_OUT2" -ge "$warning" -a "$CMD_OUT2" -lt "$critical" ]; then
echo "WARNING: jmsPing${targetname}to${target1} = ${CMD_OUT2} is greater than $warning"
exit 1
elif [ "$CMD_OUT2" -gt "$critical" ]; then
echo "CRITICAL: jmsPing${targetname}to${target1} = ${CMD_OUT2} is greater than $critical"
exit 2
else
echo "OK: jmsPing${targetname}to${target1} = ${CMD_OUT2} is okay"
# exit 0
fi
if [ "$CMD_OUT3" -ge "$warning" -a "$CMD_OUT3" -lt "$critical" ]; then
echo "WARNING: jmsPing${targetname}to${target2} = ${CMD_OUT3} is greater than $warning"
exit 1
elif [ "$CMD_OUT3" -gt "$critical" ]; then
echo "CRITICAL: jmsPing${targetname}to${target2} = ${CMD_OUT3} is greater than $critical"
exit 2
else
echo "OK: jmsPing${targetname}to${target2} = ${CMD_OUT3} is okay"
# exit 0
fi
if [ "$CMD_OUT4" -ge "$warning" -a "$CMD_OUT4" -lt "$critical" ]; then
echo "WARNING: jmsPing${targetname}to${target3} = ${CMD_OUT4} is greater than $warning"
exit 1
elif [ "$CMD_OUT4" -gt "$critical" ]; then
echo "CRITICAL: jmsPing${targetname}to${target3} = ${CMD_OUT4} is greater than $critical"
exit 2
else
echo "OK: jmsPing${targetname}to${target3} = ${CMD_OUT4} is okay"
# exit 0
fi
if [ "$CMD_OUT5" -ge "$warning" -a "$CMD_OUT5" -lt "$critical" ]; then
echo "WARNING: jmsPing${targetname}to${targetname} = ${CMD_OUT5} is greater than $warning"
exit 1
elif [ "$CMD_OUT5" -gt "$critical" ]; then
echo "CRITICAL: jmsPing${targetname}to${targetname} = ${CMD_OUT5} is greater than $critical"
exit 2
else
echo "OK: jmsPing${targetname}to${targetname} = ${CMD_OUT5} is okay"
# exit 0
fi
else
echo "OK"
# exit 0
fi
####deleting the temporary file####
rm -f $tempfile
}
target_name() {
if [ "$targetname" == "00" ]; then
target1=01
target2=02
target3=03
elif [ "$targetname" == "01" ]; then
target1=00
target2=02
target3=03
elif [ "$targetname" == "02" ]; then
target1=00
target2=01
target3=03
elif [ "$targetname" == "03" ]; then
target1=00
target2=01
target3=02
fi
}
main() {
while getopts ":t:w:c:hv" option; do
case $option in
t ) targetname=$OPTARG ;;
w ) warning=$OPTARG ;;
c ) critical=$OPTARG ;;
h ) usage ; exit ;;
v ) version ; exit ;;
? ) usage ; exit ;;
esac
done
if [ "x$targetname" = "x" ]; then
echo "error: targetname was not specified with -t"
usage
exit 2
fi
if [ "x$warning" = "x" ]; then
echo "error: warning value was not specified with -w"
usage
exit 2
fi
if [ "x$critical" = "x" ]; then
echo "error: critical value was not specified with -c"
usage
exit 2
fi
find_value
}
main $@