EvoBSD/roles/nagios-nrpe/files/plugins_bsd/check_ipsecctl.sh

24 lines
460 B
Bash
Raw Normal View History

2018-12-28 11:23:49 +01:00
#!/bin/sh
IPSECCTL="/sbin/ipsecctl -s sa"
STATUS=0
2022-06-16 17:25:52 +02:00
$IPSECCTL | grep -q "from $1 to $2"
2018-12-28 11:23:49 +01:00
if [ $? -eq 1 ]; then
STATUS=2;
OUTPUT1="No VPN from $1 to $2 "
fi
2022-06-16 17:25:52 +02:00
$IPSECCTL | grep -q "from $2 to $1"
2018-12-28 11:23:49 +01:00
if [ $? -eq 1 ]; then
STATUS=2;
OUTPUT2="No VPN from $2 to $1"
fi
2022-06-16 17:25:52 +02:00
if [ "$STATUS" -eq 0 ]; then
2018-12-28 11:23:49 +01:00
echo "VPN OK - $3 is up"
exit $STATUS
else
echo "VPN DOWN - $3 is down ($OUTPUT1 $OUTPUT2)"
exit $STATUS
fi