Skip to content

Commit 30ea94d

Browse files
Zageyiffzageyiff
Zageyiff
authored andcommitted
Support for mysql 5.6
1 parent 3490d73 commit 30ea94d

File tree

3 files changed

+373
-21
lines changed

3 files changed

+373
-21
lines changed

mysql-snmp

+54-15
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ sub parse_innodb_status {
119119
my @os_waits;
120120
my $txn_seen = 0;
121121
my $merged_op_seen = 0;
122+
my $discarded_op_seen = 0;
123+
my $individual_buffer_pool_info_seen = 0;
122124

123125
foreach my $line (@$lines) {
124126
my @row = split(/ +/, $line);
@@ -129,12 +131,30 @@ sub parse_innodb_status {
129131
push(@spin_rounds, $self->tonum($row[5]));
130132
push(@os_waits, $self->tonum($row[8]));
131133
}
132-
elsif ($line =~ m/RW-shared spins/) {
134+
elsif($line =~ m/RW-shared spins \d+, OS waits \d+; RW-excl/) {
135+
# previous mysql versions had this line
136+
# RW-shared spins 1956750, OS waits 199142; RW-excl spins 316353, OS waits 185734
133137
push(@spin_waits, $self->tonum($row[2]));
134138
push(@spin_waits, $self->tonum($row[8]));
135139
push(@os_waits, $self->tonum($row[5]));
136140
push(@os_waits, $self->tonum($row[11]));
137141
}
142+
elsif ($line =~ m/RW-shared spins \d+, rounds/) {
143+
# newer mysql versions split this line in two
144+
# RW-shared spins 38794, rounds 798644, OS waits 18015
145+
# RW-excl spins 27732, rounds 910515, OS waits 23321
146+
push(@spin_waits, $self->tonum($row[2]));
147+
push(@spin_rounds, $self->tonum($row[4]));
148+
push(@os_waits, $self->tonum($row[7]));
149+
}
150+
elsif ($line =~ m/^RW-excl spins/) {
151+
# newer mysql versions split this line in two
152+
# RW-shared spins 38794, rounds 798644, OS waits 18015
153+
# RW-excl spins 27732, rounds 910515, OS waits 23321
154+
push(@spin_waits, $self->tonum($row[2]));
155+
push(@spin_rounds, $self->tonum($row[4]));
156+
push(@os_waits, $self->tonum($row[7]));
157+
}
138158
elsif ($line =~ /seconds the semaphore:/) {
139159
# --Thread 907205 has waited at handler/ha_innodb.cc line 7156 for 1.00 seconds the semaphore:
140160
$status{'innodb_sem_waits'} += 1;
@@ -195,10 +215,16 @@ sub parse_innodb_status {
195215
$status{'file_writes'} = $self->tonum($row[4]);
196216
$status{'file_fsyncs'} = $self->tonum($row[8]);
197217
}
198-
elsif ($line =~ m/Pending normal aio/) {
218+
elsif ($line =~ m/Pending normal aio: \d+, aio/) {
219+
# Pending normal aio reads: 0, aio writes: 0,
199220
$status{'pending_normal_aio_reads'} = $self->tonum($row[4]);
200221
$status{'pending_normal_aio_writes'} = $self->tonum($row[7]);
201222
}
223+
elsif ($line =~ m/Pending normal aio: \d+ \[\d+, \d+, \d+, \d+\]/) {
224+
# Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
225+
$status{'pending_normal_aio_reads'} = $self->tonum($row[4]);
226+
$status{'pending_normal_aio_writes'} = $self->tonum($row[12]);
227+
}
202228
elsif ($line =~ m/ibuf aio reads/) {
203229
$status{'pending_ibuf_aio_reads'} = $self->tonum($row[4]);
204230
$status{'pending_aio_log_ios'} = $self->tonum($row[7]);
@@ -239,10 +265,18 @@ sub parse_innodb_status {
239265
# insert 0, delete mark 0, delete 0
240266
$merged_op_seen = 1;
241267
}
242-
elsif ($merged_op_seen && $line =~ m/ insert \d+, delete mark/) {
243-
#merged operations:
268+
elsif ($line =~ m/discarded operations:/) {
269+
#discarded operations:
244270
# insert 0, delete mark 0, delete 0
245-
$status{'ibuf_inserts'} = $self->tonum($1);
271+
$discarded_op_seen = 1;
272+
}
273+
elsif ($merged_op_seen && !$discarded_op_seen && $line =~ m/ insert \d+, delete mark/) {
274+
# we want merged operations, not discarded operations (same pattern)
275+
# merged operations:
276+
# insert 661027, delete mark 1093738, delete 6140
277+
# discarded operations:
278+
# insert 0, delete mark 0, delete 0
279+
$status{'ibuf_inserts'} = $self->tonum($row[2]);
246280
}
247281
elsif ($line =~ m/^Hash table size /) {
248282
# In some versions of InnoDB, the used cells is omitted.
@@ -276,6 +310,9 @@ sub parse_innodb_status {
276310
$status{'last_checkpoint'} = defined($row[4]) ? $self->make_bigint($row[3], $row[4]) : $self->tonum($row[3]);
277311
}
278312
# BUFFER POOL AND MEMORY
313+
elsif ($line =~ m/^INDIVIDUAL BUFFER POOL INFO/) {
314+
$individual_buffer_pool_info_seen = 1;
315+
}
279316
elsif ($line =~ m/^Total memory allocated/) {
280317
# Total memory allocated 29642194944; in additional pool allocated 0
281318
$status{'total_mem_alloc'} = $self->tonum($row[3]);
@@ -313,22 +350,24 @@ sub parse_innodb_status {
313350
# innodb_io_pattern 0 (0 + 0)
314351
$status{'innodb_io_pattern_memory'} = $self->tonum($row[2]);
315352
}
316-
elsif ($line =~ m/Buffer pool size /) {
353+
elsif (!$individual_buffer_pool_info_seen && $line =~ m/Buffer pool size /) {
317354
# The " " after size is necessary to avoid matching the wrong line:
318355
# Buffer pool size 1769471
319356
# Buffer pool size, bytes 28991012864
320357
$status{'pool_size'} = $self->tonum($row[3]);
321358
}
322-
elsif ($line =~ m/Free buffers/) {
359+
elsif (!$individual_buffer_pool_info_seen && $line =~ m/Free buffers/) {
323360
$status{'free_pages'} = $self->tonum($row[2]);
324361
}
325-
elsif ($line =~ m/Database pages/) {
362+
elsif (!$individual_buffer_pool_info_seen && $line =~ m/^Database pages/) {
326363
$status{'database_pages'} = $self->tonum($row[2]);
327364
}
328-
elsif ($line =~ m/Modified db pages/) {
365+
elsif (!$individual_buffer_pool_info_seen && $line =~ m/Modified db pages/) {
329366
$status{'modified_pages'} = $self->tonum($row[3]);
330367
}
331-
elsif ($line =~ m/Pages read/) {
368+
elsif (!$individual_buffer_pool_info_seen && $line =~ m/Pages read \d+, created/) {
369+
#Pages read 349569, created 140622, written 1614731
370+
#Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
332371
$status{'pages_read'} = $self->tonum($row[2]);
333372
$status{'pages_created'} = $self->tonum($row[4]);
334373
$status{'pages_written'} = $self->tonum($row[6]);
@@ -773,7 +812,7 @@ sub fetch_mysql_data {
773812
}
774813

775814
# Get SHOW INNODB STATUS and extract the desired metrics from it.
776-
if ($opt{innodb} && $status{'have_innodb'} eq 'YES') {
815+
if ($opt{innodb}) { #mysql 5.6 has no 'have_innodb' status, latest percona monitoring tool uses 'show engines' and looks for innodb
777816
my $innodb_array = $dbh->selectall_arrayref("SHOW /*!50000 ENGINE*/ INNODB STATUS",{Slice => {}});
778817
my @lines = split("\n", $innodb_array->[0]{'Status'});
779818

@@ -1023,7 +1062,7 @@ sub VersionMessage {
10231062
print "mysql-snmp $VERSION by brice.figureau\@daysofwonder.com\n";
10241063
}
10251064

1026-
sub run
1065+
sub run
10271066
{
10281067
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
10291068
my $agent = new NetSNMP::agent('Name' => 'mysql', 'AgentX' => 1);
@@ -1112,10 +1151,10 @@ __END__
11121151
11131152
=head1 NAME
11141153
1115-
mysql-snmp - report mysql statistics via SNMP
1116-
1154+
mysql-snmp - report mysql statistics via SNMP
1155+
11171156
=head1 SYNOPSIS
1118-
1157+
11191158
mysql-snmp [options]
11201159
11211160
-h HOST, --host=HOST connect to MySQL DB on HOST

tests/data/innodb56.output.txt

+240
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
*************************** 1. row ***************************
2+
Type: InnoDB
3+
Name:
4+
Status:
5+
=====================================
6+
2013-07-30 15:17:03 7f60d91c4700 INNODB MONITOR OUTPUT
7+
=====================================
8+
Per second averages calculated from the last 1 seconds
9+
-----------------
10+
BACKGROUND THREAD
11+
-----------------
12+
srv_master_thread loops: 60796 srv_active, 0 srv_shutdown, 6488288 srv_idle
13+
srv_master_thread log flush and writes: 6548192
14+
----------
15+
SEMAPHORES
16+
----------
17+
OS WAIT ARRAY INFO: reservation count 75081
18+
OS WAIT ARRAY INFO: signal count 109789
19+
Mutex spin waits 133415, rounds 1343530, OS waits 31509
20+
RW-shared spins 38794, rounds 798644, OS waits 18015
21+
RW-excl spins 27732, rounds 910515, OS waits 23321
22+
Spin rounds per wait: 10.07 mutex, 20.59 RW-shared, 32.83 RW-excl
23+
------------
24+
TRANSACTIONS
25+
------------
26+
Trx id counter 147558
27+
Purge done for trx's n:o < 147549 undo n:o < 0 state: running but idle
28+
History list length 631
29+
LIST OF TRANSACTIONS FOR EACH SESSION:
30+
---TRANSACTION 0, not started
31+
MySQL thread id 192507, OS thread handle 0x7f60d91c4700, query id 14635622 localhost root init
32+
show engine innodb status
33+
---TRANSACTION 147557, not started
34+
MySQL thread id 192496, OS thread handle 0x7f60d9142700, query id 14635618 localhost 127.0.0.1 cleaning up
35+
---TRANSACTION 147556, not started
36+
MySQL thread id 192489, OS thread handle 0x7f60da6fd700, query id 14635620 localhost 127.0.0.1 cleaning up
37+
---TRANSACTION 147555, not started
38+
MySQL thread id 192482, OS thread handle 0x7f60da842700, query id 14635544 localhost 127.0.0.1 cleaning up
39+
---TRANSACTION 147554, not started
40+
MySQL thread id 192481, OS thread handle 0x7f60da801700, query id 14635531 localhost 127.0.0.1 cleaning up
41+
--------
42+
FILE I/O
43+
--------
44+
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
45+
I/O thread 1 state: waiting for completed aio requests (log thread)
46+
I/O thread 2 state: waiting for completed aio requests (read thread)
47+
I/O thread 3 state: waiting for completed aio requests (read thread)
48+
I/O thread 4 state: waiting for completed aio requests (read thread)
49+
I/O thread 5 state: waiting for completed aio requests (read thread)
50+
I/O thread 6 state: waiting for completed aio requests (write thread)
51+
I/O thread 7 state: waiting for completed aio requests (write thread)
52+
I/O thread 8 state: waiting for completed aio requests (write thread)
53+
I/O thread 9 state: waiting for completed aio requests (write thread)
54+
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
55+
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
56+
Pending flushes (fsync) log: 0; buffer pool: 0
57+
350568 OS file reads, 1783974 OS file writes, 405508 OS fsyncs
58+
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
59+
-------------------------------------
60+
INSERT BUFFER AND ADAPTIVE HASH INDEX
61+
-------------------------------------
62+
Ibuf: size 1, free list len 3684, seg size 3686, 57660 merges
63+
merged operations:
64+
insert 661027, delete mark 1093738, delete 6140
65+
discarded operations:
66+
insert 0, delete mark 0, delete 0
67+
Hash table size 9461399, node heap has 24510 buffer(s)
68+
0.00 hash searches/s, 0.00 non-hash searches/s
69+
---
70+
LOG
71+
---
72+
Log sequence number 51500755024
73+
Log flushed up to 51500755024
74+
Pages flushed up to 51500755024
75+
Last checkpoint at 51500755024
76+
0 pending log writes, 0 pending chkp writes
77+
29779 log i/o's done, 0.00 log i/o's/second
78+
----------------------
79+
BUFFER POOL AND MEMORY
80+
----------------------
81+
Total memory allocated 4395630592; in additional pool allocated 0
82+
Dictionary memory allocated 493077
83+
Buffer pool size 262136
84+
Free buffers 8205
85+
Database pages 229421
86+
Old database pages 84527
87+
Modified db pages 0
88+
Pending reads 0
89+
Pending writes: LRU 0, flush list 0 single page 0
90+
Pages made young 6940988, not young 2818267
91+
0.00 youngs/s, 0.00 non-youngs/s
92+
Pages read 349569, created 140622, written 1614731
93+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
94+
No buffer pool page gets since the last printout
95+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
96+
LRU len: 229421, unzip_LRU len: 0
97+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
98+
----------------------
99+
INDIVIDUAL BUFFER POOL INFO
100+
----------------------
101+
---BUFFER POOL 0
102+
Buffer pool size 32767
103+
Free buffers 1024
104+
Database pages 28688
105+
Old database pages 10569
106+
Modified db pages 0
107+
Pending reads 0
108+
Pending writes: LRU 0, flush list 0 single page 0
109+
Pages made young 757026, not young 336092
110+
0.00 youngs/s, 0.00 non-youngs/s
111+
Pages read 42623, created 17895, written 225921
112+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
113+
No buffer pool page gets since the last printout
114+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
115+
LRU len: 28688, unzip_LRU len: 0
116+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
117+
---BUFFER POOL 1
118+
Buffer pool size 32767
119+
Free buffers 1024
120+
Database pages 28707
121+
Old database pages 10577
122+
Modified db pages 0
123+
Pending reads 0
124+
Pending writes: LRU 0, flush list 0 single page 0
125+
Pages made young 846831, not young 277286
126+
0.00 youngs/s, 0.00 non-youngs/s
127+
Pages read 42058, created 16947, written 196473
128+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
129+
No buffer pool page gets since the last printout
130+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
131+
LRU len: 28707, unzip_LRU len: 0
132+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
133+
---BUFFER POOL 2
134+
Buffer pool size 32767
135+
Free buffers 1025
136+
Database pages 28696
137+
Old database pages 10573
138+
Modified db pages 0
139+
Pending reads 0
140+
Pending writes: LRU 0, flush list 0 single page 0
141+
Pages made young 784339, not young 301199
142+
0.00 youngs/s, 0.00 non-youngs/s
143+
Pages read 44069, created 17669, written 194571
144+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
145+
No buffer pool page gets since the last printout
146+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
147+
LRU len: 28696, unzip_LRU len: 0
148+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
149+
---BUFFER POOL 3
150+
Buffer pool size 32767
151+
Free buffers 1024
152+
Database pages 28642
153+
Old database pages 10553
154+
Modified db pages 0
155+
Pending reads 0
156+
Pending writes: LRU 0, flush list 0 single page 0
157+
Pages made young 998532, not young 363353
158+
0.00 youngs/s, 0.00 non-youngs/s
159+
Pages read 43698, created 17555, written 208273
160+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
161+
No buffer pool page gets since the last printout
162+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
163+
LRU len: 28642, unzip_LRU len: 0
164+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
165+
---BUFFER POOL 4
166+
Buffer pool size 32767
167+
Free buffers 1036
168+
Database pages 28661
169+
Old database pages 10560
170+
Modified db pages 0
171+
Pending reads 0
172+
Pending writes: LRU 0, flush list 0 single page 0
173+
Pages made young 713174, not young 277219
174+
0.00 youngs/s, 0.00 non-youngs/s
175+
Pages read 40754, created 16713, written 192915
176+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
177+
No buffer pool page gets since the last printout
178+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
179+
LRU len: 28661, unzip_LRU len: 0
180+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
181+
---BUFFER POOL 5
182+
Buffer pool size 32767
183+
Free buffers 1024
184+
Database pages 28672
185+
Old database pages 10564
186+
Modified db pages 0
187+
Pending reads 0
188+
Pending writes: LRU 0, flush list 0 single page 0
189+
Pages made young 962037, not young 443774
190+
0.00 youngs/s, 0.00 non-youngs/s
191+
Pages read 45895, created 18222, written 200847
192+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
193+
No buffer pool page gets since the last printout
194+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
195+
LRU len: 28672, unzip_LRU len: 0
196+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
197+
---BUFFER POOL 6
198+
Buffer pool size 32767
199+
Free buffers 1024
200+
Database pages 28699
201+
Old database pages 10573
202+
Modified db pages 0
203+
Pending reads 0
204+
Pending writes: LRU 0, flush list 0 single page 0
205+
Pages made young 913128, not young 343902
206+
0.00 youngs/s, 0.00 non-youngs/s
207+
Pages read 43834, created 17257, written 196107
208+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
209+
No buffer pool page gets since the last printout
210+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
211+
LRU len: 28699, unzip_LRU len: 0
212+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
213+
---BUFFER POOL 7
214+
Buffer pool size 32767
215+
Free buffers 1024
216+
Database pages 28656
217+
Old database pages 10558
218+
Modified db pages 0
219+
Pending reads 0
220+
Pending writes: LRU 0, flush list 0 single page 0
221+
Pages made young 965921, not young 475442
222+
0.00 youngs/s, 0.00 non-youngs/s
223+
Pages read 46638, created 18364, written 199624
224+
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
225+
No buffer pool page gets since the last printout
226+
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
227+
LRU len: 28656, unzip_LRU len: 0
228+
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
229+
--------------
230+
ROW OPERATIONS
231+
--------------
232+
0 queries inside InnoDB, 0 queries in queue
233+
0 read views open inside InnoDB
234+
Main thread process no. 3310, id 140054010304256, state: sleeping
235+
Number of rows inserted 4710127, updated 191453, deleted 3146432, read 1129255407
236+
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
237+
----------------------------
238+
END OF INNODB MONITOR OUTPUT
239+
============================
240+

0 commit comments

Comments
 (0)