Operating System - HP-UX
1847253 Members
4399 Online
110263 Solutions
New Discussion

HP-UX hanging telnet session

 
hptcsdev
New Member

HP-UX hanging telnet session

Hi All,

There any way to identify the hanging telnet sessions ?

If the user logs into the machine through telnet and closes the window without exiting properly , whether those sessions cleaned up after a specific time ?? What is the time period for that ?

We need this info because the user will be running some interactive scripts in those telnet sessions and if the user does not exit properly, we need to clean up those scripts (which will be child process of that telnet session).

Please let us know if u have any suggestions.

Arun
7 REPLIES 7
harry d brown jr
Honored Contributor

Re: HP-UX hanging telnet session


You could write a script to look for the scripts that don't have tty's associated with them, then blow them away.

I haven't seen that behavior with telnet. Are your scripts doing trap's?

live free or die
harry
Live Free or Die
Steven E. Protter
Exalted Contributor

Re: HP-UX hanging telnet session

The TMOUT variable in configuration prior to the script may help.

It does help if the user is just sitting on the command prompt.

insf -e might help if the problem is being generated by bad pseudo device drivers.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sridhar Bhaskarla
Honored Contributor

Re: HP-UX hanging telnet session

Hi Arun,

If the telnet session exits, then all the child processes that were spawned by it should also die unless they were started with 'nohup' option.

You can probably modify the script to output the pids of the subshells into a file in some directory including it's own. Have a cronjob that checks those files periodically. If the pid of the script is not found in the 'ps -ef' list, then it can go ahead and kill rest of the pids in that file. Not a 100% sure shot, but it can be the closest you have.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Ron Kuris
Occasional Advisor

Re: HP-UX hanging telnet session

This problem usually happens when the PC is shut off. The sessions will not time out unless your telnetd supports keepalive.

It's possible to write a script that kills idle sessions, but I hate those.

My suggestion: Move off telnet and switch to ssh. There are good client programs like putty that can be used to talk over ssh. This will give you keepalives (you may need to configure the server to turn them on).
hptcsdev
New Member

Re: HP-UX hanging telnet session

Hi,

The tty for handing sessions is still "pts/tj". This remains the same even after hours.


We hav a daemon scheduled, which kills all our script running with (tty=? or ppid=1) But this is not working now as the tty remains the same and not changing to '?' even after the parent session is closed.

What could be the problem here ??

Also I have no idea how to check if the 'telnetd' supports 'keepalive'. Could anyone help me out on this..And how to change the behaviour to automatically terminate the hanging telnet sessions ?

Thanks,
Arun
Sยภเl Kย๓คг
Respected Contributor

Re: HP-UX hanging telnet session

Hi Arun
Use netstat -a|grep FIN to find the lost telnet connections.

use this script sweep

#!/usr/bin/ksh
#
# "flush_stale_finw2" -- Wolffman 6/2/98
#
# Script to flush stale FIN_WAIT_2 sockets.
# Script execution with the "-f" option results in
# HP machine sending TCP RST along with clean release
# and freeing of associated connection resources.
# (Essentially, returning kernel memory back for reuse.)
#
# Suggestion: invoke via "cron" job during off hours
#
#
#
# Usage: flush_stale_finw2 # To list sockets in FIN_WAIT_2 state
# flush_stale_finw2 -f # To actually force their removal
#
#
if test "$1" = "-f"
then
/usr/bin/ndd -get /dev/tcp tcp_status | grep FIN_WAIT_2 |
awk '{ printf "ndd -set /dev/tcp tcp_discon 0x%s\n", $1 }' > /tmp/finw2
/sbin/chmod 700 /tmp/finw2
/usr/bin/ksh -x /tmp/finw2

/sbin/rm /tmp/finw2
else
/usr/bin/ndd -get /dev/tcp tcp_status | grep FIN_WAIT_2
fi



Infact the same was alreadydisccused in a previuos thread


regards
SK
Your imagination is the preview of your life's coming attractions
harry d brown jr
Honored Contributor

Re: HP-UX hanging telnet session


WHat version of HPux are you running?

When was the last set of network patches applied?

live free or die
harry
Live Free or Die