#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # diag_fgo diag_kill idle.sh killidle.sh # # This shell archive created: Tue Jan 24 09:24:14 EST 1995 # echo "Extracting file diag_fgo" sed -e 's/^X//' <<\SHAR_EOF > diag_fgo X#!/bin/sh X# X# diag_fgo: Extracts "fglgo" or sql process lines from ps list for X# audit trail. X# Author: Another Tim Schaefer creation X# Latest: Wed Nov 30 15:29:46 EST 1994 X# Notes: DG/UX version X# X# DG/UX version of awk prints every line even if you don't want it to, X# therefore, this script uses the output accordingly. X# X# Add 10 minutes to the idle time you're figuring, so that those users X# with idle times close to the high-water mark that don't get wacked on X# one pass will get wacked on the next one. X# Xps -ef | egrep "fglgo|sql" | \ Xnawk ' { X{ printf("%10s %10d %10d %10s %10s %10s\n", $1, $2, $3, $7, $8, $9 ) } X} X' | sort SHAR_EOF if [ `wc -c < diag_fgo` -ne 677 ] then echo "Lengths do not match -- Bad Copy of diag_fgo" fi echo "Extracting file diag_kill" sed -e 's/^X//' <<\SHAR_EOF > diag_kill X#!/bin/sh X# X# diag_kill: Diagnostic program for the kill_idle.sh script to kill X# idle logins. Use this program to diagnose the output X# for use with kill_idle.sh X# X# This is 'identical' in principle to kill_idle.sh X# X# Author: Another Tim Schaefer creation X# Latest: Wed Nov 30 15:29:46 EST 1994 X# Notes: DG/UX version X# X# DG/UX version of awk prints every line even if you don't want it to, X# therefore, this script uses the output accordingly. X# X# Add 10 minutes to the idle time you're figuring, so that those users X# with idle times close to the high-water mark that don't get wacked on X# one pass will get wacked on the next one. X# XDATE_STR=`date` Xwho -HuTt | nawk ' { printf("%s %s %s %s %s\n", $1, $6, $7, $8, $9 ) } ' | \ Xsort | \ Xnawk ' gsub ( ":", " : ", $0 ) ' | nawk ' { printf("%s %s\n", NF, $0 ) } ' |\ Xnawk ' BEGIN { ps_id=0; ps_id="" } X{ if ( $1 == 6 ) X { X { if ( $6 ~ "old" ) X { X ps_id=$7 X run_str= "kill -9 "ps_id X print run_str X { printf( "OLD:6:%s\n",$0 ) } X } X } X } X} X{ if ( $1 == 8 ) X { X { if ( $6 > 0 ) X { X ps_id=$9 X run_str= "kill -9 "ps_id X print run_str X { printf( "8:6gt0:%s\n",$0 ) } X break; X } X } X { if ( $8 >= 10 ) X { X ps_id=$9 X run_str= "kill -9 "ps_id X print run_str X day_str="'"$DATE_STR"'" X { printf( "%s [%s]\n", $0, day_str ) } X break; X } X } X } X} X' SHAR_EOF if [ `wc -c < diag_kill` -ne 1459 ] then echo "Lengths do not match -- Bad Copy of diag_kill" fi echo "Extracting file idle.sh" sed -e 's/^X//' <<\SHAR_EOF > idle.sh X#!/bin/sh X# X# idle.sh X# X Xwhile true Xdo Xidle_min=`who -HuTt | grep $LOGNAME | awk ' { print $7 } ' | awk -F":" ' { gsub( 0,"",$2); print $2 }' ` Xif [ "$idle_min" = "" ] ; then X idle_min=0 Xfi Xif [ $idle_min -ge 2 ] ; then X echo "Hello World: $LOGNAME [$idle_min] `date`" X echo "\07 \07 \07" Xfi Xsleep 60 Xdone SHAR_EOF if [ `wc -c < idle.sh` -ne 318 ] then echo "Lengths do not match -- Bad Copy of idle.sh" fi echo "Extracting file killidle.sh" sed -e 's/^X//' <<\SHAR_EOF > killidle.sh X#!/bin/sh X# killidle.sh: Kills idle logins. Run from cron X# Author: Another Tim Schaefer creation X# Latest: Wed Nov 30 15:29:46 EST 1994 X# X# Notes: set up in root cron to run once every 10 minutes all the time X# X# Annex Servers: The user gets bumped off back to the Local> prompt without X# trauma. X# X# To avoid getting bumped by this script run the idle.sh from your login in X# the background: $ idle.sh & X# X# This will keep your idle time current in the ps list. Adjustable. X# X# Current bump-off time is set for one hour. A typical user will sometimes X# get an extra 10 minutes depending on how much time they have accumulated X# when this script kicks off. For example, if you have 58 minutes of idle X# time at kick-off, you won't get bumped. So 10 minutes later your idle time X# is now over an hour and then you get bumped. X# X# Currently set up for a /admin/adm directory, but you can put it anywhere X# you like. X# Xday1=Sun Xday2=Mon Xday3=Tue Xday4=Wed Xday5=Thu Xday6=Fri Xday7=Sat XHR_STR=`date +%H` XMN_STR=`date +%M` XDAY=`date +%a` XDATE_STR=`date` Xif [ $HR_STR -eq 23 -a $MN_STR -eq 50 ] ; then X if [ -f /admin/adm/killed.log ] ; then X echo "End $DAY kill log: `date`" >> /admin/adm/killed.log X mv /admin/adm/killed.log /admin/adm/killed.${DAY} X fi Xfi Xecho " -------------- `date` -------------- " >> /admin/adm/killed.log Xwho -HuTt | grep -v root | nawk ' { printf("%s %s %s %s %s\n", $1, $6, $7, $8, $9 ) } ' | \ Xsort | \ Xnawk ' gsub ( ":", " : ", $0 ) ' | nawk ' { printf("%s %s\n", NF, $0 ) } ' | \ Xnawk ' BEGIN { ps_id=0; run_str="" ; X } X{ if ( $1 == 6 ) X { X { if ( $6 ~ "old" ) X { X ps_id=$7 X run_str="" X run_str= "ps -fu "$2" >> /admin/adm/killed.log" X system( run_str ) X run_str= "kill -9 "ps_id X system( run_str ) X run_str="" X run_str="'"$DATE_STR"'" X { printf( "OLD:%s %s %s %s\n",$2, $6, $7, run_str ) >> "/admin/adm/killed.log" } X } X } X } X} X X# X# Check the HOURS of accumulated time: X# X X{ if ( $1 == 8 ) X { X { if ( $6 > 0 ) X { X ps_id=$9 X run_str="" X run_str= "ps -fu "$2" >> /admin/adm/killed.log" X system( run_str ) X run_str="" X run_str= "kill -9 "ps_id X system( run_str ) X run_str="" X run_str="'"$DATE_STR"'" X { printf( "KILLED:%s IDLE:[%s Hours] PS:%s [%s]\n",$2,$6,$9,run_str ) >> "/admin/adm/killed.log" } X break; X } X } X# X# Check the Minutes of accumulated time: X# If you want them off in less than an hour, then adjust here. X# X { if ( $8 >= 59 ) X { X ps_id=$9 X run_str="" X run_str= "ps -fu "$2" >> /admin/adm/killed.log" X system( run_str ) X run_str="" X run_str= "kill -9 "ps_id X system( run_str ) X run_str="'"$DATE_STR"'" X { printf( "KILLED:%s IDLE:[%s Minutes] PS:%s [%s]\n",$2,$8,$9,run_str ) >> "/admin/adm/killed.log" } X break; X } X } X } X} X' X/admin/adm/diag_fgo > /admin/adm/diag_fgo.log SHAR_EOF if [ `wc -c < killidle.sh` -ne 2903 ] then echo "Lengths do not match -- Bad Copy of killidle.sh" fi echo "Done." exit 0