%EXTERNALROUTINE telan5 %alias "C#telan5"(%STRING (255) s) %externalstring %fn %spec date %alias "S#date" %externalstringfnspec substring %alias "S#substring" %c (%string (*) %name s, %integer i,j) %EXTERNALROUTINESPEC prompt %ALIAS "S#PROMPT"(%STRING (255) s) %externalroutinespec EMAS3CONNECT %c (%stringname file, %integername mode, hole, prot, conad, %c type, start, end, flag) %ROUTINE define(%STRING (255) s) %EXTERNALROUTINESPEC emas3(%STRINGNAME command,params, %INTEGERNAME flag) %INTEGER flag emas3("DEFINE",s,flag) %END; ! Of %ROUTINE define. %STRING (255) t,u,v,s2,t2,padname,d2,s3,t3, mnth, curr, dst, yrs, mon name %string (5) dmstr %string (255) mn, linename, input file %INTEGER i,j,k,x,crash, st,m1,m2,yr,n, period, char, q %owninteger thisf, lastf, thisrej, lastrej, reload, finh, PAC, GRTYPE %owninteger mode, hole, prot, conad, type, start, end, flag, ptr, sample %OWNINTEGER this day,hours,thours, bars, gbase, stat type %OWNINTEGER max= 0, days, fhours, hours up, fday = 2 %real x1, y1, x2, y2, bsize %REAL mtbf %constinteger no of pacs = 6 %ownintegerarray rav(1:no of pacs) %integerarray tfa,lfa,tha, hra, tra,lra(1:no of pacs) %ownintegerarray gba(1:no of pacs) = 1, 8, 15, 17, 0, 0 %ownintegerarray pktrate(1:no of pacs) = 6, 6, 2, 2, 0, 0 %ownstring (25) %array head(1:4) = "RX Bytes", "TX Bytes", "Rx Pkt", "Tx Pkt" %RECORDFORMAT padf(%STRING (15) name, %INTEGER last crash,crash,lastt, maxu,first,last) %OWNRECORD (padf) %ARRAY pada(1:100) %OWNRECORD (padf) %NAME pad %ownintegerarray dayfigs(1:no of pacs, 0:1000) %STRING (255) %ARRAY res(1:12) %OWNINTEGER no of res %CONSTSTRING (3) %ARRAY day(1:7)= "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" %CONSTSTRING (12) %ARRAY month(1:12)= "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" %OWNINTEGERARRAY nodays(1:12)= 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 %ONEVENT 9 %START ->finish %FINISH %integerfnspec stoi(%string (255) s) %routine readstring(%string (*) %name s) %integer i s = "" %cycle readsymbol(i); %return %if i = nl s = s.tostring(i) %repeat %end %INTEGERFN constr(%STRING (255) s) %INTEGER i,j,n %CYCLE; %EXITUNLESS charno(s,1)=' '; s -> (" ").s; %REPEAT %CYCLE; %EXITUNLESS charno(s,length(s))=' '; length(s) = length(s)-1 %REPEAT %RESULT = stoi(s) %END %integerfn stoi(%string (255) s) %integer i,j,n, sum sum = 0 %if length(s) = 0 %then %result = 0 j=0 %if length(s) >= 10 %then %result = x'7fffffff' %cycle i = 1, 1, length(s) n = charno(s, i)-'0' %if n = 32-'0' %then %continue %if n < 0 %or n > 9 %start %result = sum %finish sum = sum*10+n %repeat %result = sum %end %ROUTINE read line(%STRING (255) %NAME s) %INTEGER i,j s = ""; j = 0; bars = 0 %CYCLE i = byteinteger(ptr); ptr = ptr+1; %if ptr=end+conad %then %signal 9,0 %RETURNIF i=10 %or i=12 j = j+1 bars = bars+1 %if i = '|' s = s.tostring(i) %UNLESS j>130 %REPEAT %END %routine getdate(%integer n) %integer i,j,m,h, d,wkd j = intpt(n/24); ! no of days %cycle m = 1, 1, 12 %if nodays(m) >= j %then %exit %repeat m = m-1; ! went past m = 1 %if m = 0 d = j-nodays(m); ! residual days h = n-(j*24) j = j+fday wkd = j-(intpt(j/7)*7) %if wkd = 0 %then wkd = 7 space; printstring(day(wkd)); write(d, 3) space; printstring(month(m)); space write(h, 2) %end %routine do daily(%integer thisf, %integername lastf, thours) %integer n %real dy %if days # 0 %start %if (thisf-lastf)/days > (pktrate(PAC)+2)*1000000 %start %if input file # "mail.telstatall" %start printstring("TelePAC"); write(PAC, 1) printstring(" Excess?"); print((thisf-lastf)/days, 7, 0) printstring(" on:"); printstring(d2); newline %finish lastf = -(pktrate(PAC)+2)*1000000*days+thisf; ! reload has occured %finish %unless hours <= thours %or fhours > thours %then %start n = thours %while n < hours %cycle x1=gbase; dy=((thisf-lastf)/days) dayfigs(PAC, (n-fhours)//24) = intpt(dy) n = n+24 %repeat %if padname = "M" %start printstring(" Tel"); write(PAC, 1) write(thisf, 4); print((thisf-lastf)/(hours-thours)*24, 6, 0) newline %finish %finish %finish lastf = thisf %end %routine do bar chart(%integer day, fig) %integer n n = day*24 gbase = gba(PAC) y1=(n)/bsize+2; y2 = (n+24*period)/bsize+2 x1=gbase x2 = fig/1000000+gbase printstring("{{box(") print(y1, 4, 2); printsymbol(','); print(x1, 4, 2) printstring(")(") print(y2, 4, 2); printsymbol(','); print(x2, 4, 2) printstring(")}} ") %end %routine do line stats(%string (255) s) %integer i,j,k, pr, dys, PAC %real x %routine do read(%integername n) %integer i,k, mi, hit mi = 0; hit = 0 n = 0 %cycle i = pr, 1, length(s) k = charno(s, i) %if k = '.' %then %continue %if k = '-' %then mi = 1 %and %continue %if k = ' ' %or k = 9 %start %if hit = 0 %then %continue pr = i %if mi = 1 %then n = 0 %return %finish hit = 1 n = n*10+k-'0' %unless n > 10000 %repeat %end pr = 1 ; ! pointer into s do read(i); ! skip the number of calls %cycle PAC = 1, 1, 4 do read(i) days = (hours-tha(1))//24 %if days > 7 %then dys = 1 %else dys = days; ! nasty figs lfa(PAC) = 0; tfa(PAC) = i*6*6*6*dys; ! i is *100, want a daily fig ! currently in 4* scale(should be24) %if PAC > 2 %then tfa(PAC) = tfa(PAC)*4 %if days > 0 %and days < 7 %start sample = sample+1 x = (rav(PAC)-tfa(PAC))/sample rav(pac)=rav(pac)-int pt(x) %finish %repeat %end; {of do line stats} %CYCLE i = 2,1,12; nodays(i) = nodays(i)+nodays(i-1); %REPEAT %cycle i = 1,1,6; tfa(i)=0;lfa(i)=0;tha(i)=0;hra(i)=0;tra(i)=0;lra(i)=0;%repeat curr = date dst = substring(curr, 1, 2) yrs = substring(curr, 7, 8) mn = substring(curr, 4, 5) finh = (nodays(stoi(mn))+stoi(dst)+(stoi(yrs)-86)*365)*24 curr = dst." ".month(stoi(mn))." ".yrs t = s s = "mail.telstatall" st=0 retry mon: prompt("Return, or m for monitoring:") readstring(padname) %if padname = "m" %then padname = "M" %if padname = "M" %then printstring("Monitoring ON ") %if padname = "f" %start prompt("New stats file?"); readstring(s) -> retry mon %finish prompt("Period, Day, Week or Month?"); readstring(u) char = charno(u, 1) %if char = 'd' %then period = 1 %and dmstr = "Day" %c %else %if char = 'w' %then period = 7 %and dmstr = "Week" %c %else %if char = 'm' %then period = 30 %and dmstr = "Month" prompt("Graph type, Global or Line?"); readstring(u) %if charno(u,1)='l' %then grtype = 1 %else grtype = 0 %if grtype = 1 %start prompt("Line name?"); readstring(linename) stat type = 1 s = "mail.telstats" ; {only the current file contains full information} %finish input file = s define("2,".t) select output(2) printstring(" {{label(5,19,.4,0,""TelePACs -") %if grtype=0 %then printstring(" Data Packets/".dmstr.""")}}") %else %c printstring(linename." Data/".dmstr.""")}}") printstring("{{label(12,.3, .2,0,""".dmstr.""")}} {{label(1,12,.25,90,""Packets"")}} {{label(1,.5,.20,0,""1 May 87"")}} {{box(2,1)(23,19)}} ") q = period; {multiplier on scale} %if grtype # 0 %then q = q*4; {bytes rec'd is 4 times pkts} %cycle i = 1, 1, 4 %if grtype # 0 %and i = 3 %then q = q//4 gbase=gba(i) printstring("{{label(23.50,") print(gbase+0.5, 1, 1) %if grtype = 0 %start printstring(",.20,0,""TelePAC"); write(i, 1); printstring(""")}}") %else printstring(",.20,0,""".head(i).""")}}") %finish %cycle j = 1, 1, pktrate(i) printstring(" {{label(.70,") print(gbase+(j*5)/5, 1, 1) printstring(",.2,0,"""); write(j*q,0); printstring("m"")}} ") printstring(" {{box(2,1)(23,") print(gbase+(j*5)/5,1,1); printstring(")}} ") %repeat %repeat select output(0) read next file: emas3connect(input file,mode,hole,prot,conad,type,start,end,flag) ptr = conad+start %CYCLE readline(s) %if s = "" %then %exit %IF charno(s,1)='(' %THENEXIT %REPEAT %CYCLE readline(s) %if s="" %then %continue char = charno(s, 1) %IF char='(' %OR char ='_' %THENCONTINUE %if char = ' ' %start %if grtype = 0 %and s->t.("Data frames in/ ").t %then -> an frames %if s->t.("Rejects/ ").t %then -> count rejects %finish %if grtype # 0 %and s->t.(linename).u %then do line stats(u) %and %c %continue %if charno(s, 1) = 't' %or charno(s, 1) = 'T' %start %if s->t.("telepac").u %start PAC = charno(u, 1) - '0' %if PAC = 15 %then PAC = 5; ! horrible special '?' ************ %finish %else %start %unless s->t.("TelePAC").u %then %continue PAC = 1; ! old style prompt %finish s = u %unless s->s.(" between ").t.(" ").u %then %continue %unless u->s.(" and ").t.(" ").u %then %continue d2 = u %CYCLE i = 1,1,7 %IF t=day(i) %START; ! got a date etc %UNLESS u->t.(" ").s %THENMONITOR %CYCLE j = 1,1,12 %IF t=month(j) %START; ! got a month %CYCLE; %EXITUNLESS charno(s,1)=' '; s -> (" ").s %REPEAT %UNLESS s->s2.(" ").t2 %THENMONITOR ! s2 is the day of the month ! t2 is 05:00:04 1996 %CYCLE; %EXITUNLESS s2->(" ").s2; %REPEAT this day = nodays(j)+stoi(s2) %unless t2 -> s3.(" ").t3 %then %monitor yr = stoi(t3)-1986 thours = hra(PAC) hours = this day*24+yr*365*24 mnth = t %IF fhours=0 %start fhours = hours; ! base line bsize = (finh-fhours)/21; ! make pict 21+2 cm long %finish %if padname = "M" %start printstring(s2) space; printstring(t) %finish %if thours < tha(PAC) %start printstring("TelePAC "); write(PAC, 1) printstring(" Invalid Record Sequence at "); printstring(d2); newline %finish tha(PAC) = thours; hra(PAC) = hours ->got date %FINISH %REPEAT %FINISH %REPEAT %finish %continue count rejects: ! watch for reloads thisrej = stoi(t) %if thisrej < lra(PAC) %and lra(PAC) < x'70000000' %start {overflow in 32 bits} %if input file # "mail.telstatall" %start printstring("TelePAC "); write(PAC, 1) printstring(" Reload by ".d2); write(thisrej, 5); write(lra(pac), 5); newline %finish lfa(PAC) = 0 %finish lra(PAC) = thisrej -> now do daily; ! reload (or not) detected, so output figs an frames: ! temp stuff - just data frames in (in t) %continue %unless t -> t.(" ").u lastf = lfa(PAC) thisf = stoi(t) %if lastf > thisf %then lastf = lastf-16777216 days = (hours-tha(PAC))//24 lfa(PAC) = lastf; tfa(PAC) = thisf %continue; ! wait till rejects examined now do daily: thisf = tfa(PAC); lastf = lfa(PAC); thours = tha(PAC) gbase = gba(PAC) do daily(thisf, lastf, thours) lfa(PAC) = lastf got date: %REPEAT finish: %if input file = "mail.telstatall" %then %c input file = "mail.telstats" %and -> read next file n = (hours-fhours)//24 printstring("No of days was"); write(n, 1) newline %if grtype = 1 %then n = n-1; {don't know why!} select output(2) %if period = 1 %then %start %cycle i = 0, 1, n %cycle PAC = 1, 1, 4 do bar chart(i, dayfigs(PAC, i)) %repeat %repeat %else i=0 %cycle %cycle PAC = 1, 1, 4 x = 0 %cycle j = 0, 1, period-1 x = x+dayfigs(PAC, j+i) %repeat do bar chart(i, x//period) %repeat i = i+period %exit %if i+period > n %repeat %finish printstring(" {{label(22,.5,.25,0,""".curr.""")}} ") select output(0) %if grtype # 0 %start printstring(" For: ".linename." TelePAC ".head(stat type)."/Day ") %cycle i = 1, 1, 3 write(i, 2); spaces (8); write(rav(i)*4, 6); newline %repeat %finish printstring(" Base:"); write(fhours,5) space; getdate(fhours) printstring(" Current:") write(hours,5); space; getdate(hours) printstring(", Total Hours covered ="); write(hours-fhours,5) %END %endofprogram