Is it possible to set a timeout for rpcinfo?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Is it possible to set a timeout for rpcinfo?
# 1  
Old 09-09-2009
Is it possible to set a timeout for rpcinfo?

I've created a script that checks the health of a piece of equipment out in the field by first establishing that it is pingable, and then parsing
log files to gather information. Today I realized that there are times where the equipment may be pingable, and will not show any
immediate issues in the logs, but will fail rpcinfo. I'd like to add an rpcinfo check to my script to alert who ever runs it that there is a
problem that isn't caught in any of the other tests.

My issue however is that the command rpcinfo doesn't seem to have a reasonable timeout before it fails. I don't want the script to hang
while the rpcinfo is being run. I know with ping I can lower the timeout (ping 10.90.0.11 1) but I can't find anything in the man pages
that shows me a similar way to work with rpc. I just want to do a simple "if rpc fails then echo this device has failed yadda yadda"

I'm working on a Solaris 10 box.

In case anyone cares, the script I'm working with is as follows (if you have any general advice on the script itself...by all means share.

Code:
(15:23:11\[****@Bklyn)
[~/bin]$ cat modCheck 
#!/usr/bin/bash
######################################################
# Program:      modCheck 
# Date Created: 29 January 2009 
# Developer:    **** (Digital Sys. Admin)
# Revised:      21 June 2009; Rewritten to simplify code, added color, ability to dynamically check for number of DeMODs
# Revised:      24 June 2009; added dumping to log file, added ability to use IP and MOD name
# Revised:      14 July 2009; added ping check
# Description:  Generates report of box signon for a given mod
# Last Updated: N/A
######################################################
################
#Define Colours#
################
black='\e[0;30m'
blue='\e[0;34m'
green='\e[0;32m'
cyan='\e[0;36m'
red='\e[0;31m'
purple='\e[0;35m'
brown='\e[0;33m'
lightgray='\e[0;37m'
darkgray='\e[1;30m'
lightblue='\e[1;34m'
lightgreen='\e[1;32m'
lightcyan='\e[1;36m'
lightred='\e[1;31m'
lightpurple='\e[1;35m'
yellow='\e[1;33m'
white='\e[1;37m'
nc='\e[0m'
##############################################
#Make certain that we have something to check#
##############################################
if [ -z $1 ];then
echo -e " ${red}You Must Specifiy what MOD you wish to check${nc}"
exit 1
fi
#################################
#Declare functions for later use#
#################################
nametomod () #Function that changes QPSK names to MOD ID
{
listQpsk -w 999|nawk -v x=$1 '{if (x == $10) print $9}'
}
iptomod () #Function that changes QPSK IP address to MOD ID
{
listQpsk -w 999|nawk -v x=$1 '{if (x == $4) print $6}'
}
modtoip () #Function that converts MOD ID to IP address for use in ping testing
{
listQpsk -w 999|nawk -v x=$mod '{if (x == $6) print $4}'
}
separator() #Function that draws separator
{
 printf "${lightblue}==============================================================================================================${nc}\n"
}
##########################################################################
#Analyze user input to determine if it needs to be translated into MOD ID#
##########################################################################
if [[ $1 != [0-9]** ]];then
mod=`nametomod $1`
elif [[ $1 = 10.*.*.* ]];then
mod=`iptomod $1`
else
mod=$1
fi
################################################################################################
#Analyze user input to determine if it needs to be translated into IP address for later testing#
################################################################################################
if [[ $1 != 10.*.*.* ]];then
ip=`modtoip`
else
ip="$1"
fi
###############
#Get QPSK info#
###############
lq=`listQpsk $mod`
####################################
#establish what time the log starts#
####################################
time=`head -1 /var/log/dncsLog |awk '{print $3}'`
####################################
#Establish number of DeMods on QPSK# 
####################################
num_of_mods=`echo "$lq"|awk '{print $3}'|grep -cw [1-9]`
#########################################################
#Check to see if QPSK is pingable and report information#
#########################################################
pingtest=`ping "$ip"`
if [[ "$pingtest" != "$ip is alive" ]];then
printf "${lightblue}WARNING WARNING WARNING ${red}QPSK $mod is not responding to pings ${lightblue} WARNING WARNING WARNING${nc}\n"
fi
######################################################
#Print Banner (This does not get written to log file)#
######################################################
printf "\t\t\t${white}QPSK $mod has $num_of_mods DeMODS\n\t\t${lightpurple} \
                 Please wait while I gather the Sign on statistics for this MOD${nc}\n"
#################################################
#pull out just relevant information from the log#
#################################################
log_extract=`egrep "Mod=$mod Demod=[0-$num_of_mods] - Sent Verified response" /var/log/dncsLog`

modseq=1 #Establishes baseline for checking all DeMODS
modcheck () #Function that spiders the DNCS log for sign ons
{

until [[ $modseq -gt $num_of_mods ]];do
current_count=`echo "$lq"|awk '{print $3,$5}'|grep -w $modseq|awk '{print $2}'`
total_count=`echo "$log_extract"|grep -wc "Demod=$modseq"`
if [[ $total_count -lt $current_count ]];then
separator
printf "${lightblue}\t${lightcyan}$total_count ${white}boxes have signed onto DeMod $modseq since ${yellow}$time${white} today. This is $(($current_count-$total_count)) ${lightgreen}less${white} boxes than are currently signed on${lightblue}\t\n${nc}"
separator
elif [[ $total_count -gt $current_count ]];then
separator
printf "${lightblue}\t${red}$total_count${white} boxes have signed onto DeMod $modseq ${yellow}$time${white} today. This is $(($total_count-$current_count)) ${red}more${white} boxes than are currently signed on${lightblue}\n${nc}"
separator
fi 

modseq=$(($modseq+1))
done 
echo -e "${white}$lq"
} #End of modcheck Function
makeuserdir () #Function that creates a hidden directory to store log files
{
mkdir $HOME/.modCheck
}
####################################################################
#Check to see if user already has a log directory, if not create it#
####################################################################
if [[ -d $HOME/.modCheck ]];then
name=`listQpsk -w 999|nawk -v mod=$mod '{if (mod == $9) print $10}'`
modcheck|tee $HOME/.modCheck/$name."`date "+%a_%b_%e_%H_%M"|tr " " "_"`"
else
makeuserdir
name=`listQpsk -w 999|nawk -v mod=$mod '{if (mod == $9) print $10}'`
modcheck|tee $HOME/.modCheck/$name."`date "+%a_%b_%e_%H_%M"|tr " " "_"`"
fi

(15:24:05\[ddecosta@Bklyn)
[~/bin]$ modCheck 10.90.0.11
                        QPSK 221 has 4 DeMODS
                Please wait while I gather the Sign on statistics for this MOD
==============================================================================================================
  335 boxes have signed onto DeMod 1 since 13:45:40 today. This is 778 less boxes than are currently signed on  
==============================================================================================================
==============================================================================================================
  327 boxes have signed onto DeMod 2 since 13:45:40 today. This is 897 less boxes than are currently signed on  
==============================================================================================================
==============================================================================================================
  377 boxes have signed onto DeMod 3 since 13:45:40 today. This is 705 less boxes than are currently signed on  
==============================================================================================================
==============================================================================================================
  330 boxes have signed onto DeMod 4 since 13:45:40 today. This is 251 less boxes than are currently signed on  
==============================================================================================================
 ID QPSK Name           Demod   IS2W    SignOn  % SignOn
--- ------------------  -----  -----  --------  --------
221 SUNSETQPSKMOD5B        -       0         0        -
221 SUNSETQPSKMOD5B        1    1588      1113        70
221 SUNSETQPSKMOD5B        2    1700      1224        72
221 SUNSETQPSKMOD5B        3    1517      1082        71
221 SUNSETQPSKMOD5B        4     869       581        66
--- ------------------  -----  -----  --------  --------
    Total (IS2W, signed on)     5674      4000        70
Sep 09 15:24:11 - listQpsk Ended.


Last edited by jim mcnamara; 09-09-2009 at 09:28 PM..
# 2  
Old 09-10-2009
No, rpcinfo does not have such an option. However you could easily write a watchdog script to kill your rpcinfo invocation after a certain time elapses.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

AIX 5.3 NFS export not mounting, rpcinfo hang/timeout on server

Been trying to get a directory NFS-mounted with no success. I've tried both NFS v3 and v4, but currently trying v4. I can't figure out what's going on here. server: sbkovwadmd01 sbkovwadmd01# chnfsdom Current local domain: edw.dev sbkovwadmd01# lssrc -a | grep nfs | grep active nfsd ... (3 Replies)
Discussion started by: eckertd
3 Replies

2. Linux

Is it possible to set timeout on Linux screen session

Hello friends, I work on Linux servers via SSH (putty) and run "screen" to preserve my sessions so I can attach/detach them at anytime I wish without losing the connectivity/process disruption which is working perfectly fine. As my team members also have root access to those servers, it is... (7 Replies)
Discussion started by: prvnrk
7 Replies

3. Shell Programming and Scripting

How to set timeout for dev/tcp while checking hostname and port?

I have a command to check the status of hostname and port number, echo > /dev/tcp/hostname/80 echo $? 0 success case echo > /dev/tcp/hostname/809999 I got the output ------------------- connection timed out It took almost 4 minutes to time out,,, how can I set it to 10 seconds? my... (2 Replies)
Discussion started by: sam@sam
2 Replies

4. Red Hat

How to set the screensaver timeout on Red Hat?

How is it possible to set the screensaver timeout on red hat. For solaris I understand it is : for file in /usr/dt/config/*/sys.resources; do dir=`dirname $file | sed s/usr/etc/` mkdir -p $dir echo 'dtsession*saverTimeout: 10' >>$dir/sys.resources echo 'dtsession*lockTimeout: 10'... (0 Replies)
Discussion started by: alvinoo
0 Replies

5. AIX

Set timeout value for ssh session to HMC?

Friends, Could anyone let me know - how to set the timeout value for ssh session to HMC? My HMC version is -- V7R7.4.0. I'm sure the version doesn't have anything to do with it. Thanks, -- Souvik (2 Replies)
Discussion started by: thisissouvik
2 Replies

6. Shell Programming and Scripting

set Net:SSH:Expect timeout and set it again.

SSHing into a machine can take a few seconds, but after I'm in, the commands return quickly. I was wondering if the timeout setting can be changed once I'm logged into the machine. Does anyone know if this can be set on the fly? The problem here is, if I have to set timeout = 10, it'll take 10... (1 Reply)
Discussion started by: mrwatkin
1 Replies

7. Shell Programming and Scripting

how to set timeout?

When I run a script where the 1st parameter is ip address ftp -n -i -v $1 I hang here if the ip is wrong how to set a timeout something like if (20s not complete "ftp -n -i -v $1") then echo "error" fi Thanks a lot. (14 Replies)
Discussion started by: uativan
14 Replies

8. Shell Programming and Scripting

set timeout for ssh prompt

Hi all, I want to set a timeout say 10 sec to shh prompt i.e. if no password is enetered for 10 sec prompt should again come to shell. How can this be achieved ?? I am using Linux RHEL 5 and Solaris 10. Pls help. Thanks in adv. VIKAS (3 Replies)
Discussion started by: vikas027
3 Replies

9. Programming

How to set the timeout for the client

The scenerio is: 1. A server listens on a port number 2. If the server is down and the Client tries to connect 3. How to set the timeout for the client Detailed explaination: In a client server architecture over a TCP/IP, normally the server is started first which waits and listens for the... (1 Reply)
Discussion started by: shilpi_gup
1 Replies

10. UNIX for Dummies Questions & Answers

how to set timeout for aix?

if a user login and never shutdown or exit...how do you set an automatic shutdown or timeout if the user leave the session on for 20 minutes? thanks (3 Replies)
Discussion started by: ichiro
3 Replies
Login or Register to Ask a Question