-
Notifications
You must be signed in to change notification settings - Fork 1
/
check-joomla-update.sh
52 lines (44 loc) · 1.26 KB
/
check-joomla-update.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
#!/bin/bash
CURL=`which curl`
CURL_OPTS='--user-agent check-joomla-updates-nagios-plugin --insecure'
BASENAME=`which basename`
PROGNAME=`$BASENAME $0`
# Exit codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
function print_usage
{
echo "Usage: $PROGNAME <URL>"
}
if [ ! $1 ]; then
print_usage
exit $STATE_CRITICAL
fi
# Check that we're getting a 200 OK message for the joomla-version.php file on the remote host.
response=`$CURL $CURL_OPTS -I $1`
if [[ ( $response != *"200 OK"* && $response != *"HTTP/2 200"* ) ]]; then
echo 'CRITICAL - Checker Script not installed on remote host'
exit $STATE_CRITICAL
fi
result=`$CURL $CURL_OPTS -s $1`
if [ $? != 0 ]; then
echo 'CRITICAL - Check plugin does not work. Maybe you need to install curl.'
exit $STATE_CRITICAL
else
status=`echo $result | cut -d\# -f1`
text=`echo $result | cut -d\# -f2`
echo "Joomla $status - $text"
case "$status" in
CRITICAL)
exit $STATE_CRITICAL
;;
WARNING)
exit $STATE_WARNING
;;
OK)
exit $STATE_OK
;;
esac
fi