nginxinc/nginx-amplify-agent

Problem with Mariadb 10.5.6 Centos 7

thaidh1907 opened this issue · 6 comments

Hello,
Centos 7.8.2003
Mariadb 10.5.6

File "/usr/lib/python2.7/site-packages/amplify/ext/mysql/managers.py", line 152, in _find_local
ps, _ = (ps, None) if ps is not None else subp.call(PS_CMD)
File "/usr/lib/python2.7/site-packages/amplify/agent/common/util/subp.py", line 32, in call
raise AmplifySubprocessError(message=command, payload=dict(returncode=process.returncode, error=raw_err))
AmplifySubprocessError: (message=ps xao pid,ppid,command | grep -E 'mysqld( |$)', payload={'returncode': 1, 'error': ''})

Receiving the same error.
Is there a setting in the config file to be modified to make nginx amplify look at a different process?

2020-11-25 06:16:22,290 [1732] supervisor failed to find running mysqld via "ps xao pid,ppid,command | grep -E 'mysqld( |$)'" due to AmplifySubprocessError
2020-11-25 06:16:22,290 [1732] supervisor additional info:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/amplify/ext/mysql/managers.py", line 152, in _find_local
    ps, _ = (ps, None) if ps is not None else subp.call(PS_CMD)
  File "/usr/lib/python2.7/site-packages/amplify/agent/common/util/subp.py", line 32, in call
    raise AmplifySubprocessError(message=command, payload=dict(returncode=process.returncode, error=raw_err))
AmplifySubprocessError: (message=ps xao pid,ppid,command | grep -E 'mysqld( |$)', payload={'returncode': 1, 'error': ''})

There isn't as far as I know. I did try to set remote = True and fill out both 'host' and 'port', but that still fails to get stats with the following error:

2020-11-25 13:57:18,066 [10359] mysql_metrics failed to collect MySQLd metrics due to AttributeError
2020-11-25 13:57:18,066 [10359] mysql_metrics additional info:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/amplify/ext/mysql/collectors/metrics.py", line 65, in mysql_status
with conn as cursor:
AttributeError: exit
2020-11-25 13:57:18,067 [10359] mysql_metrics mysql_metrics failed to collect: mysql_status raised KeyError
2020-11-25 13:57:18,067 [10359] mysql_metrics additional info:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/amplify/agent/collectors/abstract.py", line 129, in collect
method(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/amplify/ext/mysql/collectors/metrics.py", line 86, in mysql_status
counted_vars['mysql.global.update'] +
KeyError: 'mysql.global.insert'
2020-11-25 13:57:18,067 [10359] mysql_metrics 2368003db38ab9501e2361349341f8abfad990da9fe96a46527359b852f0ae1c collect in 0.003

Haven't been able to figure out why.

Can you try appying this change https://github.com/nginxinc/nginx-amplify-agent/pull/189 ?
With that change I have no problem with MariaDB 10.5.8 on ubuntu bionic and focal.

With the patch it does detect mariadb, but I still get the KeyError

With the patch it does detect mariadb, but I still get the KeyError

What is the output of SHOW GLOBAL STATUS LIKE "Com_insert"; with the user configured in amplify-agent?

I dug into the pyMySQL documentation and found out how to fix the issue. In both meta.py and metric.py (in ext/mysql/collectors/) the following change was necessary:

with conn as cursor:
should be:
with conn.cursor() as cursor:

FreeBSD probably comes with a (slightly?) newer version of the module than CentOS