#!/bin/sh
#
# Special finger target .down --
#	List hosts that are not responding
#
# $Id: x-.down,v 1.1 1995/01/05 04:10:33 stolcke Exp $
#

# only allow local connections
case $2 in
remote)
	exit 0
	;;
esac

# XXX: Path may need to be adjusted for non-standard location
echo .clients | /usr/pkg/libexec/in.fingerd | awk '
# Header line
NR == 1 {
	next;
}
NR == 2 {
	print
	next;
}
{
	total += 1;
	if ($3 == "down") {
		down += 1;
		print;
	}
	next;
}
END {
	printf "%d out of %d hosts are down.\r\n", down, total;
}
'
