#!/usr/bin/env bash #set -x PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$HOME/bin:/dcs/bin:/dcs/etc export PATH function usage { echo Usage "$0" hostname 1>&2 exit 1 } if [ "$#" != 1 ] then usage fi case "$1" in -*) usage ;; esac rpcinfo -p "$1" | \ while read line do program="$(echo $line | awk ' { print $1 }')" vers="$(echo $line | awk ' { print $2 }')" #echo vers is $vers proto="$(echo $line | awk ' { print $3 }')" # $port is not used for anything right now, but we could # do an nmap port scan of these ports someday... port="$(echo $line | awk ' { print $4 }')" programdescrip="$(echo $line | awk ' { print $5 }')" if [ "$program" = program ] then continue fi #echo $program $vers $proto $programdescrip bad=1 case "$proto" in tcp) if maxtime 20 rpcinfo -t "$1" "$program" "$vers" > /dev/null 2>&1 then bad=0 fi ;; udp) if maxtime 20 rpcinfo -u "$1" "$program" "$vers" > /dev/null 2>&1 then bad=0 fi ;; esac if [ "$bad" != 1 ] then if [ "$programdescrip" = "" ] then echo "Program $program, Proto $proto, Version $vers is OK" else echo "Program $programdescrip/$program, Proto $proto, Version $vers is OK" fi else if [ "$programdescrip" = "" ] then echo "Program $program, Proto $proto, Version $vers is BAD <========" else echo "Program $programdescrip/$program, Proto $proto, Version $vers is BAD <========" fi fi done #program vers proto port #100000 4 tcp 111 portmapper #100000 3 tcp 111 portmapper #100000 2 tcp 111 portmapper #100000 4 udp 111 portmapper #100000 3 udp 111 portmapper #100000 2 udp 111 portmapper #100007 3 udp 32778 ypbind #100007 2 udp 32778 ypbind #100007 1 udp 32778 ypbind #100007 3 tcp 32774 ypbind #100007 2 tcp 32774 ypbind #100007 1 tcp 32774 ypbind