Skip to content

Remove hard code mapping in dstat tool, Resolves git issue #2017 #2218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions qa/1207
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15

# real QA test starts here
pcp --archive archives/dstat-disks dstat --disk --nocolor
echo " - - - - - - - - - "
pcp --archive archives/dstat-disks dstat --disk-util --nocolor
status=$?
exit
4 changes: 4 additions & 0 deletions qa/1207.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ QA output created by 1207
-dsk/total-
read writ
0 0
- - - - - - - - -
tota
util
0
7 changes: 7 additions & 0 deletions src/pcp/dstat/pcp-dstat.5
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ For example it is common to exclude loopback devices from the
network interface reports, this is achieved using this option.
Default is to report on all instances (no culling).
.RE
.PP
filtertype (string)
.RS 4
Used for plugin metrics that want to use instance grouping.
The value of the filtertype entry should match the name of
the plugin.
.RE
.SS The [plugin] metrics
Each plugin must have at least one metric associated with it.
Any key that is not one of the above global plugin options is
Expand Down
48 changes: 25 additions & 23 deletions src/pcp/dstat/pcp-dstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def __init__(self, label):
self.names = [] # list of all column names for the plugin
self.mgroup = [] # list of names of metrics in this plugin
self.igroup = [] # list of names of this plugins instances
self.filtertype = None

