%EXTERNALROUTINE telan4 %alias "C#telan4"(%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 (255) mn, linename %INTEGER i,j,k,x,crash, st,m1,m2,yr %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 %ownintegerarray rav(1:4) %integerarray tfa,lfa,tha, hra, tra,lra(1:4) %ownintegerarray gba(1:4) = 1, 10, 20, 22 %ownintegerarray pktrate(1:4) = 5, 5, 1, 2 %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 %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 %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 bar(%integer thisf, %integername lastf, thours) %integer n %if days # 0 %start %if (thisf-lastf)/days > 6000000 %start printstring("Funny"); print((thisf-lastf)/days, 7, 0) printstring(" on:"); printstring(d2); newline lastf = -5000000*days+thisf; ! reload has occured %finish %unless hours <= thours %or fhours > thours %then %start select output(2) n = thours %while n < hours %cycle y1=(n-fhours)/bsize+2; y2 = (n+24-fhours)/bsize+2 x1=gbase; x2=((thisf-lastf)/days)/600000+gbase printstring("{{box(") print(y1, 4, 2); printsymbol(','); print(x1, 4, 2) printstring(")(") print(y2, 4, 2); printsymbol(','); print(x2, 4, 2) printstring(")}} ") n = n+24 %repeat select output(0) %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 line stats(%string (255) s) %integer i,j,k, pr, dys %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) %for k = 1, 1, stat type; ! skip the number of calls do read(i) select output(0); write(i, 4); newline days = (hours-tha(PAC))//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 stat type > 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 %end %CYCLE i = 2,1,12; nodays(i) = nodays(i)+nodays(i-1); %REPEAT %cycle i = 1,1,4; 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.telstats" 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("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) prompt("RX Bytes, Tx Bytes, RX Pkt or TX PKT (1 to 4)?") readstring(u); stat type = charno(u, 1)-'0' %if stat type < 0 %or stat type > 4 %then stat type = 1 %finish define("2,".t) emas3connect(s,mode,hole,prot,conad,type,start,end,flag) ptr = conad+start select output(2) printstring(" {{label(5,27,.5,0,""TelePACs -") %if grtype=0 %then printstring(" Data Packets/Day"")}}") %else %c printstring(linename." Data Bytes/Day"")}}") printstring("{{label(15,.3, .3,0,""Day"")}} {{label(1,12,.3,90,""Packets"")}} {{label(1,.5,.25,0,""Apr 87"")}} {{box(2,1)(30,28)}} ") %cycle i = 1, 1, 4 gbase=gba(i) printstring("{{label(30.70,") print(gbase+1, 1, 1) printstring(",.25,0,""TelePAC"); write(i, 1); printstring(""")}}") %cycle j = 1, 1, pktrate(i) printstring(" {{label(.70,") print(gbase+(j*5)/3, 1, 1) printstring(",.25,0,"""); write(j,0); printstring("m"")}} ") printstring(" {{box(2,1)(30,") print(gbase+(j*5)/3,1,1); printstring(")}} ") %repeat %repeat select output(0) %CYCLE readline(s) %if s = "" %then %exit %IF charno(s,1)='(' %THENEXIT %REPEAT %CYCLE readline(s) %if s="" %then %continue %IF charno(s,1)='(' %OR charno(s,1)='_' %THENCONTINUE %if grtype = 0 %and s->t.("Data frames in/ ").t %then -> an frames %if s->t.("Rejects/ ").t %then -> count rejects %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' %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)/28; ! make pict 28+2 cm long %finish %if padname = "M" %start printstring(s2) space; printstring(t) %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) %start printstring("TelePAC "); write(PAC, 1) printstring(" Reload by ".d2." ") lfa(PAC) = 0 %finish lra(PAC) = thisrej -> now do bar; ! 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 bar: thisf = tfa(PAC); lastf = lfa(PAC); thours = tha(PAC) gbase = gba(PAC) do bar(thisf, lastf, thours) lfa(PAC) = lastf got date: %REPEAT finish: i = hours-thours; %if i = 0 %then i = 1 printstring("Last Pkt rate was ") write(thisf, 4); print((thisf-lastf)/i*24, 6, 0) newline select output(2) printstring(" {{label(27,.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