@@ -19,7 +19,7 @@ def run(self, zbx):
19
19
with open ('/proc/diskstats' , 'r' ) as f :
20
20
21
21
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
23
23
24
24
for line in f :
25
25
if re .search ('(ram|loop)' , line ):
@@ -31,20 +31,30 @@ def run(self, zbx):
31
31
if self .OnlyPhysicalDevices and re .search ('\d+$' , dev ):
32
32
continue
33
33
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
38
36
39
37
zbx .send ('system.disk.read[{0}]' .format (
40
- dev ), read , self .DELTA_SPEED )
38
+ dev ), read_op , self .DELTA_SPEED )
41
39
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 )
43
45
zbx .send ('system.disk.utilization[{0}]' .format (
44
46
dev ), ticks / 10 , self .DELTA_SPEED )
45
47
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 )
48
58
zbx .send ('system.disk.discovery[]' , zbx .json ({'data' : devices }))
49
59
50
60
def items (self , template ):
@@ -54,17 +64,29 @@ def items(self, template):
54
64
}) + template .item ({
55
65
'name' : 'Block devices: write requests' ,
56
66
'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[]'
57
73
})
58
74
59
75
def graphs (self , template ):
60
- items = [
61
- {'key' : 'system.disk.all_read[]' , 'color' : 'CC0000' },
62
- {'key' : 'system.disk.all_write[]' , 'color' : '0000CC' }
63
- ]
64
76
graph = {
65
77
'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 )
68
90
69
91
def discovery_rules (self , template ):
70
92
@@ -84,16 +106,36 @@ def discovery_rules(self, template):
84
106
'name' : 'Block device {#BLOCKDEVICE}: read operations' },
85
107
{
86
108
'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 }]
88
118
89
119
graphs = [{
90
- 'name' : 'Block device overview: {#BLOCKDEVICE}' ,
120
+ 'name' : 'Block device overview: {#BLOCKDEVICE} operations ' ,
91
121
'items' : [{
92
122
'color' : 'CC0000' ,
93
123
'key' : 'system.disk.read[{#BLOCKDEVICE}]' },
94
124
{
95
125
'color' : '0000CC' ,
96
126
'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}]' },
97
139
{
98
140
'yaxisside' : 1 ,
99
141
'color' : '00CC00' ,
0 commit comments