forked from jedda/OSX-Monitoring-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_apns_reachability.sh
executable file
·41 lines (32 loc) · 1.26 KB
/
check_apns_reachability.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
#!/bin/bash
# Check APNS Reachability
# by Jedda Wignall
# http://jedda.me
# v1.1 - 21 Mar 2012
# Added check of x.courier.push.apple.com:5223
# v1.0 - 20 Mar 2012
# Initial release.
# This script checks the reachability of Apple's APNS servers. This can be very useful on remote Profile Manager
# or Lion Server collaboration installs where you may not be the only one in control of the firewall.
# Takes no arguments, as it simply looks for a connection.
# check port 2195 at gateway.push.apple.com
status="$(openssl s_client -connect gateway.push.apple.com:2195)"; sleep 2;
if ! echo $status | grep -q 'CONNECTED'; then
printf "CRITICAL - gateway.push.apple.com:2195 not responding"
exit 2
fi
# check port 2196 at gateway.push.apple.com
status="$(openssl s_client -connect gateway.push.apple.com:2196)"; sleep 2;
if ! echo $status | grep -q 'CONNECTED'; then
printf "CRITICAL - gateway.push.apple.com:2196 not responding"
exit 2
fi
# check port 5223 at x.courier.push.apple.com
status="$(openssl s_client -connect 1-courier.push.apple.com:5223)"; sleep 2;
if ! echo $status | grep -q 'CONNECTED'; then
printf "CRITICAL - 1-courier.push.apple.com:5223 not responding"
exit 2
fi
# we are all good!
printf "OK - APNS ports at gateway.push.apple.com are reachable"
exit 0