-
Notifications
You must be signed in to change notification settings - Fork 1
/
text_check.sh
executable file
·57 lines (46 loc) · 959 Bytes
/
text_check.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
#!/bin/bash
#
# Nagios script to check text on webpage
#
#TODO:
# 1.
# put searched string to $SEARCHED_STRING and use Nagios to pass the data
#
#
# 2.
# Make tmp file name independant - use for example current datetime as name of the file
#
#
# Make sure the script is universal, only thing you need to change is configuration of Nagios command
#
#Nagios return codes
# 0 OK
# 1 warning
# 2 critical
# 3 unknow
DOMAIN=$1
SEARCHED_STRING=$2
function finish {
rm /tmp/pujcimmoto.file
}
function file_exists () {
if [ ! -f /tmp/pujcimmoto.file ]; then
echo "$1"
exit 3
fi
}
wget $DOMAIN -O /tmp/pujcimmoto.file
file_exists "File not found in step 1"
if grep -q 'Rodinná půjčovna motocyklů' /tmp/pujcimmoto.file
then
file_exists "File not found in step 2"
finish
echo "OK - searched string found"
exit 0
else
file_exists "File not found in step 3"
finish
echo "Failure - searched string not found"
exit 2
fi
fi