%EXTERNALROUTINE padan %alias "c#padan"(%STRING (255) s) {version for NEW pad stats} %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 %INTEGER i,j,k,x,crash, st,m1,m2,m,hit,low,high, final, q,cou del, yr, ii, kk, z, fr ho up, dayofmonth %owninteger mode, hole, prot, conad, type, start, end, flag, ptr %owninteger ignorelunch %OWNINTEGER this day,hours,thours, bars, trig hours %OWNINTEGER max= 0, fhours, hours up, fday = 5, poll h, pollday %REAL mtbf %constinteger special = 13 %ownstring (11) %array fromname(1:special) = "ATBPD1", "CSTPD1", "CSTPD2", "ENGPD1", "FCNRPD", "HFROPD1", "HFROPD2", "HFRPD1", "LIBPD1", "LIBPD2", "POLPAD", "POLPD2", "SIAEPD" %ownstring (11) %array toname(1:special) = "ATBPAD1", "CSTPAD1", "CSTPAD2", "ENGPAD1", "FCNRPAD1", "HFROPAD1", "HFROPAD2", "HFROPAD1", "LIBPAD1", "LIBPAD2", "POLPAD1", "POLPAD2", "SIAEPAD" %ownintegerarray mcr(1:52) %ownintegerarray mpads(1:52) %constinteger max crash = 100 %RECORDFORMAT padf(%STRING (15) name, %INTEGER last crash,crash,lastt, maxu,first,last, last hours up, %integerarray crasha(0:max crash)) %OWNRECORD (padf) %ARRAY pada(1:150) %ownintegerarray order(1:150) %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 extract item(%string(*) %name s, t) %integer i, j, k %string (255) u t = "" %return %if s = "" %cycle i = 1, 1, length(s) %exit %if charno(s, i) # ' ' %repeat %return %if i = length(s) %if i > 0 %start charno(s, i-1) = length(s)-i+1 u = string(addr(s)+i-1); s = u %finish %unless s -> t.(" ").s %then t = "" %end %routine do order %integer i,j,k,hit order(i) = i %for i = 1, 1, 150 %cycle i = max-1, -1, 1 hit = 0 %cycle j = 1, 1, i %if pada(order(j))_name > pada(order(j+1))_name %start hit = 1 k = order(j); order(j) = order(j+1); order(j+1) = k %finish %repeat %exit %if hit = 0 %repeat %end %ROUTINE read line(%STRING (255) %NAME s) %INTEGER i,j %byteintegerarray a(0:150) s = ""; j = 0; bars = 0 %CYCLE i = byteinteger(ptr); ptr = ptr+1; %if ptr=end+conad %then %signal 9,0 %exitIF i=10 j = j+1 bars = bars+1 %if i = '|' a(j) = i %UNLESS j>130 %REPEAT %if j > 130 %then j = 130 a(0) = j s = string(addr(a(0))) %END %routine getdate(%integer n) %integer i,j,m,h, d,wkd, lfday lfday = fday %cycle %exit %if n <= 365*24 n = n-365*24 lfday = lfday+1 %repeat ! n = n+6; {Poll is at 6am} j = intpt(n/24); ! no of days %cycle m = 1, 1, 12 %if nodays(m) >= j %then %exit %repeat m = m-1 %unless nodays(12) < j; ! went past m = 1 %if m = 0 d = j-nodays(m); ! residual days h = n-(j*24) j = j+lfday 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); printstring(" hours ") %end %routine print crash line(%integer n) { printstring(pad_name); write(hours, 4); write(trig hours, 4); newline} %if padname = pad_name %or hours > trig hours %start select output(2) printstring(pad_name); spaces(10-length(pad_name)) printstring(" Crash at ") getdate(hours-hours up) printstring("Had been up "); write(pad_last hours up, 4) %if n = 1 %then printstring(" * Lunchtime") %if n = 2 %then printstring(" * Poller program") %if n = 3 %then printstring(" * W/E switch off") newline select output(0) %finish %end %CYCLE i = 2,1,12; nodays(i) = nodays(i)+nodays(i-1); %REPEAT t = s; ! presume parameter %if t="" %then t = ".lp23" s = "ERCM09:mail.padstats" res(i) = "" %for i = 1, 1, 10 st=0 prompt("All crashes on Pad (or return), name:") readstring(padname) prompt("Count 5am restarts?"); readstring(s2) %if s2 = "" %then s2 = "n" %if charno(s2, 1) = 'y' %then cou del = 0 %else cou del = 1 prompt("Count 1pm-2pm?"); readstring(s2) %if s2 = "" %then s2 = "n" %if charno(s2,1) = 'y' %then ignorelunch = 0 %else ignorelunch = 1 again: printstring("Print ALL crashes after dd mm yy (or return) ") prompt("dd mm yy?") readstring(s2) trig hours = 999999 %if s2 # "" %start %unless s2 -> s2.(" ").t2.(" ").u %start printstring("dd mm yy please ") -> again %finish trig hours = (stoi(u)-88)*365*24+(nodays(stoi(t2))+stoi(s2))*24 ! ********************** ! horrible frig to handle year ! ***************************** %finish %if padname # "" %then %c printstring("Searching on ".padname." ") define("2,".t) emas3connect(s,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 %if length(s) < 18 %then %continue %if charno(s, 5) = ':' %and charno(s, 4)='e' %then -> go for date { %if charno(s, 1) = ' ' %and s -> t.(" ").s %then i = 1; ! 2 sp at start} { %UNLESS s->t.(" ").u %then t = s %and u = ""} { %if t -> t.("|").v %then u = "|".v.u} { %if bars < 5 %then %continue %else -> get pad name} %if charno(s, 1) = ' ' %or charno(s, 1) = '*' %then -> get pad name %continue go for date: s -> t.(":").s %if pad name = "dates" %start printstring(s); space %finish extract item(s, t); {get day of month} { printstring(t); space} dayofmonth = stoi(t) extract item(s, t); {get month} %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} extract item(s, s2); {the year!} extract item(s, s2); {hh:mm:ss} this day = nodays(j)+dayofmonth %unless s2 -> s2.(":").t2 %then pollh = 0 %else %c pollh = stoi(s2) thours = hours hours = this day*24+pollh %if hours > thours+1000 %and thours > 0 %then %monitor {poll day = i} {for w/e switchoffs - need DAY of WEEK} poll day = 0 {temporary !!} %IF fhours=0 %start fhours = hours; ! base line %finish %if hours < fhours %then hours = hours+365*24 %if pad name = "dates" %start printstring("Hours ="); write(hours,5); space printstring(s2) space; printstring(t); getdate(hours); newline %finish ->got date %FINISH %REPEAT %MONITOR ! should be a pad name get pad name: charno(s, 1) = length(s)-1; t = string(addr(s)+1); s = t { s = fromstring(s, 1, length(s)-1);} {remove space or *} %unless s -> t.(" ").s %then t = "" %if length(t) > 10 %or t = "" %then %continue; {invalid formats} %if charno(t, 1) = ' ' %then %continue {all spaces entry} %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 = 151 %START %CYCLE j = 1,1,150; write(j,3); printstring(" ".pada(j)_name." ") %REPEAT %STOP %FINISH pad == pada(max); pad_name = t got name: %unless s -> s2.(":").s %then s2 = "" %if s2 = "" %then %continue %CYCLE; %EXITUNLESS s2->(" ").s2; %REPEAT hours up = stoi(s2) %IF hours-pad_lastt-1>hours up %start {allow for slow clock} z = hours up//24; fr ho up = hours up-z*24 %if cou del # 0 %and (hours up = 0 %or hours up = 23) %then %c print crash line(2) %and -> out %if ignorelunch # 0 %and fr ho up-pollh = 10 %then %c print crash line(1) %and -> out %if poll day = 2 %and hours-pad_lastt >= 72 %c %and 15 <= (hours up-pollh) <= 17 %start {Weekend switch-off} %if padname = pad_name %or hours > trig hours %then %c print crash line(3) -> out %finish %IF pad_first=0 %THEN pad_first = hours-hours up %ELSE %C pad_crash = pad_crash+1 %if pad_crash > max crash %start printstring("TOO many Restarts, increase MAX CRASH ") %stop %finish pad_crasha(pad_crash) = hours-hours up pad_last crash = hours-hours up print crash line(0) %FINISH { %if padname = pad_name %start} { printstring(padname); space; write(hours up, 3); newline} { %finish} out: pad_lastt = hours pad_last hours up = hours up s = res(5); ! max conns %if s = "" %then x = 0 %else x = constr(s) %if x > 200 %then x = 0; ! goes to 63555 %IF x>pad_maxu %THEN pad_maxu = x got date: %REPEAT finish: x = fhours %cycle k = 1, 1, 1000 %if x+720 > hours %then %exit x = x+720 %repeat final = x-720*3; %if final < fhours %then final = fhours select output(2) newpage 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(" Number of Current Max Pad Name Restarts MTBF Hours-Up Cons Last Crash Last Contact ") do order; ! put names in alphabetical order %CYCLE ii = 1,1,max i = order(ii) pad == pada(i) {%continue %if pad_first=0} 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 %and pad_crash=0 %THEN mtbf = j write(pad_crash,4); spaces(3); print(mtbf,4,0) %IF pad_crash=0 %THEN printstring(" +") %ELSE spaces(2) write(pad_last hours up, 4); write(pad_maxu,5) spaces(5) space; getdate(pad_lastcrash) space; getdate(pad_lastt) newline %REPEAT newpage printstring("Rolling 3 month averages") %if cou del = 0 %then printstring(" - 5am restarts included") %else %c printstring(" - 5am restarts not included") %if ignorelunch # 0 %then printstring(" - s/w slot ignored") printstring(" Final period for 3 month MTBF:") write(final, 4); getdate(final) printstring(" to ") write(x, 4); getdate(x) printstring(" centre month Nov Dec Jan Feb Mar Apr May Jun ") %CYCLE ii = 1,1,max i = order(ii) pad == pada(i) %continue %if pad_first = 0 printstring(pad_name); spaces(15-length(pad_name)) q = 0 %cycle k = fhours, 720, final low = k; high = k+720*3 q = q+1 hit = 0 %if pad_crash # 0 %start %cycle m = 1, 1, pad_crash %if pad_crasha(m) > high %then %exit; ! past the window %if pad_crasha(m) >= low %then hit = hit+1; ! in the window %repeat %finish %if hit = 0 %start %if high < pad_first %or low > pad_lastt %then spaces(6) %else %c printstring(" >2160") %and mpads(q) = mpads(q)+1 %finish %else %start write(2160//hit, 5) mcr(q) = mcr(q)+hit; mpads(q) = mpads(q)+1 %finish %repeat newline %repeat printstring(" Totals ") %cycle k = 1, 1, (final-fhours)//720+1 %if mcr(k) = 0 %then printstring(" ") %else %c write(mpads(k)*2160//mcr(K), 5) %repeat newpage printstring("Number of PAD-Crash Days per Rolling 3 months") %if cou del = 0 %then printstring(" - 5am restarts included") %else %c printstring(" - 5am restarts not included") %if ignorelunch # 0 %then printstring(" - s/w slot ignored") printstring(" Final period for 3 month MTBF:") write(final, 4); getdate(final) printstring(" to ") write(x, 4); getdate(x) printstring(" centre month Nov Dec Jan Feb Mar Apr May Jun ") %CYCLE ii = 1,1,max i = order(ii) pad == pada(i) %continue %if pad_first = 0 printstring(pad_name); spaces(15-length(pad_name)) q = 0 %cycle k = fhours, 720, final low = k; high = k+720*3 q = q+1 hit = 0 %if pad_crash # 0 %start %cycle m = 1, 1, pad_crash %if pad_crasha(m) > high %then %exit; ! past the window %if pad_crasha(m) >= low %then hit = hit+1; ! in the window %repeat %finish %if hit = 0 %start %if high < pad_first %or low > pad_lastt %then spaces(6) %else %c printstring(" 0") %and mpads(q) = mpads(q)+1 %finish %else %start write(hit, 5) mcr(q) = mcr(q)+hit; mpads(q) = mpads(q)+1 %finish %repeat newline %repeat printstring(" Totals ") %cycle k = 1, 1, (final-fhours)//720+1 %if mcr(k) = 0 %then printstring(" ") %else %c write(mcr(K)//mpads(k), 5) %repeat newline newpage printstring("Number of Restarts per month, or until current date ") %cycle i = 1, 1, 12 %if nodays(i)*24 > fhours %then %exit %repeat x = i-1 yr = 0 %cycle low = nodays(x)*24+yr; high = low+61*12 {30.5*24} %if low > hours %then %exit; ! all finished hit = 0 %cycle ii = 1, 1, max i = order(ii) pad == pada(i) %if pad_crash > 0 %start %cycle j = 1, 1, pad_crash %if pad_crasha(j) > high %then %exit; ! finished pad %if pad_crasha(j) >= low %then hit = hit+1 %repeat %finish %repeat printstring(month(x)); write(hit, 5) spaces(10); print(hit*7/30.5,3,0); newline x = x+1 %if x = 13 %then x = 1 %and yr = yr+365*24 %repeat newlines(5) printstring("Number of Restarts per week, or until current date Week No Week Commencing:- ") x = fhours//(7*24); x = x*24*7+72 yr = 0; k = 1 %cycle low = x; high = low+7*24 %if low > hours %then %exit; ! all finished hit = 0 %cycle ii = 1, 1, max i = order(ii) pad == pada(i) %if pad_crash > 0 %start %cycle j = 1, 1, pad_crash %if pad_crasha(j) > high %then %exit; ! finished pad %if pad_crasha(j) >= low %then hit = hit+1 %repeat %finish %repeat write(k, 3); spaces(4); getdate(x); write(hit, 5); newline k = k+1 x = x+24*7 %repeat newpage newpage newline printstring("Number of Restarts per week") %if cou del = 0 %then printstring(" - 5am restarts included") %else %c printstring(" - 5am restarts not included") %if ignorelunch # 0 %then printstring(" - s/w slot ignored") printstring(" ") mcr(i) = 0 %for i = 1, 1, 50 printstring("Week ") %cycle i = 1, 1, 40 write(i, 2) %repeat newline %CYCLE ii = 1, 1, max i = order(ii) x = fhours//(7*24); x = x*24*7-48 yr = 0; k = 1 pad == pada(i) %continue %if pad_first = 0 printstring(pad_name); spaces(10-length(pad_name)) q = 0 %cycle low = x; high = low+7*24 %if low > hours %then %exit; ! all finished hit = 0 q = q+1 hit = 0 %if pad_crash = 0 %start printstring("No Restarts") %exit %finish %cycle m = 1, 1, pad_crash %if pad_crasha(m) > high %then %exit; ! past the window %if pad_crasha(m) >= low %then hit = hit+1; ! in the window %repeat %if pad_crasha(1)>high %or pad_lastt < low %c %then spaces(3) %else write(hit, 2) mcr(q) = mcr(q)+hit; mpads(q) = mpads(q)+1 k = k+1 x = x+24*7 %repeat newline %repeat printstring(" Totals ") x = fhours//(7*24); x = x*24*7-24 yr = 0; k = 1 %cycle low = x; high = low+7*24 %if low > hours %then %exit; ! all finished %if mcr(k) = 0 %then printstring(" ") %else %c write(mcr(k), 2) k = k+1 x = x+24*7 %repeat newline newpage %END %endofprogram