Skip to content

Commit e25ce5d

Browse files
committed
fix timing metrics data
1 parent 546cdf3 commit e25ce5d

2 files changed

Lines changed: 31 additions & 69 deletions

File tree

archive/analysis/getLogData.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ echo "<a href=https://github.com/markmac99/ukmon-pitools/wiki/Trajectory-Solver-
7272
echo "<pre>" >> $logfile
7373
cat $DATADIR/failed/${rundate}_failed.txt >> $logfile
7474
echo "</pre>" >> $logfile
75+
7576
echo "<h2 id=graph>Chart of Batch Element Runtimes</h2>" >> $logfile
7677
echo "<p>This section shows the runtime of the different jobs in the batch</p>" >> $logfile
7778
echo "<p><a href=/reports/batchcharts/$rundate-perfNightly.jpg><img src=/reports/batchcharts/$rundate-perfNightly.jpg width=300\%></a></p>" >> $logfile
@@ -93,4 +94,7 @@ done
9394
cat $TEMPLATES/footer.html >> $DATADIR/lastlogs/index.html
9495
aws s3 cp $DATADIR/lastlogs/index.html $WEBSITEBUCKET/reports/lastlogs/ --quiet
9596

97+
# housekeep the fails reports
98+
find $DATADIR/failed -mtime +90 -exec rm -f {} \;
99+
96100
find $DATADIR/lastlogs -name "lastlog*" -mtime +90 -exec rm -f {} \;

archive/ukmon_pylib/metrics/timingMetrics.py

Lines changed: 27 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
def graphOfData(logf, dtstr):
15+
1516
lis = open(logf,'r').readlines()
1617
dta = [li for li in lis if li[:8]==dtstr]
1718

@@ -55,78 +56,35 @@ def graphOfData(logf, dtstr):
5556

5657

5758
def getLogStats(nightlogf, matchlogf, thisdy):
58-
with open(nightlogf,'r') as inf:
59-
loglines = inf.readlines()
60-
61-
#logf = os.path.basename(nightlogf)
62-
#spls = logf.split('-')
63-
#thisdy= spls[1]
64-
matchstr = 'RUNTIME'
65-
66-
# <13>Nov 1 11:49:55 nightlyJob: RUNTIME 10554 showerReport ALL 202211
67-
startFAM = 0
68-
startRD = 0
69-
dts = []
70-
tss = []
71-
tsks = []
72-
secs = []
73-
msgs = []
74-
for li in loglines:
75-
if matchstr in li:
76-
li = ' '.join(li.split()) # remove double-spaces eg when date is ' 6 Jan' as opposed to '16 Jan'
77-
spls = li.split()
78-
msg = ''
79-
for s in range(6, len(spls)):
80-
msg = msg + ' ' + spls[s]
81-
if 'start findAllMatches' in msg:
82-
startFAM = int(spls[5])
83-
dts.append(thisdy)
84-
tss.append(spls[2])
85-
tsks.append(spls[3].replace(':',''))
86-
secs.append(int(spls[5]))
87-
msgs.append(msg.strip())
88-
89-
with open(matchlogf,'r') as inf:
90-
loglines = inf.readlines()
59+
# logline example
60+
# <13>May 8 06:10:02 nightlyJob: start nightlyJob
61+
outdir = os.path.split(nightlogf)[0]
9162

92-
# scan for findAllMatches data first
93-
for li in loglines:
94-
if matchstr in li:
95-
spls = li.split()
96-
if 'runDistrib' in spls[3]:
97-
continue
98-
msg = ''
99-
for s in range(6, len(spls)):
100-
msg = msg + ' ' + spls[s]
101-
if 'start runDistrib' in msg:
102-
startRD = int(spls[5])
103-
dts.append(thisdy)
104-
tss.append(spls[2])
105-
tsks.append(spls[3].replace(':',''))
106-
secs.append(int(spls[5])+startFAM)
107-
msgs.append(msg.strip())
63+
loglines = open(nightlogf,'r').readlines()
64+
bsfs = [x for x in loglines if 'start'in x or 'finish' in x or 'end' in x]
65+
bsfs = [x for x in bsfs if x[0]=='<']
10866

109-
# rescan for runDistrib data
110-
for li in loglines:
111-
if matchstr in li:
112-
spls = li.split()
113-
if 'runDistrib' not in spls[3]:
114-
continue
115-
msg = ''
116-
for s in range(6, len(spls)):
117-
msg = msg + ' ' + spls[s]
118-
dts.append(thisdy)
119-
tss.append(spls[2])
120-
tsks.append(spls[3].replace(':',''))
121-
secs.append(int(spls[5]) + startFAM + startRD)
122-
msgs.append(msg.strip())
67+
loglines = open(matchlogf,'r').readlines()
68+
msfs = [x for x in loglines if 'start'in x or 'finish' in x or 'end' in x]
69+
msfs = [x for x in msfs if x[0]=='<']
12370

124-
df = pd.DataFrame(zip(dts,tss,secs,tsks,msgs), columns=['dts','tss','secs','tsk','msgs'])
125-
df = df.sort_values(by=['tss'])
126-
#print(df)
127-
outdir = os.path.split(nightlogf)[0]
128-
df.to_csv(os.path.join(outdir, 'perfNightly.csv'), mode='a', header=False, index=False)
129-
71+
alldata = msfs + bsfs
72+
alldata.sort()
73+
starttime = None
74+
yr = datetime.datetime.now().year
75+
with open(os.path.join(outdir, 'perfNightly1.csv'), 'a+') as outf:
76+
for rw in alldata:
77+
dtpart = rw[4:19]
78+
evtdt = datetime.datetime.strptime(f'{yr} {dtpart}', '%Y %b %d %H:%M:%S')
79+
if 'start nightlyJob' in rw:
80+
starttime = evtdt
81+
elapsed_secs = (evtdt - starttime).seconds
82+
txtpart = rw[20:]
83+
task = txtpart[:txtpart.find(':')]
84+
msg = txtpart[txtpart.find(':')+1:].replace(',', ' ')
85+
outstr = f'{evtdt.strftime("%Y%m%d,%H:%M:%S")},{elapsed_secs},{task},{msg}\n'
86+
outf.write(outstr)
87+
13088

13189
if __name__ == '__main__':
13290
dtstr = sys.argv[1]

0 commit comments

Comments
 (0)