nginxinc / nginx-amplify-agent

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

Problem with Mariadb 10.5.6 Centos 7 #65

Open thaidh1907 opened 4 years ago

thaidh1907 commented 4 years ago

Hello, Centos 7.8.2003 Mariadb 10.5.6

File "/usr/lib/python2.7/site-packages/amplify/ext/mysql/managers.py", line 152, in _findlocal 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': ''})

qwertynik commented 4 years ago

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': ''})
RalfvdEnden commented 4 years ago

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.

handymenny commented 4 years ago

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.

RalfvdEnden commented 4 years ago

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

handymenny commented 4 years ago

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?

RalfvdEnden commented 4 years ago

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