rloginds

Gary Weimer weimer at ssd.kodak.com
Thu Nov 8 07:14:44 AEST 1990


In article <4852 at tahoe.unr.edu> enteles at tahoe.unr.edu (Philip Enteles) writes:
>
>	We are having some trouble at our site and I would like to know 
>if anyone has had a similar problem. 
>	We are running 4.3 BSD on a Sperry 7000-40. This system is the
>backbone of our undergraduate computer science department and has about
>500 users. The system itself seems to run fine however left to its own
>devices it accumulates a number of rlogind processes that become hung.
>We are not sure where these processes are coming from but they only
>effect ptys. These stay hung until they are killed. If they are not
>killed at some point they begin to hold all the ptys and error messages
>start appearing when users try to do things like use script or login in
>from a dial-up port(like a sytec box). The error message is 
>	'no more pty's'
>When we reboot or manually kill those process everything is fine. 


This doesn't help you with the PROBLEM, but it may function as a
temporary fix. It is a shell script that will automatically find
and kill these errant logind processes (based on the info you supplied).


Here is the main script to be called by cron (or manually)
(note that program assumes a test mode (see 'set TEST') move
 the comment to actually perfom kill)

------------------------- CUT HERE -------------------------
#!/bin/csh -fb
#
#     FILE: fxlogin
#     DESC: fix errant logind processes
#

# find path and name for this program
set PROGRAM = $0
set PATH    = $PROGRAM:h
set PROGRAM = $PROGRAM:t
if ("$PATH" == "$PROGRAM") set PATH=$cwd

# assume PARSER (used for awk) has same name as this prog with .parse ext
set PARSER  = $PATH/$PROGRAM.parse

set SIG    = -9                   # signal for killing processes
set TMP    = "/tmp/tmp$$"         # tmp file

set TEST   = 1                    # test run of program, don't kill processes
#set TEST   = 0                    # the real thing, DO kill processes

# find which terminals have errant logind's and put the list in LIST
set LIST = ls -l /dev/ttyp? | awk '{if ($3 == "root" && $1 == "c---------") print substr($10,length($10)-2)}'
# in case your mailer truncates here is a copy of above line
# set LIST = ls -l /dev/ttyp? | awk '{if ($3 == "root" && $1 == "c---------")
# print substr($10,length($10)-2)}'

# if no processes to kill, then exit
if ("$LIST" == "") exit

# find all logind process and put them in TMP in '<tty> <pid>' format,
# sorted by <tty>
ps -aux | grep "rlogind" | grep -v "grep" | awk '{print $7 " " $2}' | sort >$TMP

# store pid's of errant logins in PIDS
set PIDS = `(echo $LIST; cat $TMP) | awk -f $PARSER`

rm $TMP

if ("$TEST") then
    echo "In test mode. Would have killed pids:"
    echo "    $PIDS"
else
    kill $SIG PIDS
endif
------------------------- CUT HERE -------------------------

and here is the paser used by above program:

------------------------- CUT HERE -------------------------
#
#     FILE: fxlogin.parse
#     DESC: awk script used by fxlogin
#
#     first line of input (nt == 0) is sorted list of tty's to kill processes on
#     remaining lines have <tty> <pid>, lines sorted in tty order
#
#     nt      = number of tty's to kill processes of
#     ct      = current tty to kill processes of
#     tty[]   = array of tty's to kill processes of
#
#     NOTE:  does not assume one process per tty

# get tty's to kill processes on
{if (nt == 0) {
		if (NF == 0) exit;
                for (nt=1; nt <= NF; nt++) {
                        tty[nt] = $nt
                }
                nt--;
                ct = 1;
                next
        }
}

# found a process for tty[ct]
{if (tty[ct] == $1) {
                print $2;
                next
        }
}

# tty[ct] has no more processes to kill
{while (ct <= nt && tty[ct] < $1) ct++ }

# this tty not in kill list
------------------------- CUT HERE -------------------------

I hope you've found the problem and don't need this.

Gary



More information about the Comp.unix.questions mailing list