#!/bin/sh
# Richard van Mansom, richardvm@wirelessleiden.nl, March 2010

# Minimum number of non local routes.
VALID=1

# 1. Show routing table
# 2. Only show routes which includes subnets
# 3. Discard anything with a semicolon (MAC addresses and IPv6 addresses)
# 4. Discard anything which include the word 'link' (local routes).
# 5. Use word count (get number of lines)
COUNT=`netstat -rn | grep -E '[0-9]/[0-9]' | grep -v ':' | grep -v 'link' | wc -l'`

# No have a look if the number of routes has passed the minimium threshold.
if [ ${COUNT} -gt ${VALID} ]; then

  # Display me if I have passed the threshold
  echo "ROUTING OK: Got non local routes"
else 

  # Display me if I didn't pased the threshold
  echo "ROUTING CRITICAL: I don't have any non local routes"
fi 

