nginxinc/nginx-amplify-doc

Cannot get Amplify to monitor MariaDB/mysql. amplify.agent.common.errors.AmplifySubprocessError

Danrancan opened this issue · 2 comments

I am running an Ubuntu based LEMP server, and trying to get MariaDB to show up on Nginx-amplify but it is not working after following several tutorials, as well as the amplify documentation. I have posted this question on serverfault, and got an answer to this, but there was no explanation as to how the recommended changes would affect my system. So I am reposting the question here in hopes that someone can please verify the server fault answer is the best answer, and that this won't negatively impact my system in terms of SECURITY, and performance. Any explanation of the answer or elaboration on it would be HIGHLY appreciated. Any additional answers or BETTER SOLUTIONS would be even more appreciated! Below is my Server Fault question and the answer I received from a user account that is only 11 days old (this makes me skeptical of the solution, which I why I am posting here to verify).

Thanks for your help!

QUESTION:
I am trying to get amplify to monitor mysql database on ubuntu server 20.04 running on a raspberry pi 4. I am sure I have set everything up correctly and have cross-referenced my work with many internet guides. However, mariadb does not appear in the Nginx amplify web interface after setting things up. My logs show the following errors:

2022-08-08 10:32:41,134 [1824839] supervisor ps nginx output: ['   2074       1 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf', '1740162    2074 nginx: worker process', '1740163    2074 nginx: worker process', '1740165    2074 nginx: worker process', '1740166    2074 nginx: worker process', '1740168    2074 nginx: cache manager process', '']
2022-08-08 10:32:41,161 [1824839] supervisor nginx objects: ['5057a79cf47c63d99f326ae55fea2c99bc0e2dcfd6bc5cdc5492d770f0a55284']
2022-08-08 10:32:41,162 [1824839] supervisor status objects: []
2022-08-08 10:32:41,162 [1824839] supervisor api objects: []
2022-08-08 10:32:41,228 [1824839] supervisor failed to find running mysqld via "ps xao pid,ppid,command | grep -E 'mysqld( |$)'" due to AmplifySubprocessError
2022-08-08 10:32:41,228 [1824839] supervisor additional info:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/amplify/ext/mysql/managers.py", line 154, in _find_local
    ps, _ = (ps, None) if ps is not None else subp.call(PS_CMD)
  File "/usr/lib/python3/dist-packages/amplify/agent/common/util/subp.py", line 34, in call
    raise AmplifySubprocessError(message=command, payload=dict(returncode=process.returncode, error=raw_err))
amplify.agent.common.errors.AmplifySubprocessError: (message=ps xao pid,ppid,command | grep -E 'mysqld( |$)', payload={'returncode': 1, 'error': ''})
2022-08-08 10:32:41,229 [1824839] supervisor mysql objects: []

Does anyone understand these errors and could you help me fix this to get mariaDB showing up on Nginx Amplify?

ANSWER:
The mariadb daemon is called 'mariadbd' and amplify-agent is looking for 'mysqld'.
If you run

systemctl status mariadb

Then the line starting with 'loaded' should have the location of the service file

Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
In this case it is '/lib/systemd/system/mariadb.service'. Open the file in a text editor and find the line starting

ExecStart=
Then change the path from pointing to 'mariadbd' to 'mysqld'. Then you need to reload the daemon and restart the services.

systemctl daemon-reload
systemctl restart mariadb
systemctl restart amplify-agent

The agent should now be able to find the process.

@Danrancan If you are still facing this problem, please create an issue in the NGINX Amplify Agent repo

@Danrancan If you are still facing this problem, please create an issue in the NGINX Amplify Agent repo

I am not, I solved this issue and created the following tutorial for those struggling to find a solution.

The Trick to Monitoring MariaDB/Mysql in Nginx Amplify