Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

telnet that takes 99.9 CPU time

Status
Not open for further replies.

lhg1

IS-IT--Management
Mar 29, 2005
134
0
0
DK
Hi

From unix (in this case Tru64, but the same on HP)

I use this script to call an HTTP PHP page.

I do this a lot, but in rare cases the telnet process hangs and takes 99.9% of the cpu.

This is the code that I'm using, one of the reasons for dooing it like this is the ability to do this from all unix servers without installing other applications.

Code:
updateStatus ()
{
echo "Updating1"
if [ -z "$1" ]; then
		echo "Update parm 1"
        echo "Usage:"
        echo "$0 var1=value1 ... varN=valueN"
        exit
fi
port='80'
reciever='/prodlog/status/update.php'
host=testserv
retry=20
for i in $@; do
        if [ -z "$params" ]; then
                params=$i;
        else
                params=$params'&'$i
        fi
		echo "Updating parm"
done
cmd="GET $reciever?$params /HTTP/1.1\nHost: $host\n"
i=0
echo "while [ "$output" != "statusUpdate OK" -a $i -ne $retry ]"

while [ "$output" != "statusUpdate OK" -a $i -ne $retry ] ; do
        let i=$i+1
        output=`( echo open ${host} ${port}
        sleep 1
        echo ${cmd}
        /bin/perl -e 'sleep .1'
        echo
        echo
        /bin/perl -e  'sleep .1'
        echo exit ) | telnet | grep statusUpdate ` 2> /dev/null
        echo "UpdateReal  " $i
        echo $cmd
        sleep 1;
done
output="done"
}

Does anyone have ideers of what is happening? - and any fixes og workarounds?

Can I ex. put a timeout on the telnet session?


Thanks
LHG
 
Consider using nc (NetCat) instead of telnet perhaps, it's more suited to this kind of automated usage.

Annihilannic.
 
Hi

I don't know NetCat, and I've checked it isn't on most of our serveres, the main reason for using telnet is that it is an all servers, and this is usede on a lot of different server.
Installing new software on all thise servers it not an easy task.

In my view I can do 2 things.
- Find software that i don't need to install (that can just be placed on the server)

- Find a solution for the current telnet method, that works in 99% of the times.

/LHG


 
Are you able to truss or strace or similar (not sure what kinds of system trace tools there are on Tru64) the process to figure out what exactly it's doing with this CPU time?

I'm not aware of any telnet timeout facility (not saying there isn't one, just not familiar), but you could always implement your own watchdog function in your script which runs in the background and kills it if it's taking too long or too much CPU.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top