Skip to content

Commit e8c391b

Browse files
committed
v2.2.7: add new metrics
1 parent 80e3728 commit e8c391b

File tree

6 files changed

+341
-20
lines changed

6 files changed

+341
-20
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ Metrics: Linux system
288288
'Block device {#BLOCKDEVICE}: utilization': system.disk.utilization[{#BLOCKDEVICE}]
289289
'Block device {#BLOCKDEVICE}: read operations': system.disk.read[{#BLOCKDEVICE}]
290290
'Block device {#BLOCKDEVICE}: write operations': system.disk.write[{#BLOCKDEVICE}]
291+
'Block device {#BLOCKDEVICE}: read byte/s': system.disk.read_b[{#BLOCKDEVICE}]
292+
'Block device {#BLOCKDEVICE}: write byte/s': system.disk.write_b[{#BLOCKDEVICE}]
291293
'Net device {#NETDEVICE}: RX bytes/s': system.net.rx_bytes[{#NETDEVICE}]
292294
'Net device {#NETDEVICE}: RX errors/s': system.net.rx_errors[{#NETDEVICE}]
293295
'Net device {#NETDEVICE}: RX drops/s': system.net.rx_drops[{#NETDEVICE}]

mamonsu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__author__ = 'Dmitry Vasilyev'
22
__author_email__ = '[email protected]'
33
__description__ = 'Monitoring agent for PostgreSQL'
4-
__version__ = '2.2.6'
4+
__version__ = '2.2.7'
55
__licence__ = 'BSD'
66

77
__url__ = 'https://github.com/postgrespro/mamonsu'

mamonsu/plugins/system/linux/disk_stats.py

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def run(self, zbx):
1919
with open('/proc/diskstats', 'r') as f:
2020

2121
devices = []
22-
all_read, all_write = 0, 0
22+
all_read_op, all_read_b, all_write_op, all_write_b, = 0, 0, 0, 0
2323

2424
for line in f:
2525
if re.search('(ram|loop)', line):
@@ -31,20 +31,30 @@ def run(self, zbx):
3131
if self.OnlyPhysicalDevices and re.search('\d+$', dev):
3232
continue
3333
val = [int(x) for x in val.split()]
34-
read, write, ticks = val[0], val[4], val[9]
35-
all_read += read
36-
all_write += write
37-
devices.append({'{#BLOCKDEVICE}': dev})
34+
read_op, read_sc, write_ops, write_sc, ticks = val[0], val[2], val[4], val[6], val[9]
35+
read_b, write_b = read_sc * 512, write_sc * 512 # https://github.com/sysstat/sysstat/blob/v11.5.2/iostat.c#L940
3836

3937
zbx.send('system.disk.read[{0}]'.format(
40-
dev), read, self.DELTA_SPEED)
38+
dev), read_op, self.DELTA_SPEED)
4139
zbx.send('system.disk.write[{0}]'.format(
42-
dev), write, self.DELTA_SPEED)
40+
dev), write_ops, self.DELTA_SPEED)
41+
zbx.send('system.disk.read_b[{0}]'.format(
42+
dev), read_b, self.DELTA_SPEED)
43+
zbx.send('system.disk.write_b[{0}]'.format(
44+
dev), write_b, self.DELTA_SPEED)
4345
zbx.send('system.disk.utilization[{0}]'.format(
4446
dev), ticks / 10, self.DELTA_SPEED)
4547

46-
zbx.send('system.disk.all_read[]', all_read, self.DELTA_SPEED)
47-
zbx.send('system.disk.all_write[]', all_write, self.DELTA_SPEED)
48+
all_read_op += read_op
49+
all_write_op += write_ops
50+
all_read_b += read_b
51+
all_write_b += write_b
52+
devices.append({'{#BLOCKDEVICE}': dev})
53+
54+
zbx.send('system.disk.all_read[]', all_read_op, self.DELTA_SPEED)
55+
zbx.send('system.disk.all_write[]', all_write_op, self.DELTA_SPEED)
56+
zbx.send('system.disk.all_read_b[]', all_read_b, self.DELTA_SPEED)
57+
zbx.send('system.disk.all_write_b[]', all_write_b, self.DELTA_SPEED)
4858
zbx.send('system.disk.discovery[]', zbx.json({'data': devices}))
4959

5060
def items(self, template):
@@ -54,17 +64,29 @@ def items(self, template):
5464
}) + template.item({
5565
'name': 'Block devices: write requests',
5666
'key': 'system.disk.all_write[]'
67+
}) + template.item({
68+
'name': 'Block devices: read byte/s',
69+
'key': 'system.disk.all_read_b[]'
70+
}) + template.item({
71+
'name': 'Block devices: write byte/s',
72+
'key': 'system.disk.all_write_b[]'
5773
})
5874

5975
def graphs(self, template):
60-
items = [
61-
{'key': 'system.disk.all_read[]', 'color': 'CC0000'},
62-
{'key': 'system.disk.all_write[]', 'color': '0000CC'}
63-
]
6476
graph = {
6577
'name': 'Block devices: read/write operations',
66-
'items': items}
67-
return template.graph(graph)
78+
'items': [
79+
{'key': 'system.disk.all_read[]', 'color': 'CC0000'},
80+
{'key': 'system.disk.all_write[]', 'color': '0000CC'}]
81+
}
82+
result = template.graph(graph)
83+
graph = {
84+
'name': 'Block devices: read/write bytes',
85+
'items': [
86+
{'key': 'system.disk.all_read_b[]', 'color': 'CC0000'},
87+
{'key': 'system.disk.all_write_b[]', 'color': '0000CC'}]
88+
}
89+
return result + template.graph(graph)
6890

6991
def discovery_rules(self, template):
7092

@@ -84,16 +106,36 @@ def discovery_rules(self, template):
84106
'name': 'Block device {#BLOCKDEVICE}: read operations'},
85107
{
86108
'key': 'system.disk.write[{#BLOCKDEVICE}]',
87-
'name': 'Block device {#BLOCKDEVICE}: write operations'}]
109+
'name': 'Block device {#BLOCKDEVICE}: write operations'},
110+
{
111+
'key': 'system.disk.read_b[{#BLOCKDEVICE}]',
112+
'name': 'Block device {#BLOCKDEVICE}: read byte/s',
113+
'units': Plugin.UNITS.bytes},
114+
{
115+
'key': 'system.disk.write_b[{#BLOCKDEVICE}]',
116+
'name': 'Block device {#BLOCKDEVICE}: write byte/s',
117+
'units': Plugin.UNITS.bytes}]
88118

89119
graphs = [{
90-
'name': 'Block device overview: {#BLOCKDEVICE}',
120+
'name': 'Block device overview: {#BLOCKDEVICE} operations',
91121
'items': [{
92122
'color': 'CC0000',
93123
'key': 'system.disk.read[{#BLOCKDEVICE}]'},
94124
{
95125
'color': '0000CC',
96126
'key': 'system.disk.write[{#BLOCKDEVICE}]'},
127+
{
128+
'yaxisside': 1,
129+
'color': '00CC00',
130+
'key': 'system.disk.utilization[{#BLOCKDEVICE}]'}]},
131+
{
132+
'name': 'Block device overview: {#BLOCKDEVICE} byte/s',
133+
'items': [{
134+
'color': 'CC0000',
135+
'key': 'system.disk.read_b[{#BLOCKDEVICE}]'},
136+
{
137+
'color': '0000CC',
138+
'key': 'system.disk.write_b[{#BLOCKDEVICE}]'},
97139
{
98140
'yaxisside': 1,
99141
'color': '00CC00',

0 commit comments

Comments
 (0)