MrC is so right! Just a few tweaks to get what you want. This monlist ALSO prints "peers", meaning Stratum 1 hosts. What I do is print the peers, and exclude those from the monlist. Observe:
Code:
# get peers
/usr/sbin/ntpdc -n -c listpeers |awk '{print $2}' >/tmp/peers.$$
# get all hosts connected to this ntp server
/usr/sbin/ntpdc -c monlist |awk '{ print $1 }' |
fgrep -v -f /tmp/peers.$$ # exclude those from the first list
rm -f /tmp/peers.$$
Afterwards, you might want to do forward IP host resolution on the list. The reason I use the -n command is because the ntpdc output chops long hostnames off at a certain column, rendering the grep trick useless.