/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Purpose: Verify some of the ADSM accounting record information and */ /* provide some other information from those records */ /* */ /* Format: ADSMACCT infileid outfileid */ /* Where: infileid is the name of the accounting file */ /* outfileid is the name of the report file */ /* */ /* File Names: MUST be fully qualified for the operating system on */ /* which this program is running. */ /* */ /* Program Name: depends on the operating system: */ /* CMS = ADSMACCT EXEC */ /* MSDOS = ADSMACCT.BAT (REXX88) */ /* PCDOS = ADSMACCT.REX (Personal REXX) */ /* OS/2 = ADSMACCT.CMD */ /* AIX/6000 = ADSMACCT.REX ? */ /* */ /* Entering '?' gets this minimal help */ /* */ /* Calibrated by running and manually checking sample Accounting files */ /* on 10/20/93 by John C. Steffens */ /* */ /* Author : John C. Steffens */ /* */ /* Copyright (C) 1994 IBM Corporation */ /* */ /* DISCLAIMER OF WARRANTIES. The following [enclosed] */ /* program is created by IBM Corporation. This program is not */ /* part of any standard or IBM product and is provided to you solely */ /* for the purpose of assisting you in the use of your ADSM */ /* application. The program is provided "AS IS", without */ /* warranty of any kind. IBM shall not be liable for any damages */ /* arising out of your use of the program, even if they have been */ /* advised of the possibility of such damages. */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ descend = 26 Parse Source os . execfn execft execfm . . Select When os = 'CMS' Then Do Parse Arg infile_n infile_t infile_m outfile_n outfile_t, outfile_m junk infileid = infile_n infile_t infile_m outfileid = outfile_n outfile_t outfile_m junk clearscreen = 'VMFCLEAR' os = 'C' End When os = 'MSDOS' Then Do Parse Arg infileid outfileid junk clearscreen = 'CLS' os = 'D' End When os = 'OS/2' | os = 'PCDOS' | os = 'AIX/6000' Then Do Parse Arg infileid outfileid junk clearscreen = 'CLS' os = 'O' End Otherwise Say '>'os'< Operating System not implemented' Exit 4 End /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Initialize and check parameters */ /* Get rid of any outstanding output files */ /* Process each accounting record */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Initialize and check parameters */ /* */ If infileid = '?' Then Do clearscreen Help: Parse Arg stuff Say Say execfn stuff Say If os = 'C' Then 'TYPE' execfn execft execfm '1' descend If os = 'D' Then Do i = 1 To descend stuff = Read(execfn) Say stuff End If os = 'O' Then Do i = 1 To descend stuff = Linein(execfn) Say stuff End Exit 4 End clearscreen If infileid = '' Then Do Say Say 'Input file must be specified' Signal Help End If outfileid = '' Then Do Say Say 'Output file must be specified' Signal Help End If junk <> '' Then Do Say Say 'Invalid format for command' Signal Help End /* */ /* Get rid of any outstanding output files */ /* */ If os = 'C' Then Do 'IOX STATE' outfileid If rc = 0 Then Do 'HT' 'ERASE' outfileid '(NOTYPE' 'RT' End End If os = 'D' Then If Size(outfileid) <> '' Then 'ERASE' outfileid If os = 'O' Then If Stream(outfileid,'C','QUERY EXISTS') <> '' Then 'ERASE' outfileid /* */ /* Process each accounting record */ /* */ execfn = Translate(execfn) today = Date(USA) now = Time() first_id = '' errflg = 0 acct_recd = Get_line(infileid) Do While acct_recd <> '' Parse Value acct_recd With f1 ',' f2 ',' f3 ',' f4 ',' f5 ',' f6 ',', f7 ',' f8 ',' f9 ',' f10 ',' f11 ',' f12 ',' f13 ',' f14 ',', f15 ',' f16 ',' f17 ',' f18 ',' f19 ',' f20 ',' f21 ',' f22 ',', f23 ',' f24 junk this_id = f3 f1 f2 If this_id = first_id Then Do this_stamp = Makestamp(f4'@'f5) If start_stamp >> this_stamp Then Do If errflg = 0 Then Call Errrtn(0) Call Put_line('S: Timestamp sequence error:' f4 f5 'in' acct_recd) Call Put_line(start_stamp '>>' this_stamp) Call Put_line('') start_stamp = this_stamp End If this_stamp << end_stamp Then Do If errflg = 0 Then Call Errrtn(0) Call Put_line('E: Timestamp sequence error:' f4 f5 'in' acct_recd) Call Put_line(this_stamp '<<' end_stamp) Call Put_line('') End end_stamp = this_stamp End Else Do If first_id <> '' Then Do Call Put_Summary If errflg <> 0 Then Call Errrtn(0) Call Put_line('Product changed:' this_id 'in' acct_recd) Call Put_line('') End Call Init_values first_id = this_id id_string = f3 'at Level' f1'.'f2 datetime = f4'@'f5 start_stamp = Makestamp(f4'@'f5) end_stamp = start_stamp End Call Sum_values acct_recd = Get_line(infileid) End Call Put_Summary If os = 'C' Then 'FINIS * * *' Exit 0 /* */ Sum_values: /* Sum values */ /* */ If f6 <> '' & f6 <> ' ' & Wordpos(f6,client_nodes) = 0 Then Do f6 = Strip(f6) client_nodes = client_nodes f6 If Length(f6) > maxf6 Then maxf6 = Length(f6) End If f7 <> '' & f7 <> ' ' & Wordpos(f7,client_owners) = 0 Then client_owners = client_owners f7 If f8 <> '' & f8 <> ' ' & Wordpos(f8,platforms) = 0 Then platforms = platforms f8 If f9 <> '' & f9 <> ' ' & Wordpos(f9,auth_methods) = 0 Then auth_methods = auth_methods f9 If f10 <> '' & f10 <> ' ' & Wordpos(f10,commo_methods) = 0 Then Do f10 = Translate(Strip(f10),'_',' ') commo_methods = commo_methods f10 If Length(f10) > maxf10 Then maxf10 = Length(f10) End If f11 <> '' & f11 <> ' ' & Wordpos(f11,term_inds) = 0 Then term_inds = term_inds f11 total_arch_files = total_arch_files + f12 total_arch_kb = total_arch_kb + f13 total_retr_files = total_retr_files + f14 total_retr_kb = total_retr_kb + f15 total_bkup_files = total_bkup_files + f16 total_bkup_kb = total_bkup_kb + f17 total_rest_files = total_rest_files + f18 total_rest_kb = total_rest_kb + f19 total_data_kb = total_data_kb + f20 total_duration = total_duration + f21 total_idle_wait = total_idle_wait + f22 total_commo_wait = total_commo_wait + f23 total_media_wait = total_media_wait + f24 these_files = f12 + f14 + f16 + f18 these_kb = f13 + f15 + f17 + f19 total_files = total_files + these_files total_kb = total_kb + these_kb Return /* */ Init_values: /* Initialize values */ /* */ client_nodes = '' client_owners = '' platforms = '' auth_methods = '' commo_methods = '' term_inds = '' total_arch_files = 0 total_arch_kb = 0 total_retr_files = 0 total_retr_kb = 0 total_bkup_files = 0 total_bkup_kb = 0 total_rest_files = 0 total_rest_kb = 0 total_data_kb = 0 total_duration = 0 total_idle_wait = 0 total_commo_wait = 0 total_media_wait = 0 total_files = 0 total_kb = 0 maxf6 = 0 maxf10 = 0 Return /* */ Put_summary: /* Put out summaries */ /* */ output = '' If os = 'C' Then output = '1' If os = 'D' | os = 'O' Then output = '0C'x Call Put_line(output) Call Put_line('') output = Left('I B M C O N F I D E N T I A L',39) output = output || Right('Processed:' today 'at' now,39) Call Put_line(output) Call Put_line('') output = Center('Accounting Data Report',79) Call Put_line(output) Call Put_line('') output = Center('For:' id_string,79) Call Put_line(output) Call Put_line('') fromdate = Substr(start_stamp,5,2)'/'Substr(start_stamp,7,2)'/', || Substr(start_stamp,1,4) 'at' Substr(start_stamp,9,2)':', || Substr(start_stamp,11,2)':'Substr(start_stamp,13,2) output = Center('From:' fromdate,79) Call Put_line(output) todate = Substr(end_stamp,5,2)'/'Substr(end_stamp,7,2)'/', || Substr(end_stamp,1,4) 'at' Substr(end_stamp,9,2)':', || Substr(end_stamp,11,2)':'|| Substr(end_stamp,13,2) output = Center(' To:' todate,79) Call Put_line(output) Call Put_line('') Call Put_line('') blanks = ' ' Call Put_line('Client Nodes') output = ' (Unique in Field 6):' Do i = 1 To Words(client_nodes) use = Left(Word(client_nodes,i),maxf6) If Length(output) + Length(use) > 78 Then Do Call Put_line(output) output = blanks End Else output = output use End Call Put_line(output) Call Put_line('') Call Put_line('Client Owners') output = ' (Unique in Field 7):' Do i = 1 To Words(client_owners) use = Left(Word(client_owners,i),8) If Length(output) + Length(use) > 78 Then Do Call Put_line(output) output = blanks End Else output = output use End Call Put_line(output) Call Put_line('') Call Put_line('Client Platforms') output = ' (Unique in Field 8):' Do i = 1 To Words(platforms) use = Left(Word(platforms,i),8) If Length(output) + Length(use) > 78 Then Do Call Put_line(output) output = blanks End Else output = output use End Call Put_line(output) Call Put_line('') Call Put_line('Authentication Methods') output = ' (Unique in Field 9):' Do i = 1 To Words(auth_methods) use = Left(Word(auth_methods,i),8) If Length(output) + Length(use) > 78 Then Do Call Put_line(output) output = blanks End Else output = output use End Call Put_line(output) Call Put_line('') Call Put_line('Communication Methods') output = ' (Unique in Field 10):' Do i = 1 To Words(commo_methods) use = Translate(Left(Word(commo_methods,i),maxf10),' ','_') If Length(output) + Length(use) > 78 Then Do Call Put_line(output) output = blanks End Else output = output use End Call Put_line(output) Call Put_line('') Call Put_line('Termination Indicators') output = ' (Unique in Field 11):' Do i = 1 To Words(term_inds) use = Left(Word(term_inds,i),8) If Length(output) + Length(use) > 78 Then Do Call Put_line(output) output = blanks End Else output = output use End Call Put_line(output) Call Put_line('') Call Put_line('') Call Put_line('Total Communicated Data') output = ' (Sum of Field 20):' total_data_kb 'KB' Call Put_line(output) Call Put_line('') Call Put_line('Total Session Duration') output = ' (Sum of Field 21):' total_duration 'seconds' Call Put_line(output) Call Put_line('') Call Put_line('Total Idle Wait') output = ' (Sum of Field 22):' total_idle_wait 'seconds' If total_duration > 0 Then output = output, '('Format(((total_idle_wait / total_duration) * 100),,1)'%)' Call Put_line(output) Call Put_line('') Call Put_line('Total Communication Wait') output = ' (Sum of Field 23):' total_commo_wait 'seconds' If total_duration > 0 Then output = output, '('Format(((total_commo_wait / total_duration) * 100),,1)'%)' Call Put_line(output) Call Put_line('') Call Put_line('Total Media Wait') output = ' (Sum of Field 24):' total_media_wait 'seconds' If total_duration > 0 Then output = output, '('Format(((total_media_wait / total_duration) * 100),,1)'%)' Call Put_line(output) Call Put_line('') rate = Format(total_data_kb / (total_duration - (total_idle_wait + total_commo_wait + total_media_wait)),,1) Call Put_line('Data Transfer Rate :' rate 'KB/S') Call Put_line('') Call Put_line('') output = ' Archive Retrieve Backup Res', || 'tore Total ' Call Put_line(output) output = ' ----------- ----------- ----------- -----', || '------ -------------' Call Put_line(output) output = 'Files :' Right(total_arch_files,11) ' ', Right(total_retr_files,11) ' ' Right(total_bkup_files,11) ' ', Right(total_rest_files,11) ' ' Right(total_files,13) Call Put_line(output) Call Put_line('') output = 'KB Data:' Right(total_arch_kb,11) ' ' Right(total_retr_kb,11), ' ' Right(total_bkup_kb,11) ' ' Right(total_rest_kb,11) ' ', Right(total_kb,13) Call Put_line(output) Return /* */ Makestamp: /* Make a timestamp of the date and time */ /* */ Procedure Parse Arg mo '/' da '/' yr '@' hr ':' mi ':' se mo = Right(mo,2,'*') da = Right(da,2,'*') yr = Right(yr,4,'*') hr = Right(hr,2,'*') mi = Right(mi,2,'*') se = Right(se,2,'*') stamp = yr || mo || da || hr || mi || se Return(stamp) /* */ Get_line: /* Get a line from the input file */ /* */ Procedure Expose os infileid If os = 'C' Then Do 'IOX READ' infileid 'NOC ! * stuff' If rc <> 0 Then stuff = '' End If os = 'D' Then stuff = Read(infileid) If os = 'O' Then stuff = Linein(infileid) Return(stuff) /* */ Put_line: /* Put a line into the output file */ /* */ Procedure Expose os outfileid Parse Arg stuff If stuff \== '1' & stuff \== '0C'x Then stuff = ' 'stuff If os = 'C' Then 'IOX WRITE' outfileid 'NOC ! stuff' If os = 'D' Then ans = Write(outfileid,stuff,eol) If os = 'O' Then ans = Lineout(outfileid,stuff) Return(ans) /* */ Errrtn: /* Get errors to the output file */ /* */ Procedure Expose errflg os outfileid output = ' ' If os = 'C' Then output = '1' If os = 'D' | os = 'O' Then output = '0C'x Call Put_line(output) Call Put_line('') output = Center('E R R O R S',79) Call Put_line(output) Call Put_line('') errflg = 1 Return(0)