#!/bin/bash if [ "$#" -lt "3" ]; then echo -e "\nWarning: Wrong command line arguments. \nUsage: ./check_paloaltovpn \n \nParts are: vpnses, vpnload\nExample: ./check_paloaltovpn 127.0.0.1 public vpnses\n" && exit "3" fi strHostname=$1 strCommunity=$2 strpart=$3 strWarning=$4 strCritical=$5 # Check ob Firewall erreichbar ist TEST=$(snmpstatus -v 2c $strHostname -c "$strCommunity" -t 5 -r 0 2>&1) # echo "Test: $TEST"; if [ "$TEST" == "Timeout: No Response from $strHostname" ]; then echo "CRITICAL: SNMP to $strHostname is not available"; exit 2; fi # VPN Sessions ---------------------------------------------------------------------------------------------------------------------------------------------- if [ "$strpart" == "vpnses" ]; then VPNSES=$(snmpwalk -v 2c -O vqet -c "$strCommunity" $strHostname 1.3.6.1.4.1.25461.2.1.2.5.1.3.0) echo "VPN Sessions: "$VPNSES"" strOutput="VPN Sessions=$[VPNSES]|'VPN Sessions'=$[VPNSES];;;;" echo "OK: "$strOutput exit 0 # VPN Utilization ---------------------------------------------------------------------------------------------------------------------------------------------- elif [ "$strpart" == "vpnload" ]; then VPNLOAD=$(snmpwalk -v 2c -O vqet -c "$strCommunity" $strHostname 1.3.6.1.4.1.25461.2.1.2.5.1.1) echo "VPN Utilization: "$VPNLOAD"%" strOutput="VPN Utilization=$[VPNLOAD]%|'VPN Utilization'=$[VPNLOAD];$strWarning;$strCritical;0;100" if [ $VPNLOAD -ge "$strCritical" ]; then echo "CRITICAL: "$strOutput"%" exit 2 fi if [ $VPNLOAD -ge "$strWarning" ]; then echo "WARNING: "$strOutput"%" exit 1 fi echo "OK: "$strOutput exit 0 #---------------------------------------------------------------------------------------------------------------------------------------------------- else echo -e "\nUnknown Part!" && exit "3" fi exit 0