Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for mariadbd process for MariaDB 10.5+ #9543

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions mysql/datadog_checks/mysql/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, name, init_config, instances):
super(MySql, self).__init__(name, init_config, instances)
self.qcache_stats = {}
self.version = None
self.is_mariadb = None
self._is_aurora = None
self._config = MySQLConfig(self.instance)

Expand Down Expand Up @@ -108,13 +109,14 @@ def check(self, _):
try:
self._conn = db

if self._get_is_aurora(db):
tags = tags + self._get_runtime_aurora_tags(db)

# version collection
self.version = get_version(db)
self._send_metadata()

self.is_mariadb = self.version.flavor == "MariaDB"
if self._get_is_aurora(db):
tags = tags + self._get_runtime_aurora_tags(db)

# Metric collection
self._collect_metrics(db, tags=tags)
self._collect_system_metrics(self._config.host, db, tags)
Expand Down Expand Up @@ -323,9 +325,8 @@ def _collect_metrics(self, db, tags):

def _collect_replication_metrics(self, db, results, above_560):
# Get replica stats
is_mariadb = self.version.flavor == "MariaDB"
replication_channel = self._config.options.get('replication_channel')
results.update(self._get_replica_stats(db, is_mariadb, replication_channel))
results.update(self._get_replica_stats(db, self.is_mariadb, replication_channel))
nonblocking = is_affirmative(self._config.options.get('replication_non_blocking_status', False))
results.update(self._get_replica_status(db, above_560, nonblocking))
return REPLICA_VARS
Expand Down Expand Up @@ -539,7 +540,10 @@ def _get_server_pid(self, db):
if pid is None and PSUTIL_AVAILABLE:
for proc in psutil.process_iter():
try:
if proc.name() == PROC_NAME:
process_name = PROC_NAME
if self.is_mariadb and self.version.version_compatible((10, 5, 0)):
process_name = "mariadbd"
if proc.name() == process_name:
pid = proc.pid
except (psutil.AccessDenied, psutil.ZombieProcess, psutil.NoSuchProcess):
continue
Expand Down
3 changes: 3 additions & 0 deletions mysql/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ def _add_dog_user(conn):
cur.execute("GRANT SELECT ON performance_schema.* TO 'dog'@'%'")
if MYSQL_FLAVOR == 'mysql' and MYSQL_VERSION == '8.0':
cur.execute("ALTER USER 'dog'@'%' WITH MAX_USER_CONNECTIONS 0")
elif MYSQL_FLAVOR == 'mariadb' and MYSQL_VERSION == '10.5':
cur.execute("GRANT SLAVE MONITOR ON *.* TO 'dog'@'%'")
cur.execute("ALTER USER 'dog'@'%' WITH MAX_USER_CONNECTIONS 0")
else:
cur.execute("UPDATE mysql.user SET max_user_connections = 0 WHERE user='dog' AND host='%'")
cur.execute("FLUSH PRIVILEGES")
Expand Down
12 changes: 6 additions & 6 deletions mysql/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
minversion = 2.0
basepython = py38
envlist =
py{27,38}-{5.6,5.7,8.0,maria}
py{27,38}-{5.7,8.0,maria10.2,maria10.5}

[testenv]
ensure_default_envdir = true
Expand Down Expand Up @@ -32,14 +32,14 @@ commands =
setenv =
COMPOSE_FILE=mysql.yaml
MYSQL_FLAVOR=mysql
# EOL February 5, 2021
5.6: MYSQL_VERSION=5.6
# EOL October 21, 2023
5.7: MYSQL_VERSION=5.7
8.0: COMPOSE_FILE=mysql8.yaml
# EOL April, 2026
8.0: MYSQL_VERSION=8.0
maria: COMPOSE_FILE=mariadb.yaml
maria: MYSQL_FLAVOR=mariadb
maria{10.2,10.5}: COMPOSE_FILE=mariadb.yaml
maria{10.2,10.5}: MYSQL_FLAVOR=mariadb
# EOL 23 May 2022
maria: MYSQL_VERSION=10.2.27
maria10.2: MYSQL_VERSION=10.2
# EOL 24 June 2025
maria10.5: MYSQL_VERSION=10.5