From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM" 27-MAY-1993 14:33:14.99
To:	EVERHART
CC:	
Subj:	RE: Accounting info from certain terminal server ports?

From: dougcc@brt.deakin.edu.au
X-Newsgroups: comp.os.vms
Subject: RE: Accounting info from certain terminal server ports?
Date: Fri, 28 May 93 11:30:29 GMT
Organization: Deakin University
Lines: 125
Message-ID: <1u2msu$rhf@sol.deakin.OZ.AU>
NNTP-Posting-Host: vax1.viccol.edu.au
To: Info-VAX@KL.SRI.COM
X-Gateway-Source-Info: USENET

In Article <1tvgt8$qfg@sol.deakin.OZ.AU> I wrote

>I want to get accounting info for users who login to our VMScluster from a
>certain set of terminal server ports.  That is, I want to be able to produce
>summary reports of the connect time for each user is this group.  

Thanks to the people who sent me a solution that fixes the accounting
problem at source, by getting TT_ACCPORNAM info into the accounting record. 
For a kludge, it is actually quite elegant (:-) and I've decided to go with
it for my site.

Alan Simon <simon@hslc.org>, Carl Karcher <KARCHER@WAISMAN.WISC.EDU>, and
Bob Marshall <marshall@nebula.ssd.lmsc.lockheed.com> all sent versions of a
utility originally due to Kevin Homan.  The version I've used is displayed
below.


	.Title log_port
	.ident	/V01.00/
;+
;
; ----	LOG_PORT:	Process' terminal server and port logging
;
;
; Facility:
;
;	VAX/VMS system management
;
; Environment:
;
;	VAX/VMS V5.2 or later, kernel mode
;
;	This routine will extract the current process' terminal server
;	name and port id, if it is a lat process.   This information will
;	then be stored in the remote node name and remote node id fields of
;	the process' P1 space.  These fields are normally only used by
;	RTTDRIVER and REMACP for remote process'.  These fields are
;	however written by the system accounting facility and will provide
;	a convenient means for storing and tracking this information.
;
; Version:     	V01.000
; Date:		07-FEB-1990
;
; Kevin	F. Homan
; Science Applications, Inc.
; 800 Oak Ridge Turnpike
; Oak Ridge, TN  37830
; (615) 482-9031
;
;
; Modifications:
;
; 4/7/93 - RAM. If TT_ACCPORNAM contains something other than a server/port
;          combination (e.g., a remote hostname or an IP address), store
;          the whole thing in the remote_id field (up to 16 characters).
;
;-
 	.page
        .library "SYS$LIBRARY:LIB"                      ;Get special macros from here
        .link    "sys$system:sys.stb"/selective_Search  ;Ease the link process a bit
	.Psect	DATA	noexe,rd,wrt,nopic,noshr,page
dvi_list:	.word	30
		.word	DVI$_TT_ACCPORNAM
		.address port_buffer
		.address port_descr
		.long	0
ttname_desc:	.ascid /TT/
ttchan:	.blkw	1
arglst:		.LONG	2
		.address port_descr
		.address port_buffer
port_descr:	.long 64
		.address	port_buffer
port_buffer:	.blkb	64

	.Psect		CODE	EXE,RD,NOWRT,NOPIC,SHR,PAGE
	.Entry	Start,^m<>

	$Assign_s -
		Devnam	= ttname_desc, -
		Chan	= ttchan	; assign tt
 	Blbc	r0,10$			; can't, die
	$Getdvi_s Chan	= ttchan,-	; Get the real
		Itmlst	= Dvi_list	; device name
 	blbs	r0,20$			; did all of it work?
10$:	ret				; by
20$:	cmpb	#0,port_buffer		; check port
	beql	50$			; null?
	$cmkrnl_s -			; no, continue
		arglst = arglst,-	; arglst
		routin = move_info	; get info in kernel mode
	blbs	r0,40$                  ; err?
	Ret
40$:	$dassgn_s chan=ttchan		; free chan
50$:	$exit_s
 	.page
	.entry	move_info,^m<r2,r3,r4,r5>
	nop
	movl	4(ap),r3		; get port length
	movl	(r3),r2			; length of server/port name
	movl	8(ap),r3		; address of server name
	locc  	#^A"/",r2,(r3)		; locate position of server
	subl	r0,r2			; calculate actual server length
 	pushr	#^m<r0,r2,r3>		; save server length
	cmpb   	#6,r2			; have room for 6 characters
	bgeq	5$			; is there room
	movb    r2,ctl$t_remoteid       ; no, save whole thing as remote id
	movc5  	r2,(r3),#^A/ /,#16,ctl$t_remoteid+1; store remote id
	jmp	15$                     ; done
5$:	movb	r2,ctl$t_nodename      	; store length of server
	movc5  	r2,(r3),#^A/ /,#6,ctl$t_nodename+1; store the server name
                                        ; in remote node field
 	popr	#^m<r0,r2,r3>		; restore port length
	addl	r2,r3			; offset to the portname
	decl	r0			; exclude delimiter
	incl	r3			; ditto
	cmpb   	#16,r0			; have room for 16 characters
	bgeq   	10$			; is there room
	movb	#16,r0			; no, just give first 16
10$:	movb   	r0,ctl$t_remoteid	; store length of port name
	movc5  	r0,(r3),#^A/ /,#16,ctl$t_remoteid+1; store port name
                                        ; in remote id field
15$:	movl	#ss$_normal,r0
	ret
	.end	start

