#!/bin/bash
#
# recordum_ntp
#
# v0.1 2013-04-08 RE
#
# script checks if there are valid ntp peers

# ntpq lists all current peers using the dot ip format
# and test if peer ip is a valid ip
PEERS=$( /usr/bin/ntpq -pn |awk '{print $2}' | grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' )

# if no valid ip address are found
if [[ -z ${PEERS} ]]
then
    exit 22
fi

exit 0
