cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c	Scanuser.for
c	This program scans each system at regular intervals to determine who
c	is logged on and writes it to a file to be read by DISPUSER.
c	Dale Miller - UALR
c	18-Apr-1985
c
c	Rev. 1.0  18-Apr-1985
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
	implicit integer(a-z)
	character terminal*9,node*6,pterminal*6
	character imagname*80,username*12,prcnam*15
	character nodename*6
	character image*15
	character logint*8
	integer*2  timbuf(7)
	real seconds
	include '($jpidef)'
	include '($dvidef)'
	include '($syidef)'
	include '($ssdef)'


	open(unit=1,organization='relative',recordtype='fixed',
     &	access='direct',recl=128,status='old',form='formatted',
     &	shared,file='sys$manager:scanuser.dat')

	istat = lib$getsyi(syi$_nodename,,nodename,,,)

c SITE-SPECIFIC!! Your node names go here.  The offsets should be in multiples
c of the number of users (max) per node (currently 100).

	if(nodename.eq.'ALPHA')	offset=0
	if(nodename.eq.'BETA')	offset=100
	if(nodename.eq.'GAMMA')	offset=200
	if(nodename.eq.'DELTA')	offset=300
c	program re-enters here after wait
 0009	recnum=offset+1	
	pid=-1
c	loop to scan all users
 0010	continue
	istat = lib$getjpi(jpi$_pid,pid,,realpid,,)
	if(istat.eq.ss$_nomoreproc) goto 1000
	istat = lib$getjpi(jpi$_terminal,realpid,,,terminal,)
	if(terminal.eq.' ') goto 10
	istat = lib$getjpi(jpi$_imagname,realpid,,,imagname,len)
	if (len.eq.0) then
	    image='<DCL>'
	else
	    imagname = imagname(index(imagname,']')+1:)
	    if(index(imagname,']').eq.0) then
	        image=imagname
	    else
	        image=imagname(index(imagname,']')+1:)
	    endif
	    image=image(1:index(image,'.')-1)
	endif
	istat = lib$getdvi(dvi$_tt_phydevnam,,terminal,,pterminal,)
	istat = lib$getjpi(jpi$_username,realpid,,,username,)
	istat = lib$getjpi(jpi$_prcnam,realpid,,,prcnam,)
	istat = lib$getjpi(jpi$_authpriv,realpid,,apriv,,)
	istat = lib$getjpi(jpi$_pri,realpid,,pri,,)
	istat = lib$getjpi(jpi$_cputim,realpid,,cputim,,)
	istat = lib$getjpi(jpi$_logintim,realpid,,logint,logintim,)
        istat = sys$numtim(timbuf,logint)

	do i=1,15
	    if(prcnam(i:i).lt.' ') prcnam(i:i)='.'
	    end do

	write(1'recnum,100)pid,terminal,pterminal,username,prcnam,image,
     &	pri,apriv,cputim,timbuf
 0100	format(z8,a9,a6,a12,a15,a15,i2,z8,z8,i4,6i2)

	recnum=recnum+1
        go to 10


 1000	continue
	write(1'recnum,110)0
 0110	format(i128)
	seconds=30.
	istat=lib$wait(seconds)
	go to 9
	end
