%EXTERNALROUTINE padan(%STRING (255) s) %EXTERNALROUTINESPEC prompt %ALIAS "S#PROMPT"(%STRING (255) s) %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 %INTEGER i,j,k,x,crash, st,m1,m2 %OWNINTEGER this day,hours,thours %OWNINTEGER max= 0, fhours, hours up, fday = 2 %REAL mtbf %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 %CYCLE readsymbol(i); %RETURNIF i=10 j = j+1 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 %CYCLE i = 2,1,12; nodays(i) = nodays(i)+nodays(i-1); %REPEAT %UNLESS s->s.("/").t %START printstring("/ Please ") %STOP %FINISH st=0 prompt("None, or details on name:") readstring(padname) printstring("Searching on ".padname." ") define("1,".s); define("2,".t) select input(1) %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 s->("From").t %OR s->("Via").t %OR s->(" PAD").t %OR %C s->("To:").s %OR s->("Msg").t %OR s="" %OR s->("cant").t %THENCONTINUE %UNLESS s->t.(" ").u %THEN t = s %AND 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 %CYCLE; %EXITUNLESS s2->(" ").s2; %REPEAT this day = nodays(j)+stoi(s2) thours = hours hours = this day*24 %IF fhours=0 %start fhours = hours; ! base line %finish {printstring("Hours ="); write(hours,5); space} { printstring(s2)} { space; printstring(t); newline} ->got date %FINISH %REPEAT %MONITOR %FINISH %REPEAT ! should be a pad name %IF max=0 %THEN ->empty %CYCLE i = 1,1,max pad == pada(i) %IF pad_name=t %START; ! got a match ->got name %FINISH %REPEAT empty:max = max+1 %IF max=101 %START %CYCLE j = 1,1,100; write(j,3); printstring(" ".pada(j)_name." ") %REPEAT %STOP %FINISH pad == pada(max); pad_name = t got name: %CYCLE no of res = 1,1,11 %UNLESS u->s2.("|").u %THENEXIT res(no of res) = s2 %REPEAT res(no of res) = u %IF no of res<10 %THEN ->got date; ! not enough info s = res(10); %UNLESS s->s2.(":").t2.(":").t %THEN ->got date %CYCLE; %EXITUNLESS s2->(" ").s2; %REPEAT hours up = stoi(s2) %IF hours-pad_lastt>hours up %START %IF pad_first=0 %THEN pad_first = hours %ELSE %C pad_crash = pad_crash+1 pad_last crash = hours-hours up %if padname = pad_name %start printstring(pad_name); write(hours up,5) printstring(" at ") getdate(pad_last crash) newline %finish %FINISH pad_lastt = hours s = res(4); ! max conns x = constr(s) %IF x>pad_maxu %THEN pad_maxu = x got date: %REPEAT finish: select output(2) printstring("Got "); write(max,1); printstring(" entries") printstring(" Base:"); write(fhours,5) space; getdate(fhours) printstring(" Current:") write(hours,5); space; getdate(hours) printstring(", Total Hours covered ="); write(hours-fhours,5) printstring(" Pad Name No. Crashes MTBF Max Cons Last Crash ") %CYCLE i = 1,1,max pad == pada(i) printstring(pad_name); spaces(15-length(pad_name)) %IF pad_crash=0 %THEN crash = 1 %ELSE crash = pad_crash mtbf = (pad_lastt-pad_first)/(crash) j = pad_lastt-pad_last crash %IF j>mtbf %THEN mtbf = j write(pad_crash,5); spaces(8); print(mtbf,5,0) %IF pad_crash=0 %THEN printstring(" +") %ELSE spaces(2) spaces(8); write(pad_maxu,5) spaces(8); write(pad_last crash,5) space; getdate(pad_lastcrash) write(pad_first, 4); write(pad_lastt, 4) newline %REPEAT %END %endofprogram