[go: up one dir, main page]

Menu

[b40542]: / misc / iostat-plot.mk  Maximize  Restore  History

Download this file

167 lines (147 with data), 6.3 kB

  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
############################################################################
# misc/iostat-plot.mk
#
# Part of the STXXL. See http://stxxl.sourceforge.net
#
# Copyright (C) 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
############################################################################
#
# to record the data, include this file from your Makefile
# and use a target like
#
# my_results.out:
# $(IOSTAT_PLOT_RECORD_DATA) -p $(@:.out=) \
# my_program arg1 ... argn > $@
#
# and then run
#
# make my_results.out
# make my_results.io.plot
# make my_results.cpu.plot
#
empty ?=#
space ?= $(empty) $(empty)
comma ?= ,
IOSTAT_PLOT_BINDIR ?= .
IOSTAT_PLOT_RECORD_DATA ?= $(IOSTAT_PLOT_BINDIR)/record-load-iostat
IOSTAT_PLOT_CONCAT_LINES ?= $(IOSTAT_PLOT_BINDIR)/concat-lines
IOSTAT_PLOT_FLOATING_AVERAGE ?= $(IOSTAT_PLOT_BINDIR)/floating-average
IOSTAT_PLOT_LINE_IDENTIFIER ?= ^sd
IOSTAT_PLOT_CPU_LINE_IDENTIFIER ?= ^$(space)$(space)$(space)
IOSTAT_PLOT_DISKS ?= 8
IOSTAT_PLOT_CPUS ?= 8
IOSTAT_PLOT_STRIDE ?= 12
IOSTAT_PLOT_AVERAGE ?= 1
IOSTAT_PLOT_AVERAGE.io ?= $(IOSTAT_PLOT_AVERAGE)
IOSTAT_PLOT_AVERAGE.cpu ?= $(IOSTAT_PLOT_AVERAGE)
IOSTAT_PLOT_LOAD_REDUCE ?= 0
IOSTAT_PLOT_OFFSET_read_12 ?= 6
IOSTAT_PLOT_OFFSET_write_12 ?= 7
IOSTAT_PLOT_OFFSET_utilize_12 ?= 12
IOSTAT_PLOT_OFFSET_read_14 ?= 8
IOSTAT_PLOT_OFFSET_write_14 ?= 9
IOSTAT_PLOT_OFFSET_utilize_14 ?= ???
IOSTAT_PLOT_DISK_LIST ?= sda sdb sdc sdd sde sdf sdg sdh sdi sdj
IOSTAT_PLOT_IO_WITH_UTILIZATION ?= no
IOSTAT_PLOT_Y_LABEL.io ?= Bandwidth [MiB/s]
IOSTAT_PLOT_Y_LABEL.cpu ?= CPU Usage [%]
ECHO ?= echo
# $1 = first, $2 = increment, $3 = last
define gnuplot-column-sequence-sum
$(subst $(space),+,$(patsubst %,$$%,$(shell seq $1 $2 $3)))
endef
# $1 = io | cpu, $2 = numdisks (io) | numcpus (cpu), $3 = stride
define template-iostat-gnuplot
$(RM) $@
$(ECHO) 'set title "$(subst _, ,$*) (avg=$(IOSTAT_PLOT_AVERAGE.$(strip $1)))"' >> $@
$(ECHO) 'set xlabel "Time [s]"' >> $@
$(ECHO) 'set ylabel "$(IOSTAT_PLOT_Y_LABEL.$(strip $1))"' >> $@
$(if $(filter yes,$(IOSTAT_PLOT_IO_WITH_UTILIZATION)),
$(ECHO) 'set y2label "Utilization [%]"' >> $@
$(ECHO) 'set ytics nomirror' >> $@
$(ECHO) 'set y2tics' >> $@
,$(if $(wildcard $*.waitlog),
$(ECHO) 'set y2label "Wait Time [s]"' >> $@
$(ECHO) 'set ytics nomirror' >> $@
$(ECHO) 'set y2tics' >> $@
))
# $(ECHO) 'set data style linespoints' >> $@
$(ECHO) 'set data style lines' >> $@
$(ECHO) 'set macros' >> $@
$(ECHO) 'set pointsize 0.4' >> $@
# $(ECHO) 'set samples 1000' >> $@
$(ECHO) 'set key top left' >> $@
$(ECHO) 'set yrange [0:]' >> $@
$(ECHO) '' >> $@
$(if $(filter io,$1),
$(ECHO) 'read = "$(call gnuplot-column-sequence-sum, $(IOSTAT_PLOT_OFFSET_read_$3), $3, $(shell expr $2 '*' $3))"' >> $@
$(ECHO) 'write = "$(call gnuplot-column-sequence-sum, $(IOSTAT_PLOT_OFFSET_write_$3), $3, $(shell expr $2 '*' $3))"' >> $@
$(ECHO) 'utilize = "($(call gnuplot-column-sequence-sum, $(IOSTAT_PLOT_OFFSET_utilize_$3), $3, $(shell expr $2 '*' $3))) / $2"' >> $@
$(ECHO) '' >> $@
$(ECHO) 'plot \' >> $@
$(ECHO) ' "$<" using 0:(@read + @write) title "Read + Write" ls 3$(comma) \' >> $@
$(ECHO) ' "$<" using 0:(@read) title "Read" ls 2$(comma) \' >> $@
$(ECHO) ' "$<" using 0:(@write) title "Write" ls 1$(comma) \' >> $@
$(if $(filter yes,$(IOSTAT_PLOT_IO_WITH_UTILIZATION)),
$(ECHO) ' "$<" using 0:(@utilize) title "Utilization" ls 5 axes x1y2$(comma) \' >> $@
,$(if $(wildcard $*.waitlog),
$(ECHO) ' "$*.waitlog" using 1:4 title "Wait Read" ls 5 axes x1y2$(comma) \' >> $@
$(ECHO) ' "$*.waitlog" using 1:5 title "Wait Write" ls 4 axes x1y2$(comma) \' >> $@
))
$(ECHO) ' "not.existing.dummy" using 08:15 notitle' >> $@
)
$(if $(filter cpu,$1),
$(ECHO) 'plot \' >> $@
$(ECHO) ' "$(word 2,$^)" using 0:(100*($$1-$(IOSTAT_PLOT_LOAD_REDUCE))/$(strip $2)) title "Load (100% = $2)" ls 5$(comma) \' >> $@
$(ECHO) ' "$<" using 0:($$1+$$3+$$4) title "Total" ls 4$(comma) \' >> $@
$(ECHO) ' "$<" using 0:4 title "Wait" ls 2$(comma) \' >> $@
$(ECHO) ' "$<" using 0:1 title "User" ls 1$(comma) \' >> $@
$(ECHO) ' "$<" using 0:3 title "System" ls 3$(comma) \' >> $@
$(ECHO) ' "not.existing.dummy" using 08:15 notitle' >> $@
)
$(ECHO) '' >> $@
$(ECHO) 'pause -1' >> $@
$(ECHO) '' >> $@
$(ECHO) 'set terminal postscript enhanced $(GPLT_COLOR_PS) 10' >> $@
$(ECHO) 'set output "$*.$(strip $1).eps"' >> $@
$(ECHO) 'replot' >> $@
$(ECHO) '' >> $@
endef
%.io-$(IOSTAT_PLOT_AVERAGE.io).dat: %.iostat $(MAKEFILE_LIST)
$(pipefail) \
$(IOSTAT_PLOT_CONCAT_LINES) $< $(IOSTAT_PLOT_LINE_IDENTIFIER) | \
grep "$(IOSTAT_PLOT_LINE_IDENTIFIER)" | \
$(IOSTAT_PLOT_FLOATING_AVERAGE) $(IOSTAT_PLOT_AVERAGE.io) > $@
define per-disk-plot-template
%.$(disk).io-$$(IOSTAT_PLOT_AVERAGE.io).dat: IOSTAT_PLOT_LINE_IDENTIFIER=^$(disk)
%.$(disk).io-$$(IOSTAT_PLOT_AVERAGE.io).plot: IOSTAT_PLOT_DISKS=1
%.$(disk).io-$$(IOSTAT_PLOT_AVERAGE.io).plot: IOSTAT_PLOT_IO_WITH_UTILIZATION=yes
%.$(disk).io-$$(IOSTAT_PLOT_AVERAGE.io).dat: %.iostat $$(MAKEFILE_LIST)
$$(pipefail) \
$$(IOSTAT_PLOT_CONCAT_LINES) $$< $$(IOSTAT_PLOT_LINE_IDENTIFIER) | \
grep "$$(IOSTAT_PLOT_LINE_IDENTIFIER)" | \
$$(IOSTAT_PLOT_FLOATING_AVERAGE) $$(IOSTAT_PLOT_AVERAGE.io) > $$@
endef
$(foreach disk, $(IOSTAT_PLOT_DISK_LIST),$(eval $(per-disk-plot-template)))
%.cpu-$(IOSTAT_PLOT_AVERAGE.cpu).dat: %.iostat $(MAKEFILE_LIST)
$(pipefail) \
grep "$(IOSTAT_PLOT_CPU_LINE_IDENTIFIER)" $< | \
$(IOSTAT_PLOT_FLOATING_AVERAGE) $(IOSTAT_PLOT_AVERAGE.cpu) > $@
%.io-$(IOSTAT_PLOT_AVERAGE.io).plot: %.io-$(IOSTAT_PLOT_AVERAGE.io).dat $(MAKEFILE_LIST)
$(call template-iostat-gnuplot,io,$(IOSTAT_PLOT_DISKS),$(IOSTAT_PLOT_STRIDE))
%.io.plot: %.io-$(IOSTAT_PLOT_AVERAGE.io).plot
@$(ECHO) Your plot file is: $<
%.cpu-$(IOSTAT_PLOT_AVERAGE.cpu).plot: %.cpu-$(IOSTAT_PLOT_AVERAGE.cpu).dat %.loadavg $(MAKEFILE_LIST)
$(call template-iostat-gnuplot,cpu,$(IOSTAT_PLOT_CPUS),$(IOSTAT_PLOT_STRIDE))
%.cpu.plot: %.cpu-$(IOSTAT_PLOT_AVERAGE.cpu).plot
@$(ECHO) Your plot file is: $<
%.io.xplot: %.io-$(IOSTAT_PLOT_AVERAGE.io).plot
gnuplot $<
%.cpu.xplot: %.cpu-$(IOSTAT_PLOT_AVERAGE.cpu).plot
gnuplot $<
.SECONDARY:
.DELETE_ON_ERROR: