-
Notifications
You must be signed in to change notification settings - Fork 18
/
check_pf_services
50 lines (44 loc) · 1.86 KB
/
check_pf_services
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
#!/bin/sh
if [ "$1" = "-name" ] && [ ! -z "$2" ]; then
NAME=$2
OPTION3=$3
OPTION4=$4
if [ "$NAME" = "pinger" ]; then
if [ -f /usr/local/bin/dpinger ]; then
CHECK=$(/usr/local/sbin/pfSsh.php playback svc status dpinger $OPTION3 $OPTION4 |grep 'running' |wc -l | sed -e 's/^[ \t]*//')||exit 3
NAME="d"$NAME
else
CHECK=$(/usr/local/sbin/pfSsh.php playback svc status apinger $OPTION3 $OPTION4 |grep 'running' |wc -l | sed -e 's/^[ \t]*//')||exit 3
NAME="a"$NAME
fi
#CHECK=`expr $CHECK1 + $CHECK2`
else
CHECK=$(/usr/local/sbin/pfSsh.php playback svc status $NAME $OPTION3 $OPTION4 |grep 'running' |wc -l | sed -e 's/^[ \t]*//')||exit 3
fi
#CHECK=$(/usr/local/sbin/pfSsh.php playback svc status $NAME)||exit 3
#echo "DEBUG: NAME:$NAME CHECK:$CHECK"
if [ $CHECK -lt 1 ];then
echo "CRITICAL - $NAME service not running"
exit 2
else
echo "OK - $NAME service is running"
exit 0
fi
else
echo "check_pf_services.sh - Nagios Plugin for checking services on pfSense "
echo ""
echo "Usage: check_pf_services.sh -name <service_name>"
echo " "
echo "Note: If captiveportal is the service getting checked, the zone name"
echo " in all lowercase must follow the service_name parameter"
echo "Example: check_pf_services.sh -name captiveportal guest"
echo " "
echo "Note: If openvpn is the service getting checked, two options must be"
echo " specified -- the option "server" followed by the server id."
echo "Example: check_pf_services.sh -name openvpn server 1"
echo " "
echo "Note: Specifying 'pinger' as the service will check both apinger"
echo " as well as dpinger. You can specify directly as well."
echo "Example: check_pf_services.sh -name pinger"
exit 3
fi