-
Notifications
You must be signed in to change notification settings - Fork 1
/
iostat_plotter_v3.py
executable file
·2728 lines (2458 loc) · 109 KB
/
iostat_plotter_v3.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
#!/usr/bin/python
#
# Enhanced data plotter for iostat output. Feb. 22 2014
#
# Copyright Jeffrey B. Layton
#
# License: GNU GPL v2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
# Version 2, June 1991
#
# Copyright (C) 1989, 1991 Free Software Foundation, Inc.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
#
#
# To run the application first gather the iostat information using:
#
# [laytonjb ~]$ iostat -c -d -x -t -m /dev/sda 1 100 > iostat.out
#
# where /dev/sda is the specific device you want to monitor which is
# up to you. If you don't put a device there, iostat will monitor
# all devices. For example:
#
# [laytonjb ~]$ iostat -c -d -x -t -m 1 100 > iostat.out
#
# "1 100" which tells iostat to use "1" second intervals and "100"
# means to gather data for 100 time (or 100 sceonds in this case).
#
# Then to run iostat_plotter, the command is,
#
# [laytonjb ~]$ iostat_plotter.py iostat.out
#
# where "iostat.out" is the output from iostat. The code is written
# in Python (obviously) and uses the shlex, time, os, and matplotlib
# modules. iostat_plotter is smart enough to gather the data for each
# device and plot them separately.
#
# Alternatively, you can run iostat_plotter.py as,
#
# [laytonjb ~]$ iostat_plotter.py -c iostat.out
#
# where the option "-c" stands for "combined" plots which plots all
# of the devices on the same plot.
#
# When iostat_plotter is done it will create a subdirectory "HTML_REPORT"
# that contains the plots and an html file "report.html". Open that
# html file in a browser or word processor and you will see the plots
# and a small write-up about them. Feel free to modify the code but
# please send back changes.
#
import sys
try:
import shlex # Needed for splitting input lines
except ImportError:
print "Cannot import shlex module - this is needed for this application.";
print "Exiting..."
sys.exit();
try:
import time; # Needed for time conversion function
time_var = 1
except:
time_var = 0;
print "Cannot find time module - this is needed for this application.";
print "Exiting..."
sys.exit();
try:
import matplotlib.pyplot as plt; # Needed for plots
matplotlib_var = 1
except:
matplotlib_var = 0;
print "Cannot find matplotlib - this is needed for this application.";
print "Exiting..."
sys.exit();
try:
import os # Needed for mkdir
except ImportError:
print "Cannot import os module - this is needed for this application.";
print "Exiting..."
sys.exit();
try:
import pickle # Needed for pickle
pickle_success = 1;
except ImportError:
print "Cannot import pickle module - this is not needed for this application.";
print "Continuing to process";
pickle_success = 0;
# ------------------------------
def help_out():
# prints out help information and stops
print " ";
print "This application creates a short HTML based report from iostat output";
print "(part of the sysstat tools). The report includes plots that help";
print "analyze the output. It can adapt to sysstat v9.x format or sysstat";
print "v10.x output (it is slightly different). Many distributions such as";
print "CentOS or Red Hat use sysstat version 9.x. However, it is recommended";
print "that you upgrad to sysstat 10.x because you get slightly more information.";
print "It is not a difficult task but be sure you install over the previous";
print "version.";
print " ";
print "To run the application first gather the iostat information using: ";
print "the following example.";
print " ";
print "[laytonjb ~]$ iostat -c -d -x -t -m /dev/sda 1 100 > iostat.out ";
print " ";
print "where the \"-c\" option displays the CPU utilization, the \"-d\" option";
print "displays the device utilization, the \"-x\" option displays extended";
print "statistics, and the \"-m\" option diplays the statistics in megabytes";
print "per second. The options \"1 100\" tell iostat to use \"1\" second ";
print "intervals and \"100\" means to gather data for 100 internvals (or 100";
print "seconds in this case). ";
print " ";
print "After the \"-m\" option is /dev/sda which is the specific device";
print "you want to monitor. This option is up to you. If you don't put a ";
print "device there, iostat will monitor all devices. For example:"
print " ";
print "[laytonjb ~]$ iostat -c -d -x -t -m 1 100 > iostat.out ";
print " ";
print "which captures the data from all devices.";
print " ";
print "In these two examples, the output from iostat is send to a file which is";
print "\"iostat.out\". You can name the file anything you want but be sure ";
print "note the name of the file.";
print " ";
print "Then to run iostat_plotter using the iostat output file, the command is, ";
print " ";
print "[laytonjb ~]$ iostat_plotter.py iostat.out ";
print " ";
print "where \"iostat.out\" is the output from iostat. The code is written ";
print "in Python (obviously) and uses the shlex, time, os, and matplotlib ";
print "modules. Be sure this libraries are installed on your system.";
print " ";
print "You can run iostat_plotter in one of two ways. The first way creates ";
print "the set of plots for each device on the node. In this version of ";
print "iostat_plotter, 11 plots are created per device, so if you have two";
print "devices on the node, then you will ahve a total of 22 plots.";
print " ";
print "The other way to run niostat_plotter is to combine the results for each";
print "device in the plots. This means you will have only 11 plots ";
print "in the HTML report even if you have more than one device. You run this ";
print "with the following command:";
print " ";
print "[laytonjb ~]$ iostat_plotter.py -c iostat.out ";
print " ";
print "The option \"-c\" tells iostat_plotter to \"combine\" the results from";
print "all of the devices into a single plot. Currently, you can analyze about";
print "8 devices. With more than 8 devices, the legend labels run into each other.";
print " ";
print "When iostat_plotter is done it will create a subdirectory \"HTML_REPORT\" ";
print "that contains the plots and an html file \"report.html\". Open that ";
print "html file in a browser or word processor and you will see the plots ";
print "and a small write-up about them. Feel free to modify the code but ";
print "please send back changes. ";
print " ";
# end def
def Three_Chart(x1, y1, x2, y2, x3, y3, xlabel, ylabel1, ylabel2, ylabel3,
d1, d2, d3, fsize, flegsize, filename, box_expansion):
#
# Creates 3 vertical subplots with legends and 1 x-axis label at the
# the bottom
#
# x1 = x-axis data for top plot
# x2 = x-axis data for middle plot
# x3 = x-axis data for bottom plot
# y1 = y-axis data for top plot
# y2 = y-axis data for middle plot
# y3 = y-axis data for bottom plot
# xlabel = x-axis label (only on bottom plot)
# ylabel1 = label for top y-axis
# ylabel2 = label for middle y-axis
# ylabel3 = label for bottom plot
# d1 = data label for top plot
# d2 = data label for middle plot
# d3 = data label for bottom plot
# fsize = font size for tick labels
# flegsize = font size for legend labels
# filename = name of file for plot output
# box_expansion = expansion factor on legend box
#
# Top plot
ax1 = plt.subplot(311); # Define top plot using subplot function
plt.plot(x1,y1, "ro-", label=d1); # Plot the first data set with a red line wiht "o" as a symbol
plt.grid();
plt.xlabel(" "); # Don't put an x-axis label since it's the top plot
plt.ylabel(ylabel1, fontsize=6); # Use a 10 pt font for y-axis label
ax1.set_xticklabels([]); # get x-axis tick label
# Legend
box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame1 = leg1.get_frame();
frame1.set_facecolor("0.80"); # Make legend box have a gray background
for t in leg1.get_texts():
t.set_fontsize(flegsize); # Change the font size of the legend text to 10 pt.
# end for
plt.xticks(fontsize=6);
plt.yticks(fontsize=6);
# Middle plot
ax2 = plt.subplot(312);
plt.plot(x2,y2, "bo-", label=d2);
plt.grid();
plt.xlabel(" ");
plt.ylabel(ylabel2, fontsize=fsize);
ax2.set_xticklabels([]);
# Legend
box = ax2.get_position();
ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height]);
leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame2 = leg2.get_frame();
frame2.set_facecolor("0.80");
for t in leg2.get_texts():
t.set_fontsize(flegsize);
# end for
plt.xticks(fontsize=fsize);
plt.yticks(fontsize=fsize);
# Bottom plot
ax3 = plt.subplot(313);
plt.plot(x3,y3, "go-", label=d3);
plt.grid();
plt.xlabel(xlabel);
plt.ylabel(ylabel3, fontsize=fsize);
# Legend
box = ax3.get_position()
ax3.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg3 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame3 = leg3.get_frame();
frame3.set_facecolor("0.80");
for t in leg3.get_texts():
t.set_fontsize(flegsize);
# end for
plt.xticks(fontsize=fsize);
plt.yticks(fontsize=fsize);
# Either save the plot to a file or display it to the screen
if (len(filename) == 0):
plt.show();
else:
plt.savefig(filename);
plt.close();
# end if
# end def
def Two_Chart(x1, y1, x2, y2, xlabel, ylabel1, ylabel2, d1, d2, fsize, flegsize,
filename, box_expansion):
#
# Creates 2 vertical subplots with legends and 1 x-axis label at the
# the bottom
#
# x1 = x-axis data for top plot
# x2 = x-axis data for bottom plot
# y1 = y-axis data for top plot
# y2 = y-axis data for bottom plot
# xlabel = x-axis label (only on bottom plot)
# ylabel1 = label for top y-axis
# ylabel2 = label for bottom y-axis
# d1 = data label for top plot
# d2 = data label for bottom plot
# fsize = font size for tick labels
# flegsize = font size for legend labels
# filename = name of file for plot output
# box_expansion = expansion factor for legend
#
# Top plot
ax1 = plt.subplot(211);
plt.plot(x1,y1, "ro-", label=d1);
plt.grid();
plt.xlabel(" ");
plt.ylabel(ylabel1, fontsize=fsize);
ax1.set_xticklabels([]);
# Legend
box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame1 = leg1.get_frame();
frame1.set_facecolor("0.80");
for t in leg1.get_texts():
t.set_fontsize(flegsize);
# end for
# Bottom Plot
ax2 = plt.subplot(212);
plt.plot(x2,y2, "go-", label=d2);
plt.grid();
plt.xlabel(xlabel);
plt.ylabel(ylabel2, fontsize=fsize);
# Legend
box = ax2.get_position()
ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame2 = leg2.get_frame();
frame2.set_facecolor("0.80");
for t in leg2.get_texts():
t.set_fontsize(fsize);
# end for
if (len(filename) == 0):
plt.show();
else:
plt.savefig(filename);
plt.close();
# end if
# end def
def One_Chart(x, y, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion):
#
# Creates 1 chart with a legend and 1 x-axis label
#
# x = x-axis data
# y = y-axis data
# xlabel = x-axis label
# ylabel1 = label for y-axis
# d = data label
# fsize = Font size for tick marks and labels
# flegsize = Legend font size
# filename = name of file for plot output
# box_expansion = expansion factor for legend
#
ax1 = plt.subplot(111);
plt.plot(x,y, "go-", label=d);
plt.grid();
plt.xlabel(xlabel);
plt.ylabel(ylabel, fontsize=fsize);
# Legend
box = ax1.get_position()
ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame = leg1.get_frame();
frame.set_facecolor("0.80");
for t in leg1.get_texts():
t.set_fontsize(flegsize);
# end for
if (len(filename) == 0):
plt.show();
else:
plt.savefig(filename);
plt.close();
# end if
# end def
def plot1(iloop, iplot, combined_plots, f, dirname, x_seconds, user_list, system_list,
nice_list, fsize, item):
#
# Figure 1: Various CPU percentages (user, system, nice) vs. time (3 subplots)
#
junk1 = "cpu_utilization" + str(iloop);
if (combined_plots == 0):
output_str = "<H4> \n";
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Percentage CPU Time (CPU Utilization)</a>";
output_str = output_str + ". Device: " + item["device"] + " \n";
output_str = output_str + "</H4> \n";
elif (combined_plots == 1):
output_str = "<H3> \n";
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Percentage CPU Time (CPU Utilization)</a>";
output_str = output_str + "</H3> \n";
#end if
output_str = output_str + " \n";
output_str = output_str + "<P> \n";
output_str = output_str + "This figure plots three types of CPU Utilization: (1) User, \n";
output_str = output_str + "(2) System, and (3) Nice. The User utilization is the percentage \n";
output_str = output_str + "of CPU utilization that occurred while executing at the user level \n";
output_str = output_str + "(applications).The System utilization is the percentage of CPU \n";
output_str = output_str + "utilization that occurred while executing at the system level \n";
output_str = output_str + "(kernel). The third time is the Nice utilization which is the \n";
output_str = output_str + "percentage of CPU utilization that occurred while executing at \n";
output_str = output_str + "the user level with nice priority. \n";
f.write(output_str);
# make the plot
ylabel1 = "% CPU Utilization \n by User tasks";
ylabel2 = "% CPU Utilization \n by System tasks";
ylabel3 = "% CPU Utilization \n by Nice tasks";
xlabel = "Time (seconds)";
d1 = "User";
d2 = "System";
d3 = "Nice";
filename = dirname + "/percentage_cpu_utilization" + str(iloop);
fsize = 8;
flegsize = 6;
# Compute box_expansion factor:
box_expansion = 0.95; # Default
ilongest = 0;
if (len(d1) > ilongest):
ilongest = len(d1);
# end if
if (len(d2) > ilongest):
ilongest = len(d2);
# end if
if (len(d3) > ilongest):
ilongest = len(d3);
# end if
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
Three_Chart(x_seconds, user_list, x_seconds, system_list, x_seconds, nice_list,
xlabel, ylabel1, ylabel2, ylabel3, d1, d2, d3, fsize, flegsize,
filename, box_expansion);
# HTML Output: (Figure html)
output_str = "<center> \n";
junk1 = "percentage_cpu_utilization" + str(iloop) + ".png";
output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
if (combined_plots == 0):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Utilization (User, System, and Nice) for device: " + item["device"] + "</strong></center><BR><BR> \n";
elif (combined_plots == 1):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Utilization (User, System, and Nice) for device </strong></center><BR><BR> \n";
#end if
output_str = output_str + "<BR><BR> \n";
output_str = output_str + "</P> \n \n";
f.write(output_str);
# end def
def plot2(iloop, iplot, combined_plots, f, dirname, x_seconds, iowait_list,
fsize, item):
#
# Figure 2: iowait percentage time
#
junk1 = "iowait_cpu_utilization" + str(iloop);
if (combined_plots == 0):
output_str = "<H4> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">IOWait Percentage Time</a>";
output_str = output_str + ". Device: " + item["device"] + " \n";
output_str = output_str + "</H4> \n";
elif(combined_plots == 1):
output_str = "<H3> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">IOWait Percentage Time</a>";
output_str = output_str + "</H3> \n";
# end if
output_str = output_str + " \n";
output_str = output_str + "<P> \n";
output_str = output_str + "This is the percentage of time that the CPU or CPUs were idle \n";
output_str = output_str + "during which the system had an outstanding disk device I/O request. \n";
f.write(output_str);
# make the plot
ylabel = "% IOwait CPU Percentage Time \n Waiting for IO requests";
xlabel = "Time (seconds)";
d = "IOwait";
filename = dirname + "/iowait_percentage_cpu_time" + str(iloop);
fsize = 8;
flegsize = 6;
# Compute box_expansion factor:
box_expansion = 0.96;
ilongest = 0;
if (len(d) > ilongest):
ilongest = len(d);
# end if
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
One_Chart(x_seconds, iowait_list, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion);
# HTML Output:
output_str = "<center> \n";
junk1 = "iowait_percentage_cpu_time" + str(iloop) + ".png";
output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
if (combined_plots == 0):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time waiting to process disk requests for device: " + item["device"] + "</strong></center><BR><BR> \n";
elif (combined_plots == 1):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time waiting to process disk requests </strong></center><BR><BR> \n";
# end if
output_str = output_str + "<BR><BR> \n";
output_str = output_str + "</P> \n \n";
f.write(output_str);
# end def
def plot3(iloop, iplot, combined_plots, f, dirname, x_seconds, steal_list,
fsize, item):
#
# Figure 3: Steal Time
#
junk1 = "steal_cpu_utilization" + str(iloop);
if (combined_plots == 0):
output_str = "<H4> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Steal Percentage Time</a>";
output_str = output_str + ". Device: " + item["device"] + " \n";
output_str = output_str + "</H4> \n";
elif (combined_plots == 1):
output_str = "<H3> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Steal Percentage Time</a>";
output_str = output_str + "</H3> \n";
# end if
output_str = output_str + " \n";
output_str = output_str + "<P> \n";
output_str = output_str + "This is the percentage of time spent in involuntary \n";
output_str = output_str + "wait by the virtual CPU or CPUs while the hypervisor was \n";
output_str = output_str + "servicing another virtual processor. \n";
f.write(output_str);
# make the plot
ylabel = "% Steal CPU Percentage Time \n Waiting for IO requests";
xlabel = "Time (seconds)";
d = "Steal";
filename = dirname + "/steal_percentage_cpu_time" + str(iloop);
fsize = 8;
flegsize = 6;
# Compute box_expansion factor:
box_expansion = 0.96;
ilongest = 0;
if (len(d) > ilongest):
ilongest = len(d);
# end if
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
One_Chart(x_seconds, steal_list, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion);
# HTML Output:
output_str = "<center> \n";
junk1 = "steal_percentage_cpu_time" + str(iloop) + ".png";
output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
if (combined_plots == 0):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in involuntary waiting for device: " + item["device"] + "</strong></center><BR><BR> \n";
elif (combined_plots == 1):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in involuntary waiting </strong></center><BR><BR> \n";
# end if
output_str = output_str + "<BR><BR> \n";
output_str = output_str + "</P> \n \n";
f.write(output_str);
# end def
def plot4(iloop, iplot, combined_plots, f, dirname, x_seconds, idle_list,
fsize, item):
#
# Figure 4: Idle Time
#
junk1 = "idle_cpu_utilization" + str(iloop);
if (combined_plots == 0):
output_str = "<H4> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Idle Percentage Time with no IO requests</a>";
output_str = output_str + ". Device: " + item["device"] + " \n";
output_str = output_str + "</H4> \n";
elif(combined_plots == 1):
output_str = "<H3> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Idle Percentage Time with no IO requests</a>";
output_str = output_str + "</H3> \n";
# end if
output_str = output_str + " \n";
output_str = output_str + "<P> \n";
output_str = output_str + "This is the percentage of time that the CPU or CPUs were \n";
output_str = output_str + "idle and the system did not have an outstanding disk I/O request. \n";
f.write(output_str);
# make the plot
ylabel = "% Idle CPU Percentage Time \n and no Waiting for IO requests";
xlabel = "Time (seconds)";
d = "Idle";
filename = dirname + "/idle_percentage_cpu_time" + str(iloop);
fsize = 8;
flegsize = 6;
# Compute box_expansion factor:
box_expansion = 0.97;
ilongest = 0;
if (len(d) > ilongest):
ilongest = len(d);
# end if
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
One_Chart(x_seconds, idle_list, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion);
# HTML Output:
output_str = "<center> \n";
junk1 = "idle_percentage_cpu_time" + str(iloop) + ".png";
output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
if (combined_plots == 0):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in idle activities with no IO requests for device: " + item["device"] + "</strong></center><BR><BR> \n";
elif (combined_plots == 1):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in idle activities with no IO requests </strong></center><BR><BR> \n";
# end if
output_str = output_str + "<BR><BR> \n";
output_str = output_str + "</P> \n \n";
f.write(output_str);
# end if
def plot5(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
fsize, item, device_data_list, line_list):
#
# Figure 5: Read Throughput and Total CPU Utilization
#
junk1 = "rmb_total_cpu" + str(iloop);
if (combined_plots == 0):
output_str = "<H4> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Throughput and Total CPU Utilization</a>";
output_str = output_str + ". Device: " + item["device"] + " \n";
output_str = output_str + "</H4> \n";
elif (combined_plots == 1):
output_str = "<H3> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Throughput and Total CPU Utilization</a>";
output_str = output_str + "</H3> \n";
# end if
output_str = output_str + " \n";
output_str = output_str + "<P> \n";
output_str = output_str + "This figure has two parts. The top graph plots the Read Rate \n";
output_str = output_str + "in MB/s versus time and the bottom graph plots the Total CPU \n";
output_str = output_str + "Utilization percentage (User Time + System Time). \n";
f.write(output_str);
# make the plot
ylabel1 = "Read Throughput (MB/s)";
ylabel2 = "Total CPU Percentage Utilization";
xlabel = "Time (seconds)";
d1 = "Read Throughput";
d2 = "Total CPU Util";
filename = dirname + "/read_throughput" + str(iloop);
fsize = 8;
flegsize = 6;
if (combined_plots == 0):
# Compute box_expansion factor:
box_expansion = 0.88; # default
ilongest = 0;
if (len(d1) > ilongest):
ilongest = len(d1);
# end if
if (len(d2) > ilongest):
ilongest = len(d2);
# end if
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
Two_Chart(x_seconds, item["rMB"], x_seconds, time_sum_list, xlabel, ylabel1,
ylabel2, d1, d2, fsize, flegsize, filename, box_expansion);
elif (combined_plots == 1):
jloop = -1;
# Compute expansion_box factor:
box_expansion = 0.88; # default
ilongest = 0;
for item in device_data_list:
if (len(d1) > ilongest):
ilongest = len(d1);
# end if
d11 = item["device"] + " " + d1;
if (len(d11) > ilongest):
ilongest = len(d11);
# end if
if (len(d2) > ilongest):
ilongest = len(d2);
# end if
d22 = item["device"] + " " + d2;
if (len(d22) > ilongest):
ilongest = len(d22);
# end if
# end for
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
# Top plot
for item in device_data_list:
jloop = jloop + 1;
marker = line_list[jloop];
ax1 = plt.subplot(211);
d11 = item["device"] + " " + d1;
plt.plot(x_seconds, item["rMB"], marker, label=d11);
plt.xlabel(" ");
plt.ylabel(ylabel1, fontsize=fsize);
ax1.set_xticklabels([]);
# end for
plt.grid();
# Legend
box = ax1.get_position();
ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height]);
leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame1 = leg1.get_frame();
frame1.set_facecolor("0.80");
for t in leg1.get_texts():
t.set_fontsize(flegsize);
# end for
# Bottom Plot
fsize = 8;
flegsize = 6;
ax2 = plt.subplot(212);
plt.plot(x_seconds, time_sum_list, "go-", label=d2);
plt.grid();
plt.xlabel(xlabel);
plt.ylabel(ylabel2, fontsize=fsize);
# Legend
box = ax2.get_position()
ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0.0, labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame2 = leg2.get_frame();
frame2.set_facecolor("0.80");
for t in leg2.get_texts():
t.set_fontsize(flegsize);
# end for
if (len(filename) == 0):
plt.show();
else:
plt.savefig(filename);
plt.close();
# end if
# end if
# HTML Output:
output_str = "<center> \n";
junk1 = "read_throughput" + str(iloop) + ".png";
output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
if (combined_plots == 0):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Throughput (MB/s) and Total CPU Utilization Percentage for device: " + item["device"] + "</strong></center><BR><BR> \n";
if (combined_plots == 1):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Throughput (MB/s) and Total CPU Utilization Percentage </strong></center><BR><BR> \n";
# end if
output_str = output_str + "<BR><BR> \n";
output_str = output_str + "</P> \n \n";
f.write(output_str);
# end if
def plot6(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
fsize, item, device_data_list, line_list):
#
# Figure 6: Write Throughput and Total CPU Utilization
#
junk1 = "wmb_total_cpu" + str(iloop);
if (combined_plots == 0):
output_str = "<H4> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Write Throughput and Total CPU Utilization</a>";
output_str = output_str + ". Device: " + item["device"] + " \n";
output_str = output_str + "</H4> \n";
elif (combined_plots == 1):
output_str = "<H3> \n"
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Write Throughput and Total CPU Utilization</a>";
output_str = output_str + "</H3> \n";
# end if
output_str = output_str + " \n";
output_str = output_str + "<P> \n";
output_str = output_str + "This figure has two parts. The top graph plots the Write Rate \n";
output_str = output_str + "in MB/s versus time and the bottom graph plots the Total CPU \n";
output_str = output_str + "Utilization percentage (User Time + System Time). \n";
f.write(output_str);
# make the plot
ylabel1 = "Write Throughput (MB/s)";
ylabel2 = "Total CPU Percentage Utilization";
xlabel = "Time (seconds)";
d1 = "Write Throughput";
d2 = "Total CPU Utilization";
filename = dirname + "/write_throughput" + str(iloop);
fsize = 8;
flegsize = 6;
if (combined_plots == 0):
# Compute box_expansion factor:
box_expansion = 0.82; # default
ilongest = 0;
if (len(d1) > ilongest):
ilongest = len(d1);
# end if
if (len(d2) > ilongest):
ilongest = len(d2);
# end if
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
Two_Chart(x_seconds, item["wMB"], x_seconds, time_sum_list, xlabel, ylabel1,
ylabel2, d1, d2, fsize, flegsize, filename, box_expansion);
elif (combined_plots == 1):
jloop = -1;
# Compute box_expansion factor:
box_expansion = 0.88; # Default
ilongest = 0;
for item in device_data_list:
if (len(d1) > ilongest):
ilongest = len(d1);
# end if
d11 = item["device"] + " " + d1;
if (len(d11) > ilongest):
ilongest = len(d11);
# end if
if (len(d2) > ilongest):
ilongest = len(d2);
# end if
d22 = item["device"] + " " + d2;
if (len(d22) > ilongest):
ilongest = len(d22);
# end if
# end for
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
# Top plot
for item in device_data_list:
jloop = jloop + 1;
marker = line_list[jloop];
ax1 = plt.subplot(211);
d11 = item["device"] + " " + d1;
plt.plot(x_seconds, item["wMB"], marker, label=d11);
plt.xlabel(" ");
plt.ylabel(ylabel1, fontsize=fsize);
ax1.set_xticklabels([]);
# end for
plt.grid();
# Legend
box = ax1.get_position();
ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame1 = leg1.get_frame();
frame1.set_facecolor("0.80");
for t in leg1.get_texts():
t.set_fontsize(flegsize);
# end for
# Bottom Plot
ax2 = plt.subplot(212);
plt.plot(x_seconds, time_sum_list, "go-", label=d2);
plt.grid();
plt.xlabel(xlabel);
plt.ylabel(ylabel2, fontsize=fsize);
# Legend
box = ax2.get_position()
ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
borderpad=0.15, handletextpad=0.2);
frame2 = leg2.get_frame();
frame2.set_facecolor("0.80");
for t in leg2.get_texts():
t.set_fontsize(flegsize);
# end for
if (len(filename) == 0):
plt.show();
else:
plt.savefig(filename);
plt.close();
# end if
# end if
# HTML Output:
output_str = "<center> \n";
junk1 = "write_throughput" + str(iloop) + ".png";
output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
if (combined_plots == 0):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Write Throughput (MB/s) and Total CPU Utilization Percentage for device: " + item["device"] + "</strong></center><BR><BR> \n";
elif (combined_plots == 1):
output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Write Throughput (MB/s) and Total CPU Utilization Percentage </strong></center><BR><BR> \n";
# end if
output_str = output_str + "<BR><BR> \n";
output_str = output_str + "</P> \n \n";
f.write(output_str);
# end def
def plot7(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
fsize, item, device_data_list, line_list):
#
# Figure 7: Read Request complete rate, Write Request complete rate, and Total CPU Utilization
#
if (combined_plots == 0):
output_str = "<H4> \n"
junk1 = "requests_complete_total_cpu" + str(iloop);
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Requests Complete, Write Requests Complete, and Total CPU Utilization</a>";
output_str = output_str + ". Device: " + item["device"] + " \n";
output_str = output_str + "</H4> \n";
elif (combined_plots == 1):
output_str = "<H3> \n"
junk1 = "requests_complete_total_cpu" + str(iloop);
output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Requests Complete, Write Requests Complete, and Total CPU Utilization</a>";
output_str = output_str + "</H3> \n";
# end if
output_str = output_str + " \n";
output_str = output_str + "<P> \n";
output_str = output_str + "This figure has three parts. The top graph plots the number (after \n";
output_str = output_str + "merges) of read requests completed per second for the device \n";
output_str = output_str + "versus time. The middle graph plots the number (after merges) \n";
output_str = output_str + "of write requests completed per second for the device versus time. \n";
output_str = output_str + "The bottom graph plots the Total CPU Utilization percentage \n";
output_str = output_str + "(User Time + System Time). \n";
f.write(output_str);
# make the plot
ylabel1 = "Read requests \n complete rate \n (requests/s)";
ylabel2 = "Write requests \n complete rate \n (requests/s)";
ylabel3 = "Total CPU \n Percentage \n Utilization";
xlabel = "Time (seconds)";
d1 = "Read reqs complete";
d2 = "Write reqs complete";
d3 = "Total CPU Utilization";
filename = dirname + "/read_write_requests_complete_rate" + str(iloop);
fsize = 8;
flegsize = 6;
if (combined_plots == 0):
# Compute box_expansion factor:
box_expansion = 0.86; # default
ilongest = 0;
if (len(d1) > ilongest):
ilongest = len(d1);
# end if
if (len(d2) > ilongest):
ilongest = len(d2);
# end if
if (len(d3) > ilongest):
ilongest = len(d3);
# end if
junk1 = -0.0082702674*ilongest + 1.0538027948; # Curve fit of # chars vs. expansion box
expansion_box = round(junk1,2);
Three_Chart(x_seconds, item["r"], x_seconds, item["w"], x_seconds, time_sum_list, xlabel, ylabel1,
ylabel2, ylabel3, d1, d2, d3, fsize, flegsize, filename, box_expansion);
elif (combined_plots == 1):
jloop = -1;
# Compute box_expansion factor:
expansion_box = 0.86; # default
ilongest = 0;
for item in device_data_list:
if (len(d1) > ilongest):
ilongest = len(d1);
# end if
d11 = item["device"] + " " + d1;
if (len(d11) > ilongest):
ilongest = len(d11);
# end if
if (len(d2) > ilongest):
ilongest = len(d2);
# end if
d22 = item["device"] + " " + d2;
if (len(d22) > ilongest):
ilongest = len(d22);
# end if
if (len(d3) > ilongest):
ilongest = len(d3);
# end if