forked from ManageIQ/integration_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperf_message_stats.py
1113 lines (973 loc) · 49.6 KB
/
perf_message_stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*
"""Functions for performance analysis/charting of the backend messages and top_output from an
appliance.
"""
from utils.log import logger
from utils.path import log_path
from utils.perf import convert_top_mem_to_mib
from utils.perf import generate_statistics
from datetime import datetime
import dateutil.parser as du_parser
from datetime import timedelta
from time import time
import csv
import numpy
import os
import pygal
import subprocess
import re
# Regular Expressions to capture relevant information from each log line:
# [----] I, [2014-03-04T08:11:14.320377 #3450:b15814] INFO -- : ....
log_stamp = re.compile(r'\[----\]\s[IWE],\s\[([0-9\-]+)T([0-9\:\.]+)\s#([0-9]+):[0-9a-z]+\]')
# [----] .* MIQ( * )
miqmsg = re.compile(r'\[----\].*MIQ\(([a-zA-Z0-9\._]*)\)')
# Command: [ * ]
miqmsg_cmd = re.compile(r'Command:\s\[([a-zA-Z0-9\._\:]*)\]')
# Message id: [ * ]
miqmsg_id = re.compile(r'Message\sid:\s\[([0-9]*)\]')
# Args: [ *]
miqmsg_args = re.compile(
r'Args:\s\[([A-Za-z0-9\{\}\(\)\[\]\s\\\-\:\"\'\,\=\<\>\_\/\.\@\?\%\&\#]*)\]')
# Dequeued in: [ * ] seconds
miqmsg_deq = re.compile(r'Dequeued\sin:\s\[([0-9\.]*)\]\sseconds')
# Delivered in [ * ] seconds
miqmsg_del = re.compile(r'Delivered\sin\s\[([0-9\.]*)\]\sseconds')
# Worker related regular expressions:
# MIQ(PriorityWorker) ID [15], PID [6461]
miqwkr = re.compile(r'MIQ\(([A-Za-z]*)\)\sID\s\[([0-9]*)\],\sPID\s\[([0-9]*)\]')
# with ID: [21]
miqwkr_id = re.compile(r'with\sID:\s\[([0-9]*)\]')
# For use with workers exiting, such as authentication failures:
miqwkr_id_2 = re.compile(r'ID\s\[([0-9]*)\]')
# top regular expressions
# Cpu(s): 13.7%us, 1.2%sy, 2.1%ni, 80.0%id, 1.7%wa, 0.0%hi, 0.1%si, 1.3%st
miq_cpu = re.compile(r'Cpu\(s\)\:\s+([0-9\.]*)%us,\s+([0-9\.]*)%sy,\s+([0-9\.]*)%ni,\s+'
r'([0-9\.]*)%id,\s+([0-9\.]*)%wa,\s+([0-9\.]*)%hi,\s+([0-9\.]*)%si,\s+([0-9\.]*)%st')
# Mem: 5990952k total, 4864016k used, 1126936k free, 441444k buffers
miq_mem = re.compile(r'Mem:\s+([0-9]*)k\stotal,\s+([0-9]*)k\sused,\s+([0-9]*)k\sfree,\s+'
r'([0-9]*)k\sbuffers')
# Swap: 9957368k total, 0k used, 9957368k free, 1153156k cached
miq_swap = re.compile(r'Swap:\s+([0-9]*)k\stotal,\s+([0-9]*)k\sused,\s+([0-9]*)k\sfree,\s+'
r'([0-9]*)k\scached')
# PID PPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
# 17526 2320 root 30 10 324m 9.8m 2444 S 0.0 0.2 0:09.38 /var/www/miq/vmdb/lib/workers/bin/worker.rb
miq_top = re.compile(r'([0-9]+)\s+[0-9]+\s+[A-Za-z0-9]+\s+[0-9]+\s+[0-9\-]+\s+([0-9\.mg]+)\s+'
r'([0-9\.mg]+)\s+([0-9\.mg]+)\s+[SRDZ]\s+([0-9\.]+)\s+([0-9\.]+)')
def evm_to_messages(evm_file, filters):
test_start = ''
test_end = ''
line_count = 0
messages = {}
msg_cmds = {}
runningtime = time()
evmlogfile = open(evm_file, 'r')
evm_log_line = evmlogfile.readline()
while evm_log_line:
line_count += 1
evm_log_line = evm_log_line.strip()
miqmsg_result = miqmsg.search(evm_log_line)
if miqmsg_result:
# Obtains the first timestamp in the log file
if test_start == '':
ts, pid = get_msg_timestamp_pid(evm_log_line)
test_start = ts
# A message was first put on the queue, this starts its queuing time
if (miqmsg_result.group(1) == 'MiqQueue.put'):
msg_cmd = get_msg_cmd(evm_log_line)
msg_id = get_msg_id(evm_log_line)
if msg_id:
ts, pid = get_msg_timestamp_pid(evm_log_line)
test_end = ts
messages[msg_id] = MiqMsgStat()
messages[msg_id].msg_id = msg_id
messages[msg_id].msg_id = '\'' + msg_id + '\''
messages[msg_id].msg_cmd = msg_cmd
messages[msg_id].pid_put = pid
messages[msg_id].puttime = ts
msg_args = get_msg_args(evm_log_line)
if msg_args is False:
logger.debug('Could not obtain message args line #: %s', line_count)
else:
messages[msg_id].msg_args = msg_args
else:
logger.error('Could not obtain message id, line #: %s', line_count)
elif (miqmsg_result.group(1) == 'MiqQueue.get_via_drb'):
msg_id = get_msg_id(evm_log_line)
if msg_id:
if msg_id in messages:
ts, pid = get_msg_timestamp_pid(evm_log_line)
test_end = ts
messages[msg_id].pid_get = pid
messages[msg_id].gettime = ts
messages[msg_id].deq_time = get_msg_deq(evm_log_line)
else:
logger.error('Message ID not in dictionary: %s', msg_id)
else:
logger.error('Could not obtain message id, line #: %s', line_count)
elif (miqmsg_result.group(1) == 'MiqQueue.delivered'):
msg_id = get_msg_id(evm_log_line)
if msg_id:
ts, pid = get_msg_timestamp_pid(evm_log_line)
test_end = ts
if msg_id in messages:
messages[msg_id].del_time = get_msg_del(evm_log_line)
messages[msg_id].total_time = messages[msg_id].deq_time + \
messages[msg_id].del_time
else:
logger.error('Message ID not in dictionary: %s', msg_id)
else:
logger.error('Could not obtain message id, line #: %s', line_count)
if (line_count % 100000) == 0:
timediff = time() - runningtime
runningtime = time()
logger.info('Count {} : Parsed 100000 lines in %s', line_count, timediff)
evm_log_line = evmlogfile.readline()
# I tried to avoid two loops but this reduced the complexity of filtering on messages.
# By filtering over messages, we can better display what is occuring under the covers, as a
# daily rollup is picked up off the queue different than a hourly rollup, etc
for msg in sorted(messages.keys()):
msg_args = messages[msg].msg_args
# Determine if the pattern matches and append to the command if it does
for p_filter in filters:
results = filters[p_filter].search(msg_args.strip())
if results:
messages[msg].msg_cmd = '{}{}'.format(messages[msg].msg_cmd, p_filter)
break
msg_cmd = messages[msg].msg_cmd
if msg_cmd not in msg_cmds:
msg_cmds[msg_cmd] = {}
msg_cmds[msg_cmd]['total'] = []
msg_cmds[msg_cmd]['queue'] = []
msg_cmds[msg_cmd]['execute'] = []
if messages[msg].total_time != 0:
msg_cmds[msg_cmd]['total'].append(round(messages[msg].total_time, 2))
msg_cmds[msg_cmd]['queue'].append(round(messages[msg].deq_time, 2))
msg_cmds[msg_cmd]['execute'].append(round(messages[msg].del_time, 2))
return messages, msg_cmds, test_start, test_end, line_count
def evm_to_workers(evm_file):
# Use grep to reduce # of lines to sort through
p = subprocess.Popen(['grep', 'Interrupt\\|MIQ([A-Za-z]*) ID\\|"evm_worker_uptime_exceeded\\|'
'"evm_worker_memory_exceeded\\|"evm_worker_stop\\|Worker exiting.', evm_file],
stdout=subprocess.PIPE)
greppedevmlog, err = p.communicate()
greppedevmlog = greppedevmlog.strip()
evmlines = greppedevmlog.split('\n')
workers = {}
wkr_upt_exc = 0
wkr_mem_exc = 0
wkr_stp = 0
wkr_int = 0
wkr_ext = 0
for evm_log_line in evmlines:
ts, pid = get_msg_timestamp_pid(evm_log_line)
miqwkr_result = miqwkr.search(evm_log_line)
if miqwkr_result:
workerid = int(miqwkr_result.group(2))
if workerid not in workers:
workers[workerid] = MiqWorker()
workers[workerid].worker_type = miqwkr_result.group(1)
workers[workerid].pid = miqwkr_result.group(3)
workers[workerid].worker_id = int(workerid)
workers[workerid].start_ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f')
elif 'evm_worker_uptime_exceeded' in evm_log_line:
miqwkr_id_result = miqwkr_id.search(evm_log_line)
if miqwkr_id_result:
workerid = int(miqwkr_id_result.group(1))
if workerid in workers:
if not workers[workerid].terminated:
wkr_upt_exc += 1
workers[workerid].terminated = 'evm_worker_uptime_exceeded'
workers[workerid].end_ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f')
elif 'evm_worker_memory_exceeded' in evm_log_line:
miqwkr_id_result = miqwkr_id.search(evm_log_line)
if miqwkr_id_result:
workerid = int(miqwkr_id_result.group(1))
if workerid in workers:
if not workers[workerid].terminated:
wkr_mem_exc += 1
workers[workerid].terminated = 'evm_worker_memory_exceeded'
workers[workerid].end_ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f')
elif 'evm_worker_stop' in evm_log_line:
miqwkr_id_result = miqwkr_id.search(evm_log_line)
if miqwkr_id_result:
workerid = int(miqwkr_id_result.group(1))
if workerid in workers:
if not workers[workerid].terminated:
wkr_stp += 1
workers[workerid].terminated = 'evm_worker_stop'
workers[workerid].end_ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f')
elif 'Interrupt' in evm_log_line:
for workerid in workers:
if not workers[workerid].end_ts:
wkr_int += 1
workers[workerid].terminated = 'Interrupted'
workers[workerid].end_ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f')
elif 'Worker exiting.' in evm_log_line:
miqwkr_id_2_result = miqwkr_id_2.search(evm_log_line)
if miqwkr_id_2_result:
workerid = int(miqwkr_id_2_result.group(1))
if workerid in workers:
if not workers[workerid].terminated:
wkr_ext += 1
workers[workerid].terminated = 'Worker Exited'
workers[workerid].end_ts = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f')
return workers, wkr_mem_exc, wkr_upt_exc, wkr_stp, wkr_int, wkr_ext, len(evmlines)
def split_appliance_charts(top_appliance, charts_dir):
# Automatically split top_output data roughly per day
minutes_in_a_day = 24 * 60
size_data = len(top_appliance['datetimes'])
start_hour = top_appliance['datetimes'][0][11:13]
start_minute = top_appliance['datetimes'][0][14:16]
bracket_end = minutes_in_a_day - ((int(start_hour) * 60) + int(start_minute))
if size_data > minutes_in_a_day:
# Greater than one day worth of data, split
file_names = [generate_appliance_charts(top_appliance, charts_dir, 0, bracket_end)]
for start_bracket in range(bracket_end, len(top_appliance['datetimes']), minutes_in_a_day):
if (start_bracket + minutes_in_a_day) > size_data:
end_index = size_data - 1
else:
end_index = start_bracket + minutes_in_a_day
file_names.append(generate_appliance_charts(top_appliance, charts_dir, start_bracket,
end_index))
return file_names
else:
# Less than one day worth of data, do not split
return [generate_appliance_charts(top_appliance, charts_dir, 0, size_data - 1)]
def generate_appliance_charts(top_appliance, charts_dir, start_index, end_index):
cpu_chart_file = '/{}-app-cpu.svg'.format(top_appliance['datetimes'][start_index])
mem_chart_file = '/{}-app-mem.svg'.format(top_appliance['datetimes'][start_index])
lines = {}
lines['Idle'] = top_appliance['cpuid'][start_index:end_index]
lines['User'] = top_appliance['cpuus'][start_index:end_index]
lines['System'] = top_appliance['cpusy'][start_index:end_index]
lines['Nice'] = top_appliance['cpuni'][start_index:end_index]
lines['Wait'] = top_appliance['cpuwa'][start_index:end_index]
# lines['Hi'] = top_appliance['cpuhi'][start_index:end_index] # IRQs %
# lines['Si'] = top_appliance['cpusi'][start_index:end_index] # Soft IRQs %
# lines['St'] = top_appliance['cpust'][start_index:end_index] # Steal CPU %
line_chart_render('CPU Usage', 'Date Time', 'Percent',
top_appliance['datetimes'][start_index:end_index], lines, charts_dir.join(cpu_chart_file),
True)
lines = {}
lines['Memory Total'] = top_appliance['memtot'][start_index:end_index]
lines['Memory Free'] = top_appliance['memfre'][start_index:end_index]
lines['Memory Used'] = top_appliance['memuse'][start_index:end_index]
lines['Swap Used'] = top_appliance['swause'][start_index:end_index]
lines['cached'] = top_appliance['cached'][start_index:end_index]
line_chart_render('Memory Usage', 'Date Time', 'KiB',
top_appliance['datetimes'][start_index:end_index], lines, charts_dir.join(mem_chart_file))
return cpu_chart_file, mem_chart_file
def generate_hourly_charts_and_csvs(hourly_buckets, charts_dir):
for cmd in sorted(hourly_buckets):
current_csv = 'hourly_' + cmd + '.csv'
csv_rawdata_path = log_path.join('csv_output', current_csv)
logger.info('Writing %s csvs/charts', cmd)
output_file = csv_rawdata_path.open('w', ensure=True)
csvwriter = csv.DictWriter(output_file, fieldnames=MiqMsgBucket().headers,
delimiter=',', quotechar='\'', quoting=csv.QUOTE_MINIMAL)
csvwriter.writeheader()
for dt in sorted(hourly_buckets[cmd].keys()):
linechartxaxis = []
avgdeqtimings = []
mindeqtimings = []
maxdeqtimings = []
avgdeltimings = []
mindeltimings = []
maxdeltimings = []
cmd_put = []
cmd_get = []
sortedhr = sorted(hourly_buckets[cmd][dt].keys())
for hr in sortedhr:
linechartxaxis.append(str(hr))
bk = hourly_buckets[cmd][dt][hr]
avgdeqtimings.append(round(bk.avg_deq, 2))
mindeqtimings.append(round(bk.min_deq, 2))
maxdeqtimings.append(round(bk.max_deq, 2))
avgdeltimings.append(round(bk.avg_del, 2))
mindeltimings.append(round(bk.min_del, 2))
maxdeltimings.append(round(bk.max_del, 2))
cmd_put.append(bk.total_put)
cmd_get.append(bk.total_get)
bk.date = dt
bk.hour = hr
csvwriter.writerow(dict(bk))
lines = {}
lines['Put ' + cmd] = cmd_put
lines['Get ' + cmd] = cmd_get
line_chart_render(cmd + ' Command Put/Get Count', 'Hour during ' + dt,
'# Count of Commands', linechartxaxis, lines,
charts_dir.join('/{}-{}-cmdcnt.svg'.format(cmd, dt)))
lines = {}
lines['Average Dequeue Timing'] = avgdeqtimings
lines['Min Dequeue Timing'] = mindeqtimings
lines['Max Dequeue Timing'] = maxdeqtimings
line_chart_render(cmd + ' Dequeue Timings', 'Hour during ' + dt, 'Time (s)',
linechartxaxis, lines, charts_dir.join('/{}-{}-dequeue.svg'.format(cmd, dt)))
lines = {}
lines['Average Deliver Timing'] = avgdeltimings
lines['Min Deliver Timing'] = mindeltimings
lines['Max Deliver Timing'] = maxdeltimings
line_chart_render(cmd + ' Deliver Timings', 'Hour during ' + dt, 'Time (s)',
linechartxaxis, lines, charts_dir.join('/{}-{}-deliver.svg'.format(cmd, dt)))
output_file.close()
def generate_raw_data_csv(rawdata_dict, csv_file_name):
csv_rawdata_path = log_path.join('csv_output', csv_file_name)
output_file = csv_rawdata_path.open('w', ensure=True)
csvwriter = csv.DictWriter(output_file, fieldnames=rawdata_dict[rawdata_dict.keys()[0]].headers,
delimiter=',', quotechar='\'', quoting=csv.QUOTE_MINIMAL)
csvwriter.writeheader()
sorted_rd_keys = sorted(rawdata_dict.keys())
for key in sorted_rd_keys:
csvwriter.writerow(dict(rawdata_dict[key]))
def generate_total_time_charts(msg_cmds, charts_dir):
for cmd in sorted(msg_cmds):
logger.info('Generating Total Time Chart for %s', cmd)
lines = {}
lines['Total Time'] = msg_cmds[cmd]['total']
lines['Queue'] = msg_cmds[cmd]['queue']
lines['Execute'] = msg_cmds[cmd]['execute']
line_chart_render(cmd + ' Total Time', 'Message #', 'Time (s)', [], lines,
charts_dir.join('/{}-total.svg'.format(cmd)))
def generate_worker_charts(workers, top_workers, charts_dir):
for worker in top_workers:
logger.info('Generating Charts for Worker: %s Type: %s',
worker, workers[worker].worker_type)
worker_name = '{}-{}'.format(worker, workers[worker].worker_type)
lines = {}
lines['Virt Mem'] = top_workers[worker]['virt']
lines['Res Mem'] = top_workers[worker]['res']
lines['Shared Mem'] = top_workers[worker]['share']
line_chart_render(worker_name, 'Date Time', 'Memory in MiB',
top_workers[worker]['datetimes'], lines,
charts_dir.join('/{}-Memory.svg'.format(worker_name)))
lines = {}
lines['CPU %'] = top_workers[worker]['cpu_per']
line_chart_render(worker_name, 'Date Time', 'CPU Usage', top_workers[worker]['datetimes'],
lines, charts_dir.join('/{}-CPU.svg'.format(worker_name)))
def get_first_miqtop(top_log_file):
# Find first miqtop log line
p = subprocess.Popen(['grep', '-m', '1', '^miqtop\:', top_log_file], stdout=subprocess.PIPE)
greppedtop, err = p.communicate()
str_start = greppedtop.index('is->')
miqtop_time = du_parser.parse(greppedtop[str_start:], fuzzy=True, ignoretz=True)
timezone_offset = int(greppedtop[str_start + 34:str_start + 37])
miqtop_time = miqtop_time - timedelta(hours=timezone_offset)
return miqtop_time, timezone_offset
def get_msg_args(log_line):
miqmsg_args_result = miqmsg_args.search(log_line)
if miqmsg_args_result:
return miqmsg_args_result.group(1)
else:
return False
def get_msg_cmd(log_line):
miqmsg_cmd_result = miqmsg_cmd.search(log_line)
if miqmsg_cmd_result:
return miqmsg_cmd_result.group(1)
else:
return False
def get_msg_del(log_line):
miqmsg_del_result = miqmsg_del.search(log_line)
if miqmsg_del_result:
return float(miqmsg_del_result.group(1))
else:
return False
def get_msg_deq(log_line):
miqmsg_deq_result = miqmsg_deq.search(log_line)
if miqmsg_deq_result:
return float(miqmsg_deq_result.group(1))
else:
return False
def get_msg_id(log_line):
miqmsg_id_result = miqmsg_id.search(log_line)
if miqmsg_id_result:
return miqmsg_id_result.group(1)
else:
return False
def get_msg_timestamp_pid(log_line):
# Obtains the timestamp and pid
ts_result = log_stamp.search(log_line)
if ts_result:
dt_evm = '{} {}'.format(ts_result.group(1), ts_result.group(2))
return dt_evm, ts_result.group(3)
else:
return False, 0
def hour_bucket_init(init):
if init:
return MiqMsgBucket()
else:
return {}
def line_chart_render(title, xtitle, ytitle, x_labels, lines, fname, stacked=False):
if stacked:
line_chart = pygal.StackedLine()
else:
line_chart = pygal.Line()
line_chart.title = title
line_chart.x_title = xtitle
line_chart.y_title = ytitle
line_chart.title_font_size = 8
line_chart.legend_font_size = 8
line_chart.truncate_legend = 26
line_chart.x_labels = x_labels
sortedlines = sorted(lines.keys())
for line in sortedlines:
line_chart.add(line, lines[line])
line_chart.render_to_file(str(fname))
def messages_to_hourly_buckets(messages, test_start, test_end):
hr_bkt = {}
# Hour buckets look like: hr_bkt[msg_cmd][msg_date][msg_hour] = MiqMsgBucket()
for msg in messages:
# put on queue, deals with queuing:
msg_cmd = messages[msg].msg_cmd
putdate = messages[msg].puttime[:10]
puthour = messages[msg].puttime[11:13]
if msg_cmd not in hr_bkt:
hr_bkt[msg_cmd] = provision_hour_buckets(test_start, test_end)
hr_bkt[msg_cmd][putdate][puthour].total_put += 1
hr_bkt[msg_cmd][putdate][puthour].sum_deq += messages[msg].deq_time
if (hr_bkt[msg_cmd][putdate][puthour].min_deq == 0 or
hr_bkt[msg_cmd][putdate][puthour].min_deq > messages[msg].deq_time):
hr_bkt[msg_cmd][putdate][puthour].min_deq = messages[msg].deq_time
if (hr_bkt[msg_cmd][putdate][puthour].max_deq == 0 or
hr_bkt[msg_cmd][putdate][puthour].max_deq < messages[msg].deq_time):
hr_bkt[msg_cmd][putdate][puthour].max_deq = messages[msg].deq_time
hr_bkt[msg_cmd][putdate][puthour].avg_deq = \
hr_bkt[msg_cmd][putdate][puthour].sum_deq / hr_bkt[msg_cmd][putdate][puthour].total_put
# Get time is when the message is delivered
getdate = messages[msg].gettime[:10]
gethour = messages[msg].gettime[11:13]
hr_bkt[msg_cmd][getdate][gethour].total_get += 1
hr_bkt[msg_cmd][getdate][gethour].sum_del += messages[msg].del_time
if (hr_bkt[msg_cmd][getdate][gethour].min_del == 0 or
hr_bkt[msg_cmd][getdate][gethour].min_del > messages[msg].del_time):
hr_bkt[msg_cmd][getdate][gethour].min_del = messages[msg].del_time
if (hr_bkt[msg_cmd][getdate][gethour].max_del == 0 or
hr_bkt[msg_cmd][getdate][gethour].max_del < messages[msg].del_time):
hr_bkt[msg_cmd][getdate][gethour].max_del = messages[msg].del_time
hr_bkt[msg_cmd][getdate][gethour].avg_del = \
hr_bkt[msg_cmd][getdate][gethour].sum_del / hr_bkt[msg_cmd][getdate][gethour].total_get
return hr_bkt
def messages_to_statistics_csv(messages, statistics_file_name):
all_statistics = []
for msg_id in messages:
msg = messages[msg_id]
added = False
if len(all_statistics) > 0:
for msg_statistics in all_statistics:
if msg_statistics.cmd == msg.msg_cmd:
if msg.del_time > 0:
msg_statistics.delivertimes.append(float(msg.del_time))
msg_statistics.gets += 1
msg_statistics.dequeuetimes.append(float(msg.deq_time))
msg_statistics.totaltimes.append(float(msg.total_time))
msg_statistics.puts += 1
added = True
break
if not added:
msg_statistics = MiqMsgLists()
msg_statistics.cmd = msg.msg_cmd
if msg.del_time > 0:
msg_statistics.delivertimes.append(float(msg.del_time))
msg_statistics.gets = 1
msg_statistics.dequeuetimes.append(float(msg.deq_time))
msg_statistics.totaltimes.append(float(msg.total_time))
msg_statistics.puts = 1
all_statistics.append(msg_statistics)
csvdata_path = log_path.join('csv_output', statistics_file_name)
outputfile = csvdata_path.open('w', ensure=True)
try:
csvfile = csv.writer(outputfile)
metrics = ['samples', 'min', 'avg', 'median', 'max', 'std', '90', '99']
measurements = ['deq_time', 'del_time', 'total_time']
headers = ['cmd', 'puts', 'gets']
for measurement in measurements:
for metric in metrics:
headers.append('{}_{}'.format(measurement, metric))
csvfile.writerow(headers)
# Contents of CSV
for msg_statistics in sorted(all_statistics, key=lambda x: x.cmd):
if msg_statistics.gets > 1:
logger.debug('Samples/Avg/90th/Std: %s: %s : %s : %s,Cmd: %s',
str(len(msg_statistics.totaltimes)).rjust(7),
str(round(numpy.average(msg_statistics.totaltimes), 3)).rjust(7),
str(round(numpy.percentile(msg_statistics.totaltimes, 90), 3)).rjust(7),
str(round(numpy.std(msg_statistics.totaltimes), 3)).rjust(7),
msg_statistics.cmd)
stats = [msg_statistics.cmd, msg_statistics.puts, msg_statistics.gets]
stats.extend(generate_statistics(msg_statistics.dequeuetimes, 3))
stats.extend(generate_statistics(msg_statistics.delivertimes, 3))
stats.extend(generate_statistics(msg_statistics.totaltimes, 3))
csvfile.writerow(stats)
finally:
outputfile.close()
def provision_hour_buckets(test_start, test_end, init=True):
buckets = {}
start_date = datetime.strptime(test_start[:10], '%Y-%m-%d')
end_date = datetime.strptime(test_end[:10], '%Y-%m-%d')
start_hr = int(test_start[11:13])
end_hr = int(test_end[11:13]) + 1
delta_date = end_date - start_date
for dates in range(delta_date.days + 1):
new_date = start_date + timedelta(days=dates)
buckets[new_date.strftime('%Y-%m-%d')] = {}
sorteddt = sorted(buckets.keys())
for date in sorteddt:
if date == test_start[:10]:
if date == test_end[:10]:
for hr in range(start_hr, end_hr):
buckets[date][str(hr).zfill(2)] = hour_bucket_init(init)
else:
for hr in range(start_hr, 24):
buckets[date][str(hr).zfill(2)] = hour_bucket_init(init)
elif date == test_end[:10]:
for hr in range(end_hr):
buckets[date][str(hr).zfill(2)] = hour_bucket_init(init)
else:
for hr in range(24):
buckets[date][str(hr).zfill(2)] = hour_bucket_init(init)
if init:
buckets[''] = {}
buckets[''][''] = MiqMsgBucket()
return buckets
def top_to_appliance(top_file):
# Find first miqtop log line
miqtop_time, timezone_offset = get_first_miqtop(top_file)
runningtime = time()
grep_pattern = '^top\s\-\s\\|^miqtop\:\\|^Cpu(s)\:\\|^Mem\:\\|^Swap\:'
# Use grep to reduce # of lines to sort through
p = subprocess.Popen(['grep', grep_pattern, top_file], stdout=subprocess.PIPE)
greppedtop, err = p.communicate()
timediff = time() - runningtime
logger.info('Grepped top_output for CPU/Mem/Swap & time data in %s', timediff)
top_lines = greppedtop.strip().split('\n')
line_count = 0
top_keys = ['datetimes', 'cpuus', 'cpusy', 'cpuni', 'cpuid', 'cpuwa', 'cpuhi', 'cpusi', 'cpust',
'memtot', 'memuse', 'memfre', 'buffer', 'swatot', 'swause', 'swafre', 'cached']
top_app = dict((key, []) for key in top_keys)
cur_time = None
miqtop_ahead = True
runningtime = time()
for top_line in top_lines:
line_count += 1
if 'top - ' in top_line:
# top - 11:00:43
cur_hour = int(top_line[6:8])
cur_min = int(top_line[9:11])
cur_sec = int(top_line[12:14])
if miqtop_ahead:
# Have not found miqtop date/time yet so we must rely on miqtop date/time "ahead"
if cur_hour <= miqtop_time.hour:
cur_time = miqtop_time.replace(hour=cur_hour, minute=cur_min, second=cur_sec) \
- timedelta(hours=timezone_offset)
else:
# miqtop_time is ahead by date
logger.info('miqtop_time is ahead by one day')
cur_time = miqtop_time - timedelta(days=1)
cur_time = cur_time.replace(hour=cur_hour, minute=cur_min, second=cur_sec) \
- timedelta(hours=timezone_offset)
else:
cur_time = miqtop_time.replace(hour=cur_hour, minute=cur_min, second=cur_sec) \
- timedelta(hours=timezone_offset)
elif 'miqtop: ' in top_line:
miqtop_ahead = False
# miqtop: .* is-> Mon Jan 26 08:57:39 EST 2015 -0500
str_start = top_line.index('is->')
miqtop_time = du_parser.parse(top_line[str_start:], fuzzy=True, ignoretz=True)
# Time logged in top is the system's time which is ahead/behind by the timezone offset
timezone_offset = int(top_line[str_start + 34:str_start + 37])
miqtop_time = miqtop_time - timedelta(hours=timezone_offset)
elif 'Cpu(s): ' in top_line:
miq_cpu_result = miq_cpu.search(top_line)
if miq_cpu_result:
top_app['datetimes'].append(str(cur_time))
top_app['cpuus'].append(float(miq_cpu_result.group(1).strip()))
top_app['cpusy'].append(float(miq_cpu_result.group(2).strip()))
top_app['cpuni'].append(float(miq_cpu_result.group(3).strip()))
top_app['cpuid'].append(float(miq_cpu_result.group(4).strip()))
top_app['cpuwa'].append(float(miq_cpu_result.group(5).strip()))
top_app['cpuhi'].append(float(miq_cpu_result.group(6).strip()))
top_app['cpusi'].append(float(miq_cpu_result.group(7).strip()))
top_app['cpust'].append(float(miq_cpu_result.group(8).strip()))
else:
logger.error('Issue with miq_cpu regex: %s', top_line)
elif 'Mem: ' in top_line:
miq_mem_result = miq_mem.search(top_line)
if miq_mem_result:
top_app['memtot'].append(round(float(miq_mem_result.group(1).strip()) / 1024, 2))
top_app['memuse'].append(round(float(miq_mem_result.group(2).strip()) / 1024, 2))
top_app['memfre'].append(round(float(miq_mem_result.group(3).strip()) / 1024, 2))
top_app['buffer'].append(round(float(miq_mem_result.group(4).strip()) / 1024, 2))
else:
logger.error('Issue with miq_mem regex: %s', top_line)
elif 'Swap: ' in top_line:
miq_swap_result = miq_swap.search(top_line)
if miq_swap_result:
top_app['swatot'].append(round(float(miq_swap_result.group(1).strip()) / 1024, 2))
top_app['swause'].append(round(float(miq_swap_result.group(2).strip()) / 1024, 2))
top_app['swafre'].append(round(float(miq_swap_result.group(3).strip()) / 1024, 2))
top_app['cached'].append(round(float(miq_swap_result.group(4).strip()) / 1024, 2))
else:
logger.error('Issue with miq_swap regex: %s', top_line)
else:
logger.error('Issue with grepping of top file:%s', top_line)
if (line_count % 20000) == 0:
timediff = time() - runningtime
runningtime = time()
logger.info('Count {} : Parsed 20000 lines in %s', line_count, timediff)
return top_app, len(top_lines)
def top_to_workers(workers, top_file):
# Find first miqtop log line
miqtop_time, timezone_offset = get_first_miqtop(top_file)
runningtime = time()
grep_pids = ''
for wkr in workers:
grep_pids = '{}^{}\s\\|'.format(grep_pids, workers[wkr].pid)
grep_pattern = '{}^top\s\-\s\\|^miqtop\:'.format(grep_pids)
# Use grep to reduce # of lines to sort through
p = subprocess.Popen(['grep', grep_pattern, top_file], stdout=subprocess.PIPE)
greppedtop, err = p.communicate()
timediff = time() - runningtime
logger.info('Grepped top_output for pids & time data in %s', timediff)
# This is very ugly because miqtop does include the date but top does not
# Also pids can be duplicated, so careful attention to detail on when a pid starts and ends
top_lines = greppedtop.strip().split('\n')
line_count = 0
top_workers = {}
cur_time = None
miqtop_ahead = True
runningtime = time()
for top_line in top_lines:
line_count += 1
if 'top - ' in top_line:
# top - 11:00:43
cur_hour = int(top_line[6:8])
cur_min = int(top_line[9:11])
cur_sec = int(top_line[12:14])
if miqtop_ahead:
# Have not found miqtop time yet so we must rely on miqtop time "ahead"
if cur_hour <= miqtop_time.hour:
cur_time = miqtop_time.replace(hour=cur_hour, minute=cur_min, second=cur_sec) \
- timedelta(hours=timezone_offset)
else:
# miqtop_time is ahead by date
logger.info('miqtop_time is ahead by one day')
cur_time = miqtop_time - timedelta(days=1)
cur_time = cur_time.replace(hour=cur_hour, minute=cur_min, second=cur_sec) \
- timedelta(hours=timezone_offset)
else:
cur_time = miqtop_time.replace(hour=cur_hour, minute=cur_min, second=cur_sec) \
- timedelta(hours=timezone_offset)
elif 'miqtop: ' in top_line:
miqtop_ahead = False
# miqtop: .* is-> Mon Jan 26 08:57:39 EST 2015 -0500
str_start = top_line.index('is->')
miqtop_time = du_parser.parse(top_line[str_start:], fuzzy=True, ignoretz=True)
# Time logged in top is the system's time which is ahead/behind by the timezone offset
timezone_offset = int(top_line[str_start + 34:str_start + 37])
miqtop_time = miqtop_time - timedelta(hours=timezone_offset)
else:
top_results = miq_top.search(top_line)
if top_results:
top_pid = top_results.group(1)
top_virt = convert_top_mem_to_mib(top_results.group(2))
top_res = convert_top_mem_to_mib(top_results.group(3))
top_share = convert_top_mem_to_mib(top_results.group(4))
top_cpu_per = float(top_results.group(5))
top_mem_per = float(top_results.group(6))
for worker in workers:
if workers[worker].pid == top_pid:
if cur_time > workers[worker].start_ts and \
(workers[worker].end_ts == '' or cur_time < workers[worker].end_ts):
w_id = workers[worker].worker_id
if w_id not in top_workers:
top_workers[w_id] = {}
top_workers[w_id]['datetimes'] = []
top_workers[w_id]['virt'] = []
top_workers[w_id]['res'] = []
top_workers[w_id]['share'] = []
top_workers[w_id]['cpu_per'] = []
top_workers[w_id]['mem_per'] = []
top_workers[w_id]['datetimes'].append(str(cur_time))
top_workers[w_id]['virt'].append(top_virt)
top_workers[w_id]['res'].append(top_res)
top_workers[w_id]['share'].append(top_share)
top_workers[w_id]['cpu_per'].append(top_cpu_per)
top_workers[w_id]['mem_per'].append(top_mem_per)
break
else:
logger.error('Issue with miq_top regex or grepping of top file:%s', top_line)
if (line_count % 20000) == 0:
timediff = time() - runningtime
runningtime = time()
logger.info('Count %s : Parsed 20000 lines in %s', line_count, timediff)
return top_workers, len(top_lines)
def perf_process_evm(evm_file, top_file):
msg_filters = {
'-hourly': re.compile(r'\"[0-9\-]*T[0-9\:]*Z\",\s\"hourly\"'),
'-daily': re.compile(r'\"[0-9\-]*T[0-9\:]*Z\",\s\"daily\"'),
'-EmsRedhat': re.compile(r'\[\[\"EmsRedhat\"\,\s[0-9]*\]\]'),
'-EmsVmware': re.compile(r'\[\[\"EmsVmware\"\,\s[0-9]*\]\]'),
'-EmsAmazon': re.compile(r'\[\[\"EmsAmazon\"\,\s[0-9]*\]\]'),
'-EmsOpenstack': re.compile(r'\[\[\"EmsOpenstack\"\,\s[0-9]*\]\]')
}
starttime = time()
initialtime = starttime
logger.info('----------- Parsing evm log file for messages -----------')
messages, msg_cmds, test_start, test_end, msg_lc = evm_to_messages(evm_file, msg_filters)
timediff = time() - starttime
logger.info('----------- Completed Parsing evm log file -----------')
logger.info('Parsed %s lines of evm log file for messages in %s', msg_lc, timediff)
logger.info('Total # of Messages: %d', len(messages))
logger.info('Total # of Commands: %d', len(msg_cmds))
logger.info('Start Time: %s', test_start)
logger.info('End Time: %s', test_end)
logger.info('----------- Parsing evm log file for workers -----------')
starttime = time()
workers, wkr_mem_exc, wkr_upt_exc, wkr_stp, wkr_int, wkr_ext, wkr_lc = evm_to_workers(evm_file)
timediff = time() - starttime
logger.info('----------- Completed Parsing evm log for workers -----------')
logger.info('Parsed %s lines of evm log file for workers in %s', wkr_lc, timediff)
logger.info('Total # of Workers: %d', len(workers))
logger.info('# Workers Memory Exceeded: %s', wkr_mem_exc)
logger.info('# Workers Uptime Exceeded: %s', wkr_upt_exc)
logger.info('# Workers Exited: %s', wkr_ext)
logger.info('# Workers Stopped: %s', wkr_stp)
logger.info('# Workers Interrupted: %s', wkr_int)
logger.info('----------- Parsing top_output log file for Appliance Metrics -----------')
starttime = time()
top_appliance, tp_lc = top_to_appliance(top_file)
timediff = time() - starttime
logger.info('----------- Completed Parsing top_output log -----------')
logger.info('Parsed %s lines of top_output file for Appliance Metrics in %s', tp_lc,
timediff)
logger.info('----------- Parsing top_output log file for worker CPU/Mem -----------')
starttime = time()
top_workers, tp_lc = top_to_workers(workers, top_file)
timediff = time() - starttime
logger.info('----------- Completed Parsing top_output log -----------')
logger.info('Parsed %s lines of top_output file for workers in %s', tp_lc, timediff)
charts_dir = log_path.join('charts')
if not os.path.exists(str(charts_dir)):
os.mkdir(str(charts_dir))
logger.info('----------- Generating Raw Data csv files -----------')
starttime = time()
generate_raw_data_csv(messages, 'queue-rawdata.csv')
generate_raw_data_csv(workers, 'workers-rawdata.csv')
timediff = time() - starttime
logger.info('Generated Raw Data csv files in: %s', timediff)
logger.info('----------- Generating Hourly Buckets -----------')
starttime = time()
hr_bkt = messages_to_hourly_buckets(messages, test_start, test_end)
timediff = time() - starttime
logger.info('Generated Hourly Buckets in: %s', timediff)
logger.info('----------- Generating Hourly Charts and csvs -----------')
starttime = time()
generate_hourly_charts_and_csvs(hr_bkt, charts_dir)
timediff = time() - starttime
logger.info('Generated Hourly Charts and csvs in: %s', timediff)
logger.info('----------- Generating Total Time Charts -----------')
starttime = time()
generate_total_time_charts(msg_cmds, charts_dir)
timediff = time() - starttime
logger.info('Generated Total Time Charts in: %s', timediff)
logger.info('----------- Generating Appliance Charts -----------')
starttime = time()
app_chart_files = split_appliance_charts(top_appliance, charts_dir)
timediff = time() - starttime
logger.info('Generated Appliance Charts in: %s', timediff)
logger.info('----------- Generating Worker Charts -----------')
starttime = time()
generate_worker_charts(workers, top_workers, charts_dir)
timediff = time() - starttime
logger.info('Generated Worker Charts in: %s', timediff)
logger.info('----------- Generating Message Statistics -----------')
starttime = time()
messages_to_statistics_csv(messages, 'queue-statistics.csv')
timediff = time() - starttime
logger.info('Generated Message Statistics in: %s', timediff)
logger.info('----------- Writing html files for report -----------')
# Write an index.html file for fast switching between graphs:
html_index = log_path.join('index.html').open('w', ensure=True)
cmd = hr_bkt.keys()[0]
html_index.write(
'<html>\n'
'<title>Performance Worker/Message Metrics</title>\n'
'<frameset cols="17%,83%">\n'
' <frame src="msg_menu.html" name="menu"/>\n'
' <frame src="charts/{}-{}-dequeue.svg" name="showframe" />\n'
'</frameset>\n'
'</html>'.format(cmd, sorted(hr_bkt[cmd].keys())[-1]))
html_index.close()
# Write the side bar menu html file
html_menu = log_path.join('msg_menu.html').open('w', ensure=True)
html_menu.write('<html>\n')
html_menu.write('<font size="2">')
html_menu.write('Appliance:<BR>')
for cpu_mem_charts in app_chart_files:
html_menu.write('{} <a href="charts{}" target="showframe">CPU</a> | '.format(
cpu_mem_charts[0][1:11], cpu_mem_charts[0]))
html_menu.write('<a href="charts{}" target="showframe">Memory</a><br>'.format(
cpu_mem_charts[1]))
html_menu.write('<a href="worker_menu.html" target="menu">Worker CPU/Memory</a><br>')
html_menu.write('Parsed {} lines for messages<br>'.format(msg_lc))
html_menu.write('Start Time: {}<br>'.format(test_start))
html_menu.write('End Time: {}<br>'.format(test_end))
html_menu.write('Message Count: {}<br>'.format(len(messages)))
html_menu.write('Command Count: {}<br>'.format(len(msg_cmds)))
html_menu.write('Parsed {} lines for workers<br>'.format(wkr_lc))
html_menu.write('Total Workers: {}<br>'.format(len(workers)))
html_menu.write('Workers Memory Exceeded: {}<br>'.format(wkr_mem_exc))
html_menu.write('Workers Uptime Exceeded: {}<br>'.format(wkr_upt_exc))
html_menu.write('Workers Exited: {}<br>'.format(wkr_ext))
html_menu.write('Workers Stopped: {}<br>'.format(wkr_stp))
html_menu.write('Workers Interrupted: {}<br>'.format(wkr_int))
html_menu.write('<a href="csv_output/messages-rawdata.csv">messages-rawdata.csv</a><br>')
html_menu.write('<a href="csv_output/messages-statistics.csv">messages-statistics.csv</a><br>')
html_menu.write('<a href="csv_output/workers-rawdata.csv">workers-rawdata.csv</a><br><br>')
# Sorts by the the messages which have the most, descending
for cmd in sorted(msg_cmds, key=lambda x: len(msg_cmds[x]['total']), reverse=True):
html_menu.write('<a href="csv_output/hourly_{}.csv"'
'target="showframe">{}</a><br>'.format(cmd, cmd))
html_menu.write('<a href="charts/{}-total.svg" target="showframe">'
'Total Messages: {} </a><br>'.format(cmd, len(msg_cmds[cmd]['total'])))
for dt in sorted(hr_bkt[cmd].keys()):
if dt == '':
html_menu.write('Queued: ')
else:
html_menu.write('{}: '.format(dt))
html_menu.write('<a href="charts/{}-{}-cmdcnt.svg" target="showframe">'
'cnt</a> | '.format(cmd, dt))
html_menu.write('<a href="charts/{}-{}-dequeue.svg" target="showframe">'
'deq</a> | '.format(cmd, dt))
html_menu.write('<a href="charts/{}-{}-deliver.svg" target="showframe">'
'del</a><br>'.format(cmd, dt))
html_menu.write('<br>')
html_menu.write('</font>')
html_menu.write('</html>')
html_menu.close()
html_wkr_menu = log_path.join('worker_menu.html').open('w', ensure=True)
html_wkr_menu.write('<html>\n')
html_wkr_menu.write('<font size="2">')
html_wkr_menu.write('Appliance:<BR>')
for cpu_mem_charts in app_chart_files:
html_wkr_menu.write('{}-<a href="charts{}" target="showframe">CPU</a> | '.format(
cpu_mem_charts[0][1:11], cpu_mem_charts[0]))
html_wkr_menu.write('<a href="charts{}" target="showframe">Memory</a><br>'.format(
cpu_mem_charts[1]))
html_wkr_menu.write('<a href="msg_menu.html" target="menu">Message Latencies</a><br>')
html_wkr_menu.write('Parsed {} lines for messages<br>'.format(msg_lc))
html_wkr_menu.write('Start Time: {}<br>'.format(test_start))
html_wkr_menu.write('End Time: {}<br>'.format(test_end))
html_wkr_menu.write('Message Count: {}<br>'.format(len(messages)))
html_wkr_menu.write('Command Count: {}<br>'.format(len(msg_cmds)))
html_wkr_menu.write('Parsed {} lines for workers<br>'.format(wkr_lc))
html_wkr_menu.write('Total Workers: {}<br>'.format(len(workers)))
html_wkr_menu.write('Workers Memory Exceeded: {}<br>'.format(wkr_mem_exc))
html_wkr_menu.write('Workers Uptime Exceeded: {}<br>'.format(wkr_upt_exc))
html_wkr_menu.write('Workers Exited: {}<br>'.format(wkr_ext))
html_wkr_menu.write('Workers Stopped: {}<br>'.format(wkr_stp))
html_wkr_menu.write('Workers Interrupted: {}<br>'.format(wkr_int))
html_wkr_menu.write('<a href="csv_output/messages-rawdata.csv">messages-rawdata.csv</a><br>')
html_wkr_menu.write('<a href="csv_output/messages-statistics.csv">'
'messages-statistics.csv</a><br>')
html_wkr_menu.write('<a href="csv_output/workers-rawdata.csv">workers-rawdata.csv</a><br><br>')
html_wkr_menu.write('Running Workers:<br>')
w_type = ''
for worker_id in sorted(workers, key=lambda x: workers[x].worker_type):
if workers[worker_id].terminated == '':
if not w_type == workers[worker_id].worker_type:
w_type = workers[worker_id].worker_type
html_wkr_menu.write('{}<br>'.format(w_type))