1 ! 2! PROGRAM : ACCWEEK.BAS 3! VERSION : 1.0 4! DATE : 29-Mar-1982 5! AUTHOR : A. Frank Hattyar 20 ! Modifications 100 ! Description 900 on error goto 19000 & \ map (account) word a_type, ! record type & string fill = 14%, ! skip some stuff & long a_logout(1%), ! logout time & string a_account = 8%, ! account name of user & a_user = 12%, ! username & long a_cputim, ! job cputime in 10ms units & a_faults, ! number of page faults & a_pagfil, ! peak pgs used in pagefile & a_peak_ws, ! peak working set size & a_bufios, ! number of buffered I/O's & a_dirios, ! number of direct I/O's & fill, ! number of mounts & a_login(1%), ! login time of job & fill, ! PID of process owner & string a_bat_jobnam = 8%, ! batch jobname & fill = 1%, ! count for next field & a_bat_quenam = 15% ! batch que name & ! & ! Map for ACCOUNTNG.DAT file & ! & \ map (account) fill$ = 48%, ! skip non-printer stuff & long a_print_pagcnt, ! number of pages printed & a_print_qiocnt, ! number of QIO's & a_print_getcnt, ! number of gets & string fill = 8% , ! queing time of job & string a_print_jobnam = 8%, ! print job name & fill = 1%, ! count for next field & a_print_quenam = 11% ! print que name & ! & ! Map it again for printer queue specific data & ! & \ map (accweek) string w_user = 12%, ! username for this record & w_account = 8%, ! account name & long w_batch, ! total batch processes & w_inter, ! total interactive processes & w_sub, ! total detached or subprocs & w_print, ! total print jobs & w_login_fail, ! total login failures & w_bat_cputot, ! batch total CPU time & w_bat_cpumax, ! CPU time of longest bat job & w_int_cputot, ! interactive total CPU time & w_int_cpumax, ! CPU time of longest int job & w_bat_elatot, ! batch total elapsed time & w_bat_elamax, ! ela time of longest bat job & w_int_elatot, ! int total elapsed time & w_int_elamax, ! ela time of longest int job & w_bat_fautot, ! batch total page faults & w_bat_faumax, ! most faults in a batch job & w_int_fautot, ! int total page faults & w_int_faumax, ! most faults, int job & w_bat_pgftot, ! batch total page file usage & w_int_pgftot, ! int total page file usage & w_bat_pwsmax, ! max working set of a bat job & w_int_pwsmax, ! max working set of an int job & w_bat_bufios, ! batch total buffered I/O's & w_bat_bufmax, ! most buffered I/O's for a batch job & w_int_bufios, ! interactive total buffered I/O's & w_int_bufmax, ! most buffered I/O's for a inter job & w_bat_dirios, ! batch total direct I/O's & w_bat_dirmax, ! most direct I/O's for any batch job & w_int_dirios, ! interactive total direct I/O's & w_int_dirmax, ! most direct I/O's for any inter job & w_date(1%), ! week-ending date for this summary & word w_group, ! UIC of this user & w_member, & ! the following subscripted data is broken down & ! on a que-by-que basis : & ! & long w_batque_jobtot(9%), ! total number of jobs & w_batque_cputot(9%), ! total cputime & w_batque_cpumax(9%), ! largest job in each queue & w_batque_elatot(9%), ! total ela time in each que & w_batque_elamax(9%), ! longest job in each queue & w_prtque_jobtot(9%), ! tot print jobs in each que & w_prtque_pagcnt(9%), ! total pages printed & w_prtque_pagmax(9%), ! biggest print job & w_print_pagcnt, ! total pgs for all printers & w_print_pagmax, ! biggest job for all printers & w_print_qiocnt, ! total QIO's for all print jobs & w_print_qiomax, ! most QIO's for a print job & w_print_getcnt, ! total gets for all print jobs & w_print_getmax , ! most gets for a print job & string w_bat_maxnam = 8%, ! name of largest batch job & fill = 76% ! expansion room & \ map (accweek) w_buf$ = 576% & ! & ! Map for our output file of weekly summary data & ! & \ map (acctotal) string t_user = 12%, t_account = 8%, long t_batch, & t_inter, t_sub, t_print, t_login_fail, t_bat_cputot, & t_bat_cpumax, t_int_cputot, t_int_cpumax, & t_bat_elatot, t_bat_elamax, t_int_elatot, & t_int_elamax, t_bat_fautot, t_bat_faumax, & t_int_fautot, t_int_faumax, t_bat_pgftot, & t_int_pgftot, t_bat_pwsmax, t_int_pwsmax, & t_bat_bufios, t_bat_bufmax, t_int_bufios, & t_int_bufmax, t_bat_dirios, t_bat_dirmax, & t_int_dirios, t_int_dirmax, t_date(1%), word t_group, & t_member, long t_batque_jobtot(9%), & t_batque_cputot(9%), t_batque_cpumax(9%), & t_batque_elatot(9%), t_batque_elamax(9%), & t_prtque_jobtot(9%), t_prtque_pagcnt(9%), & t_prtque_pagmax(9%), t_print_pagcnt, t_print_pagmax, & t_print_qiocnt, t_print_qiomax, t_print_getcnt, & t_print_getmax, string t_bat_maxnam = 8%, & t_bat_maxuser = 12%, fill = 64% ! username of largest & \ map (acctotal) t_buf$ = 576% ! batch job & ! & ! Map for our output file of weekly total data & ! & \ map (quad) qa0%, qa1%, qb0%, qb1%, qc0%, qc1%, qd0%, qd1%, & qe0%, qe1%, qf0%, qf1% & ! & ! A place for quad arithmetic & ! & \ map (who) fill$ = 1%, who_uic$ = 9%, fill$ = 1%, & who_user$ = 12% & ! & ! Input from file created by "WHO" & ! & 910 dim who$(200%,1%), b_que$(9%), p_que$(9%) & ! & ! Dimension an array for storing the usernames and UIC's, & ! one for batch queue names and their reference numbers, & ! and one for print queue names and their reference numbers. & ! & 920 external integer constant acc$k_battrm, & acc$k_inttrm, & acc$k_prctrm, & acc$k_logtrm, & acc$k_prtjob, & acc$k_insmsg, & ss$_normal & \ external integer function sys$asctim, & sys$bintim, & sys$gettim, & lib$day, & lib$get_input, & utl_day_of_week & ! & ! Define externals for identifying accounting record type & ! and a few functions that'll be used. & ! & 1000 open "s_reports:who.lis" for input as file #1%, map who & \ for i% = 0% to 200% & \ get #1% & \ who$(i%,0%) = who_user$ & \ who$(i%,1%) = who_uic$ & \ next i% & ! & ! Open the WHO listing that must be created before hand and & ! read in the usernames and the UIC's. Someday this will be & ! cleaned up to get the info directly from SYSUAF.DAT. & ! & 1010 who_total% = i% - 1% & \ que_data% = 0% & \ open "s_home:queconfig.dat" for input as file #1% & ! & ! Open the que file that will associate a que name with the & ! number in the output files that will tabulate the number of & ! entries for that queue. & ! & 1020 input line #1%, a$ & \ a$ = edit$(a$,4% + 8% + 16% + 32% + 128%) & \ i% = val%(seg$(a$,3%,3%)) & \ if left$(a$,1%) = "B" & then & b_que$(i%) = edit$(right$(a$,5%),-1%) & \ goto 1020 & else & if left$(a$,1%) = "P" & then & p_que$(i%) = edit$(right$(a$,5%),-1%) & \ goto 1020 & else goto 1020 & ! & ! Get a line from the file, massacre it and put the que name & ! in the correct position in the proper array & ! & 1030 open "s_sort:accweesrt.dat" for input as file #1%, map account, & organization undefined, recordtype any & \ open "s_summary:accweeuse.dat" as file #2%, map accweek, & access append, organization sequential fixed, & recordsize 576% & \ open "s_summary:accweetot.dat" as file #3%, map acctotal, & access append, organization sequential fixed, & recordsize 576% & \ t_buf$, w_buf$ = string$(576%,0%) & \ count%, done% = 0% & \ qa0% = 711573504% ! this is the factor for & \ qa1% = 201% ! subtracting 24 hours & \ get #1% & \ previous_user$ = a_user & \ previous_account$ = a_account & \ sts% = sys$gettim(qd0%) & \ day_of_week$ = string$(0%,3%) & \ sts% = utl_day_of_week(day_of_week$,done%,done%) & \ p% = pos("SATSUNMONTUEWEDTHUFRI", day_of_week$, 1%)/3% + 1% & \ qb0% = p% & \ qb1% = 0% & \ call multquad(qa0%,qb0%,qc0%) & \ call subquad(qd0%,qc0%,qa0%) & \ default_date$ = string$(11%,0%) & \ sts% = sys$asctim(,default_date$,qa0%,) & ! & ! Open our files, both the user-by-user summary and the overall & ! system summary. Figure out today's date and day and set up & ! our defaults to the previous Friday. If today is Friday then & ! we default to last Friday. (Eh ? Robinson Crusoe ?) & ! & 1040 prompt$ = "Week ending (dd-mmm-yyyy) <" + default_date$ + "> : " & \ sts% = lib$get_input(a$,prompt$,) & \ if edit$(a$,-1%) <> "" & then & a$ = edit$(a$, 4% + 8% + 16% + 32% + 128%) & \ a$ = a$ + " 00:00:00.00" & \ sts% = sys$bintim(a$,qa0%) & \ goto 1040 if sts% <> ss$_normal & else & a$ = default_date$ + " 00:00:00.00" & \ sts% = sys$bintim(a$,qa0%) & ! & ! We now prompt for the date and only let them enter & ! month, day and year. The time is place at zero to & ! make it nicer for certain DATATRIEVE operations. & ! & 1050 sts% = lib$day(stop_date%,qa0%) & \ start_date% = stop_date% - 6% & \ stop_time0% = qa0% & \ stop_time1% = qa1% & ! & ! Based on the above information we figure out the start & ! and stop day for our selections. & ! & 1060 prompt$ = "Process" + ht + "1) All records in file (A)" + cr + lf + & ht + ht + "2) Selected in the interval (S)" + ht + & " : " & \ sts% = lib$get_input(a$,prompt$,) & \ a$ = edit$(a$,-1%) & \ if (a$ = "") or (a$ = "A") & then & selections% = 0% & else & if a$ = "S" & then & selections% = -1% & else & goto 1060% & ! & ! We can choose to just process the records that fall in & ! the start day/stop day range or to process all the records & ! in the file and just plug in the date entered as the date & ! in the summary record. This may be helpful in fixing messes & ! like operators accidentally entering the wrong date. & ! & 1070 done%, qd1% = 0% & \ qd0% = 10000000% & ! & ! Set up a few variables and a constant to be used & ! in figuring elapsed time. & ! & 2000 sts% = lib$day(logout_date%, a_logout(0%),) & \ goto 2100 if (logout_date% < start_date%) if selections% & \ goto 2100 if (logout_date% > stop_date%) if selections% & ! & ! Select a record if we are doing selections & ! & \ w_batch = w_batch + 1% if a_type = acc$k_battrm & \ w_inter = w_inter + 1% if a_type = acc$k_inttrm & \ w_sub = w_sub + 1% if a_type = acc$k_prctrm & \ w_print = w_print + 1% if a_type = acc$k_prtjob & \ w_login_fail = w_login_fail + 1% if a_type = acc$k_logtrm & \ goto 2100 if a_type = acc$k_logtrm & \ goto 2040 if a_type = acc$k_prtjob & ! & ! See whether we have a batch, interactive, subprocess, & ! print symbiont or login failure record and bump the & ! appropriate counter, then skip the rest if we have a & ! login failure. We go to the print job section if we have & ! a print job. & ! & \ if a_type <> acc$k_battrm & then & goto 2030 & else & w_bat_cputot = w_bat_cputot + a_cputim & \ if a_cputim > w_bat_cpumax & then & w_bat_cpumax = a_cputim & \ w_bat_maxnam = a_bat_jobnam & ! & ! We get totals and maximums for all the batch stuff. & ! & 2010 w_bat_fautot = w_bat_fautot + a_faults & \ w_bat_faumax = a_faults if a_faults > w_bat_faumax & \ w_bat_pgftot = w_bat_pgftot + a_pagfil & \ w_bat_pwsmax = a_peak_ws if a_peak_ws > w_bat_pwsmax & \ w_bat_bufios = w_bat_bufios + a_bufios & \ w_bat_bufmax = a_bufios if a_bufios > w_bat_bufmax & \ w_bat_dirios = w_bat_dirios + a_dirios & \ w_bat_dirmax = a_dirios if a_dirios > w_bat_dirmax & \ call subquad(a_logout(0%),a_login(0%),qb0%) & \ call divquad(qb0%,qd0%,qa0%) & \ goto 2100 if qa0% < 0% & \ w_bat_elatot = w_bat_elatot + qa0% & \ w_bat_elamax = qa0% if qa0% > w_bat_elamax & \ goto 2100 unless que_data% & \ for i% = 0% to 9% & \ if b_que$(i%) = edit$(a_bat_quenam,-1%) & then & w_batque_jobtot(i%) = w_batque_jobtot(i%) + & 1% & \ w_batque_cputot(i%) = w_batque_cputot(i%) + & a_cputim & \ w_batque_cpumax(i%) = a_cputim & if a_cputim > w_batque_cpumax(i%) & \ w_batque_elatot(i%) = w_batque_elatot(i%) + & qa0% & \ w_batque_elamax(i%) = qa0% & if qa0% > w_batque_elamax(i%) & \ goto 2100 & ! & ! We also do the tabulation for the individual batch & ! queues. The numbers are assigned from QUECONFIG.DAT. & ! & 2020 next i% & \ goto 2100 & 2030 w_int_cputot = w_int_cputot + a_cputim & \ w_int_cpumax = a_cputim if a_cputim > w_int_cpumax & \ w_int_fautot = w_int_fautot + a_faults & \ w_int_faumax = a_faults if a_faults > w_int_faumax & \ w_int_pgftot = w_int_pgftot + a_pagfil & \ w_int_pwsmax = a_peak_ws if a_peak_ws > w_int_pwsmax & \ w_int_bufios = w_int_bufios + a_bufios & \ w_int_bufmax = a_bufios if a_bufios > w_int_bufmax & \ w_int_dirios = w_int_dirios + a_dirios & \ w_int_dirmax = a_dirios if a_dirios > w_int_dirmax & \ call subquad(a_logout(0%),a_login(0%),qb0%) & \ call divquad(qb0%,qd0%,qa0%) & \ goto 2100 if qa0% < 0% & \ w_int_elatot = w_int_elatot + qa0% & \ w_int_elamax = qa0% if qa0% > w_int_elamax & \ goto 2100 & ! & ! Tabulate data for interactive jobs, detached jobs, & ! and subprocesses. & ! & 2040 w_print_pagcnt = w_print_pagcnt + a_print_pagcnt & \ w_print_pagmax = a_print_pagcnt if a_print_pagcnt > w_print_pagmax & \ w_print_qiocnt = w_print_qiocnt + a_print_qiocnt & \ w_print_qiomax = a_print_qiocnt if a_print_qiocnt > w_print_qiomax & \ w_print_getcnt = w_print_getcnt + a_print_getcnt & \ w_print_getmax = a_print_getcnt if a_print_getcnt > w_print_getmax & \ goto 2100 unless que_data% & \ for i% = 0% to 9% & \ if p_que$(i%) = edit$(a_print_quenam,-1%) & then & w_prtque_jobtot(i%) = w_prtque_jobtot(i%) + 1% & \ w_prtque_pagcnt(i%) = w_prtque_pagcnt(i%) + & a_print_pagcnt & \ w_prtque_pagmax(i%) = a_print_pagcnt & if a_print_pagcnt > w_prtque_pagmax(i%) & \ goto 2100 & ! & ! Do data-shuffling now for a print job, including the & ! que-by-que stuff ....... & ! & 2050 next i% & 2100 get #1% & \ if previous_user$ = a_user then goto 2000 & ! & ! Go back for more if we have the same username again & ! & 2110 if (w_batch + w_inter + w_sub + w_print) = 0% & then & previous_user$ = a_user & \ previous_account$ = a_account & \ w_buf$ = string$(576%,0%) & \ goto 2000 unless done% & \ goto 2140 & ! & ! If we only got login failures then the username is not & ! a valid one so we start processing over again for a new one & ! & else & goto 2120 if previous_user$ = who$(i%,0%) & for i% = 0% to 200% & \ goto 2130 & ! & ! ... otherwise we see if we can match the username up with a & ! UIC. If not..... oh well ......... & ! & 2120 w_group = val%(seg$(who$(i%,1%),2%,4%)) & \ w_member = val%(seg$(who$(i%,1%),6%,8%)) & \ who$(i%,0%) = "" & ! & ! Put the UIC in the record if we found it & ! & 2130 w_user = previous_user$ & \ w_account = previous_account$ & \ w_date(0%) = stop_time0% & \ w_date(1%) = stop_time1% & \ put #2% & \ count% = count% + 1% & \ t_batch = t_batch + w_batch & \ t_inter = t_inter + w_inter & \ t_sub = t_sub + w_sub & \ t_print = t_print + w_print & \ t_login_fail = t_login_fail + w_login_fail & \ t_bat_cputot = t_bat_cputot + w_bat_cputot & \ if w_bat_cpumax > t_bat_cpumax & then & t_bat_cpumax = w_bat_cpumax & \ t_bat_maxnam = w_bat_maxnam & \ t_bat_maxuser = previous_user$ & ! & ! Write the rec and update our cumulative system total & ! & 2135 t_int_cputot = t_int_cputot + w_int_cputot & \ t_int_cpumax = w_int_cpumax if w_int_cpumax > t_int_cpumax & \ t_bat_elatot = t_bat_elatot + w_bat_elatot & \ t_bat_elamax = w_bat_elamax if w_bat_elamax > t_bat_elamax & \ t_int_elatot = t_int_elatot + w_int_elatot & \ t_int_elamax = w_int_elamax if w_int_elamax > t_int_elamax & \ t_bat_fautot = t_bat_fautot + w_bat_fautot & \ t_bat_faumax = w_bat_faumax if w_bat_faumax > t_bat_faumax & \ t_int_fautot = t_int_fautot + w_int_fautot & \ t_int_faumax = w_int_faumax if w_int_faumax > t_int_faumax & \ t_bat_pgftot = t_bat_pgftot + w_bat_pgftot & \ t_int_pgftot = t_int_pgftot + w_int_pgftot & \ t_bat_pwsmax = w_bat_pwsmax if w_bat_pwsmax > t_bat_pwsmax & \ t_int_pwsmax = w_int_pwsmax if w_int_pwsmax > t_int_pwsmax & \ t_bat_bufios = t_bat_bufios + w_bat_bufios & \ t_bat_bufmax = w_bat_bufmax if w_bat_bufmax > t_bat_bufmax & \ t_int_bufios = t_int_bufios + w_int_bufios & \ t_int_bufmax = w_int_bufmax if w_int_bufmax > t_int_bufmax & \ t_bat_dirios = t_bat_dirios + w_bat_dirios & \ t_bat_dirmax = w_bat_dirmax if w_bat_dirmax > t_bat_dirmax & \ t_int_dirios = t_int_dirios + w_int_dirios & \ t_int_dirmax = w_int_dirmax if w_int_dirmax > t_int_dirmax & \ for i% = 0% to 9% & \ t_batque_jobtot(i%) = t_batque_jobtot(i%) + & w_batque_jobtot(i%) & \ t_batque_cputot(i%) = t_batque_cputot(i%) + & w_batque_cputot(i%) & \ t_batque_cpumax(i%) = w_batque_cpumax(i%) & if w_batque_cpumax(i%) > t_batque_cpumax(i%) & \ t_batque_elatot(i%) = t_batque_elatot(i%) + & w_batque_elatot(i%) & \ t_batque_elamax(i%) = w_batque_elamax(i%) & if w_batque_elamax(i%) > t_batque_elamax(i%) & \ t_prtque_jobtot(i%) = t_prtque_jobtot(i%) + & w_prtque_jobtot(i%) & \ t_prtque_pagcnt(i%) = t_prtque_pagcnt(i%) + & w_prtque_pagcnt(i%) & \ t_prtque_pagmax(i%) = w_prtque_pagmax(i%) & if w_prtque_pagmax(i%) > t_prtque_pagmax(i%) & \ next i% & \ t_print_pagcnt = t_print_pagcnt + w_print_pagcnt & \ t_print_pagmax = w_print_pagmax if w_print_pagmax > t_print_pagmax & \ t_print_qiocnt = t_print_qiocnt + w_print_qiocnt & \ t_print_qiomax = w_print_qiomax if w_print_qiomax > t_print_qiomax & \ t_print_getcnt = t_print_getcnt + w_print_getcnt & \ t_print_getmax = w_print_getmax if w_print_getmax > t_print_getmax & \ w_buf$ = string$(576%,0%) & \ previous_user$ = a_user & \ previous_account$ = a_account & \ goto 2000 unless done% & ! & ! Lots and lots of totals & ! & 2140 t_user = "VAX 1" & \ t_account = "VAX 1" & \ t_date(0%) = stop_time0% & \ t_date(1%) = stop_time1% & \ t_group = -1% & \ t_member = -1% & \ put #3% & \ print count%; " user records written." & ! & ! Write our totals record out to the total file & ! & \ w_buf$ = string$(576%,0%) & \ w_date(0%) = stop_time0% & \ w_date(1%) = stop_time1% & \ for i% = 0% to who_total% & \ if who$(i%,0%) <> "" & then & w_group = val%(seg$(who$(i%,1%),2%,4%)) & \ w_member = val%(seg$(who$(i%,1%),6%,8%)) & \ w_user = who$(i%,0%) & \ put #2% & ! & ! Write a dummy record for users whose names are in & ! WHO.LIS but who didn't have any activity this week. & ! & 2150 next i% & \ close #1%, #2%, #3% & \ goto 32767 & ! & ! Close up shop and leave & ! & 19000 if err = 11% and erl = 1000% then resume 1010 & else & if err = 55% and erl = 1020% then resume 1020 & else & if err = 5% and erl = 1020% then que_data% = 0% & \ resume 1030 & else & if err = 11% and erl = 1020% then que_data% = -1% & \ resume 1030% & else & if err = 11% and erl = 2100% then done% = -1% & \ resume 2110 & ! & ! A little basic (ugh....) error handling & ! & 19090 print ert$(err); " at line ";erl & \ on error goto 0 & ! & ! The coward's way out .... & ! & 32767 end