def apply(self, metric):
""" Apply default pmConfig list values where none exist as yet
Expand Down Expand Up @@ -282,6 +283,7 @@ def apply(self, metric):
metric[12] = self.cullinsts
metric[13] = self # back-pointer to this from metric dict
metric[14] = self.valuesets # recent samples for averaging
metric[15] = self.filtertype # filtertype for plugin

def prepare_grouptype(self, instlist, fullinst):
"""Setup a list of instances from the command line"""
Expand Down Expand Up @@ -444,7 +446,7 @@ def __init__(self, arguments):

### Add additional dstat metric specifiers
dspec = (None, 'printtype', 'colorstep', 'grouptype', 'cullinsts',
'plugin', 'valuesets')
'plugin', 'valuesets', 'filtertype')
mspec = self.pmconfig.metricspec + dspec
self.pmconfig.metricspec = mspec

Expand Down Expand Up @@ -525,7 +527,7 @@ def __init__(self, arguments):
# values - 0:text label, 1:instance(s), 2:unit/scale, 3:type,
# 4:width, 5:pmfg item, 6:precision, 7:limit,
# [ 8:printtype, 9:colorstep, 10:grouptype, 11:cullinsts,
# 12:plugin, 13:valuesets <- Dstat extras ]
# 12:plugin, 13:valuesets <- Dstat extras, 14: filtertype]
self.metrics = OrderedDict()
self.pmfg = None
self.pmfg_ts = None
Expand Down Expand Up @@ -686,34 +688,34 @@ def prepare_metrics(self, config):
lib.parse_verbose_metric_info(metrics, name, 'label', mkey)
lib.parse_verbose_metric_info(metrics, name, spec, value)

# Instance logic for -C/-D/-L/-M/-P/-I/-N/-S options
if section == 'cpu':
plugin.prepare_grouptype(self.cpulist, self.full)
elif section in ['disk', 'disk-tps']:
plugin.prepare_grouptype(self.disklist, self.full)
elif section in ['dm', 'dm-tps']:
plugin.prepare_grouptype(self.dmlist, self.full)
elif section in ['md', 'md-tps']:
plugin.prepare_grouptype(self.mdlist, self.full)
elif section in ['part', 'part-tps']:
plugin.prepare_grouptype(self.partlist, self.full)
elif section == 'int':
plugin.prepare_grouptype(self.intlist, self.full)
elif section == 'net':
plugin.prepare_grouptype(self.netlist, self.full)
elif section == 'net-packets':
plugin.prepare_grouptype(self.netpacketlist, self.full)
elif section == 'swap':
plugin.prepare_grouptype(self.swaplist, self.full)
if key in ['filtertype']:
if value == 'cpu':
plugin.prepare_grouptype(self.cpulist, self.full)
elif value == 'disk':
plugin.prepare_grouptype(self.disklist, self.full)
elif value == 'dm':
plugin.prepare_grouptype(self.dmlist, self.full)
elif value == 'md':
plugin.prepare_grouptype(self.mdlist, self.full)
elif value == 'part':
plugin.prepare_grouptype(self.partlist, self.full)
elif value == 'int':
plugin.prepare_grouptype(self.intlist, self.full)
elif value == 'net':
plugin.prepare_grouptype(self.netlist, self.full)
elif value == 'net-packets':
plugin.prepare_grouptype(self.netpacketlist, self.full)
elif value == 'swap':
plugin.prepare_grouptype(self.swaplist, self.full)

for metric in metrics:
name = metrics[metric][0]
#print("Plugin[%s]: %s" % (name, metrics[metric]))
#print("Plugin[%s]: %s\n" % (name, metrics[metric]))
plugin.apply(metrics[metric])
state = metrics[metric][1:]
plugin.metrics.append(state)
self.metrics[name] = state
#print("Appended[%s]: %s" % (name, state))
#print("Appended[%s]: %s\n" % (name, state))

self.totlist.append(plugin)

Expand Down
1 change: 1 addition & 0 deletions src/pcp/dstat/plugins/cpu
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ precision = 0
printtype = p
colorstep = 34
grouptype = 2
filtertype = cpu
usr = 100 * (rate(kernel.percpu.cpu.user) + rate(kernel.percpu.cpu.nice) + rate(kernel.percpu.cpu.irq.soft) + rate(kernel.percpu.cpu.irq.hard))
sys = 100 * rate(kernel.percpu.cpu.sys)
idl = 100 * rate(kernel.percpu.cpu.idle)
Expand Down
7 changes: 7 additions & 0 deletions src/pcp/dstat/plugins/disk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ label = dsk/%I
printtype = b
precision = 0
grouptype = 2
filtertype = disk
reads = disk.dev.read_bytes
reads.label = read
writes = disk.dev.write_bytes
Expand All @@ -18,6 +19,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = disk
avgqu = disk.dev.aveq

[disk-avgrq]
Expand All @@ -26,6 +28,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = disk
avgrq = (delta(disk.dev.read_bytes) + delta(disk.dev.write_bytes)) / (delta(disk.dev.read) + delta(disk.dev.write))

[disk-svctm]
Expand All @@ -34,13 +37,15 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = disk
svctm = (delta(disk.dev.avactive) / 1000 / 2) / (delta(disk.dev.read) + delta(disk.dev.write))

[disk-tps]
label = dsk/%I
width = 5
printtype = d
grouptype = 2
filtertype = disk
reads = disk.dev.read
reads.label = #read
writes = disk.dev.write
Expand All @@ -52,6 +57,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 34
filtertype = disk
util = 100 * rate(disk.dev.avactive)

[disk-wait]
Expand All @@ -60,6 +66,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = disk
rawait = delta(disk.dev.read_rawactive) / delta(disk.dev.read)
wawait = delta(disk.dev.write_rawactive) / delta(disk.dev.write)

7 changes: 7 additions & 0 deletions src/pcp/dstat/plugins/dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ label = %I
printtype = b
precision = 0
grouptype = 2
filtertype = dm
reads = disk.dm.read_bytes
reads.label = read
writes = disk.dm.write_bytes
Expand All @@ -18,6 +19,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = dm
avgqu = disk.dm.aveq

[dm-avgrq]
Expand All @@ -26,6 +28,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = dm
avgrq = (delta(disk.dm.read_bytes) + delta(disk.dm.write_bytes)) / (delta(disk.dm.read) + delta(disk.dm.write))

[dm-svctm]
Expand All @@ -34,13 +37,15 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = dm
svctm = (delta(disk.dm.avactive) / 1000 / 2) / (delta(disk.dm.read) + delta(disk.dm.write))

[dm-tps]
label = %I
width = 5
printtype = d
grouptype = 2
filtertype = dm
reads = disk.dm.read
reads.label = #read
writes = disk.dm.write
Expand All @@ -52,6 +57,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 34
filtertype = dm
util = 100 * rate(disk.dm.avactive)

[dm-wait]
Expand All @@ -60,6 +66,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = dm
rawait = delta(disk.dm.read_rawactive) / delta(disk.dm.read)
wawait = delta(disk.dm.write_rawactive) / delta(disk.dm.write)

1 change: 1 addition & 0 deletions src/pcp/dstat/plugins/int
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ label = interrupts
width = 4
printtype = d
grouptype = 2
filtertype = int
int = kernel.all.interrupts.total
int.label = %I
7 changes: 7 additions & 0 deletions src/pcp/dstat/plugins/md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ label = dsk/%I
printtype = b
precision = 0
grouptype = 2
filtertype = md
reads = disk.md.read_bytes
reads.label = read
writes = disk.md.write_bytes
Expand All @@ -18,6 +19,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = md
avgqu = disk.md.aveq

[md-avgrq]
Expand All @@ -26,6 +28,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = md
avgrq = (delta(disk.md.read_bytes) + delta(disk.md.write_bytes)) / (delta(disk.md.read) + delta(disk.md.write))

[md-svctm]
Expand All @@ -34,13 +37,15 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = md
svctm = (delta(disk.md.avactive) / 1000 / 2) / (delta(disk.md.read) + delta(disk.md.write))

[md-tps]
label = dsk/%I
width = 5
printtype = d
grouptype = 2
filtertype = md
reads = disk.md.read
reads.label = #read
writes = disk.md.write
Expand All @@ -52,6 +57,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 34
filtertype = md
util = 100 * rate(disk.md.avactive)

[md-wait]
Expand All @@ -60,6 +66,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = md
rawait = delta(disk.md.read_rawactive) / delta(disk.md.read)
wawait = delta(disk.md.write_rawactive) / delta(disk.md.write)

2 changes: 2 additions & 0 deletions src/pcp/dstat/plugins/net
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ label = net/%I
width = 5
printtype = b
cullinsts = ^(?:lo|bond\d+|team\d+|face|.+\.\d+)$
filtertype = net
bits_in.label = recv
bits_in = network.interface.in.bytes
bits_out.label = send
Expand All @@ -18,6 +19,7 @@ width = 5
printtype = d
pkts_in.label = #recv
cullinsts = ^(?:lo|bond\d+|team\d+|face|.+\.\d+)$
filtertype = net
pkts_in = network.interface.in.packets
pkts_out.label = #send
pkts_out = network.interface.out.packets
Expand Down
7 changes: 7 additions & 0 deletions src/pcp/dstat/plugins/part
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ label = dsk/%I
printtype = b
precision = 0
grouptype = 2
filtertype = part
reads = disk.partitions.read_bytes
reads.label = read
writes = disk.partitions.write_bytes
Expand All @@ -18,6 +19,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = part
avgqu = disk.partitions.aveq

[part-avgrq]
Expand All @@ -26,6 +28,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 10
filtertype = part
avgrq = (delta(disk.partitions.read_bytes) + delta(disk.partitions.write_bytes)) / (delta(disk.partitions.read) + delta(disk.partitions.write))

[part-svctm]
Expand All @@ -34,13 +37,15 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = part
svctm = (delta(disk.partitions.avactive) / 1000 / 2) / (delta(disk.partitions.read) + delta(disk.partitions.write))

[part-tps]
label = dsk/%I
width = 5
printtype = d
grouptype = 2
filtertype = part
reads = disk.partitions.read
reads.label = #read
writes = disk.partitions.write
Expand All @@ -52,6 +57,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 34
filtertype = part
util = 100 * rate(disk.partitions.avactive)

[part-wait]
Expand All @@ -60,6 +66,7 @@ width = 4
grouptype = 1
printtype = f
colorstep = 1
filtertype = part
rawait = delta(disk.partitions.read_rawactive) / delta(disk.partitions.read)
wawait = delta(disk.partitions.write_rawactive) / delta(disk.partitions.write)

1 change: 1 addition & 0 deletions src/pcp/dstat/plugins/swap
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

[swap]
label = %I
filtertype = swap
used = swapdev.length - swapdev.free
free = swapdev.free
Loading