Info-3b2 Digest, Number 85

Ken Davis kdavis at lamc.UUCP
Tue May 23 01:54:18 AEST 1989


 
                           Info-3b2 Digest, Number 85
 
                             Monday, May 22nd 1989
 
Today's Topics:
 
                                 Re: idledaemon
                                 Re: idledaemon
                         Wanted: 3b2/500, 600 or larger
                         Wanted: 3b2/500, 600 or larger
----------------------------------------------------------------------
 
Subject: Re: idledaemon
From: info-3b2 at netsys.COM
Date: Fri, 19 May 89 10:16:18 -0400

Subject: Re: idledaemon
Date: Fri, 19 May 89 10:08:33 EDT
From: "Tim J Ihde" <tim at attdso.dec.com>

Here's a relativly flexible idle-killer that I wrote a while back.  I run
it from cron every now and then to kill off various users.  We can only
have so many people logged in via our STARLAN, so I usually kill them
quickly (15 min).  Incoming modems are always a premium, so they go as well.
Regular tty's I don't worry about too much, so they can be idle for
45 minutes.

The pattern for who to kill is passed to lcheck.sh as the first argument.
This pattern will be used by egrep on the output of a "who -uTH" to find
who to kill.  With this setup you can put comments in /etc/inittab to
match on - for example I put "modem xxx-xxxx" in the file, and then I
can use 'modem' as a pattern to lcheck.sh for killing users logged in via
modems.  The second argument passed is the maximum idle time to allow.

There are some tunables here - you can specify certain users or certain
processes that will never be killed.

This tries to be friendly, and kill first with a SIGHUP.  Most programs
(notibly vi) will clean up before terminating with this signal.  Vi will
at least save the file the person was editing instead of losing it.  If
the SIGHUP  doesn't work then SIGKILL is used.

A logfile "lcheck.log" is maintained containing information about who and
what was killed.  Data can also be mailed to root if desired.

Here are the cron entries I use at the moment:

1,11,21,31,41,51 * * * *	/usr/root/PM-D/lcheck.sh 'slan|modem' >/dev/null
5,35 * * * *			/usr/root/PM-D/lcheck.sh 'tty' 45 >/dev/null

And here's the program:

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	lcheck.sh
#
if test -f 'lcheck.sh'
then
	echo shar: will not over-write existing file "'lcheck.sh'"
else
	echo x - 'lcheck.sh'
	sed 's/^X//' >'lcheck.sh' << 'SHAR_EOF'
X###
X#
X#  name		lcheck.sh - check for idle users
X#
X#  synopsis	lcheck.sh <egrep pattern> <max idle>
X#
X#  author	Tim J Ihde
X#
X###
X
XWORKDIR=/usr/root/PM-D
XPATTERN=${1:-slan}			#pattern to match, def 'slan'
XUIGNORE="tim"				#never kill these users
XPIGNORE="ttysrv|uucico|UUCICO|rnews"	#never kill these processes
XMAXIDLE=${2:-15}			#max min. of idle time, def 15 minutes
X
Xecho "PATTERN - [$PATTERN]"
Xecho "MAXIDLE - [$MAXIDLE]"
X
Xcd $WORKDIR
Xrm -f lcheck.now killps
X
X#
X#	pass one: politely suggest that these processes go away
X#
Xwho -uTH |
Xegrep "$PATTERN" |
Xegrep -v "$UIGNORE" |
Xcut -c1-9,12-18,37-50 |
Xsed ' /\./D
X    s/://
X    ' |
Xwhile read login ttyname itime pid
Xdo
X    if [ $itime = "old" -o $itime -gt $MAXIDLE ]
X    then
X	who -uTH | grep $ttyname | tee -a lcheck.log
X	ps -ft$ttyname
X	ps -t$ttyname | tail +2 | egrep -v "$PIGNORE" |
X	while read procid stuff
X	do
X	    echo $procid >>killps
X	    kill -1 $procid 2>/dev/null
X	    [ $? -eq 0 ] && echo "1 -> $procid"
X	done
X	ps -ft$ttyname
X    fi
Xdone > lcheck.now
X
X#	wait for them to die
Xsleep 5
X
X#
X#	pass two: no more mister nice guy
X#
X
Xif [ -s killps ]
Xthen
X    while read procid
X    do
X	kill -9 $procid 2>/dev/null
X	[ $? -eq 0 ] && echo "9 -> $procid"
X    done < killps
Xfi >> lcheck.now
X
X#print report if we did anything
X[ -s lcheck.now ] && cat lcheck.now
X
X#or mail the report here if you prefer
X#if [ -s lcheck.now ]
X#then
X	#mailx -s'login_killed' root <lcheck.now
X#fi
X
Xexit 0
SHAR_EOF
if test 1432 -ne "`wc -c < 'lcheck.sh'`"
then
	echo shar: error transmitting "'lcheck.sh'" '(should have been 1432 characters)'
fi
echo Done
exit 0

-- 
Tim J Ihde				INTERNET:   tim at attdso.att.com
(201) 898-6687				UUCP:	    att!attdso!tim

------------------------------
 
Subject: Wanted: 3b2/500, 600 or larger
From: info-3b2 at netsys.COM
Date: Fri, 19 May 89 13:48:02 -0400

Subject: Wanted: 3b2/500, 600 or larger
Date: 19 May 89 00:45:27 GMT

Greetings!

	We're looking for a used 3b2/500, or larger. It should have at least:
    			
			a 300mb disk,
			8mb of ram,
			console,
	   		ethernet interface board and
			an intelligent serial card.

	We would also appreciate any leads to vendors of used AT&T equipment.

	Thanks.
	
-- 
____*_  Neil J. Wilson              {sun,sharkey,pacbell}!indetech!neil
\  / /  Independence Technologies
 \/ /   42705 Lawrence Place        FAX: 415 438-2034
  \/    Fremont, CA 94538           Voice: 415 438-2017

 
-------------------------------------
 
To join this group or have your thoughts in the next issue, please
send electronic mail to Ken Davis at the following address;

    {apple, netsys, pacbell, pyramid}!lamc!info-3b2-digest
 
The views expressed in Info-3b2 Digest are those of the 
individual authors only.
 
**********************
End of Info-3b2 Digest
**********************



More information about the Comp.sys.att mailing list