nginxinc / nginx-amplify-agent

NGINX Amplify Agent
BSD 2-Clause "Simplified" License
23 stars 9 forks source link

Failure to gather MySQL metrics #35

Open dvershinin opened 6 years ago

dvershinin commented 6 years ago

MySQL version: Server version: 5.6.39 MySQL Community Server (GPL) Python version: 2.6.6 OS: CentOS release 6.10 (Final) Amplify agent: 1.4.1-1.el6 @nginx-amplify

I've configured MySQL user for amplify agent, made sure it can read global metric (verified on the command line), set correct path to MySQL socket file, running amplify agent as root user, but...:

mysql_meta failed to connect to MySQLd due to TypeError
2018-07-27 16:34:43,607 [30291] mysql_meta additional info:
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/amplify/ext/mysql/objects.py", line 82, in connect
    return pymysql.connect(**conn_kwargs)
  File "/usr/lib/python2.6/site-packages/amplify/pymysql/__init__.py", line 90, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/amplify/pymysql/connections.py", line 699, in __init__
    self.connect()
  File "/usr/lib/python2.6/site-packages/amplify/pymysql/connections.py", line 935, in connect
    self._get_server_information()
  File "/usr/lib/python2.6/site-packages/amplify/pymysql/connections.py", line 1249, in _get_server_information
    packet = self._read_packet()
  File "/usr/lib/python2.6/site-packages/amplify/pymysql/connections.py", line 991, in _read_packet
    packet_header = self._read_bytes(4)
  File "/usr/lib/python2.6/site-packages/amplify/pymysql/connections.py", line 1025, in _read_bytes
    data = self._rfile.read(num_bytes)
  File "/usr/lib64/python2.6/io.py", line 940, in read
    return self._read_unlocked(n)
  File "/usr/lib64/python2.6/io.py", line 974, in _read_unlocked
    chunk = self.raw.read(wanted)
  File "/usr/lib64/python2.6/io.py", line 591, in read
    n = self.readinto(b)
  File "/usr/lib/python2.6/site-packages/amplify/pymysql/_socketio.py", line 59, in readinto
    return self._sock.recv_into(b)
TypeError: recv_into() argument 1 must be pinned buffer, not bytearray
akamoroz commented 6 years ago

Hello @dvershinin, this issue requires some investigation. Creating a ticket in our support queue. Pls check your mailbox.

dvershinin commented 6 years ago

So with CentOS 6 / Python 2.6 the agent cannot send the MySQL metrics due to a bug (I've been told the bug is with Python 2.6 itself so likely cannot be fixed by the agent itself).

I've detailed my experience installing newer Python 2.7 on CentOS 6 as well as installing the agent manually here. I hope this can be useful to anyone still using CentOS 6 and having a requirement to monitor MySQL.

One important note is that with:

[mysql]
host = localhost
remote = False
...

it still failed, but with:

[mysql]
#host =
#remote = False
...

things worked.