#!/bin/sh # # Paths to commands used in this script. These # may have to be modified to match your system setup. # TV: removed PATH restriction. Need to think more about what this means overall #PATH="" ECHO="/bin/echo" GREP="/bin/egrep" DIFF="/usr/bin/diff" TAIL="/usr/bin/tail" CAT="/bin/cat" RM="/bin/rm" CHMOD="/bin/chmod" TOUCH="/bin/touch" PROGNAME=`/usr/bin/basename $0` PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` REVISION=`echo '$Revision: 14 $' | sed -e 's/[^0-9.]//g'` . $PROGPATH/utils.sh print_usage() { echo "Usage: $PROGNAME --ip endpointip" echo "Usage: $PROGNAME --help" echo "Usage: $PROGNAME --version" } print_help() { print_revision $PROGNAME $REVISION echo "" print_usage echo "" echo "Racoon VPN check plugin for Nagios" echo "" support } # Make sure the correct number of command line # arguments have been supplied if [ $# -lt 1 ]; then print_usage exit $STATE_UNKNOWN fi # Grab the command line arguments #logfile=$1 #oldlog=$2 #query=$3 exitstatus=$STATE_WARNING #default while test -n "$1"; do case "$1" in --help) print_help exit $STATE_OK ;; -h) print_help exit $STATE_OK ;; --version) print_revision $PROGNAME $REVISION exit $STATE_OK ;; -V) print_revision $PROGNAME $REVISION exit $STATE_OK ;; --ip) endpoint=$2 shift ;; -x) exitstatus=$2 shift ;; --exitstatus) exitstatus=$2 shift ;; *) echo "Unknown argument: $1" print_usage exit $STATE_UNKNOWN ;; esac shift done # If the source log file doesn't exist, exit isakmp=`sudo /usr/sbin/racoonctl show-sa isakmp| grep $endpoint` if [ "$isakmp" != "" ] then $ECHO "Racoon vpn tunnel check ok: $endpoint\n" exitstatus=$STATE_OK else $ECHO "CRITICAL - Racoon vpn tunnel not found: $endpoint\n" exitstatus=$STATE_CRITICAL fi exit $exitstatus