diff --git a/ch_tools/monrun_checks/ch_system_queues.py b/ch_tools/monrun_checks/ch_system_queues.py index e4ea9773..d55cc8d2 100644 --- a/ch_tools/monrun_checks/ch_system_queues.py +++ b/ch_tools/monrun_checks/ch_system_queues.py @@ -3,7 +3,6 @@ from ch_tools.common.result import Result from ch_tools.monrun_checks.clickhouse_client import ClickhouseClient -from ch_tools.monrun_checks.clickhouse_info import ClickhouseInfo @click.command("system-queues") @@ -27,7 +26,7 @@ def system_queues_command(ctx, crit, warn, conf): config = {"triggers": {"default": {"crit": crit, "warn": warn}}} metrics = get_metrics(ctx) - return check_metrics(ctx, metrics, config) + return check_metrics(metrics, config) def get_config(conf): @@ -49,7 +48,7 @@ def get_metrics(ctx): return ClickhouseClient(ctx).execute(query, compact=False) -def check_metrics(ctx, metrics, config): +def check_metrics(metrics, config): """ Check that metrics are within acceptable levels. """ @@ -60,7 +59,6 @@ def check_metrics(ctx, metrics, config): status = 0 message = "OK" triggers = [] - versions_count = 0 for row in metrics: db_table = "{}.{}".format(row["database"], row["table"]) @@ -73,17 +71,10 @@ def check_metrics(ctx, metrics, config): thresholds = table_thresholds.get(key, default_thresholds[key]) report = "" - table_status = 0 for prior in "crit", "warn": threshold = thresholds[prior] if value > threshold: table_status = status_map[prior] - if table_status > 1: - if versions_count == 0: - versions_count = ClickhouseInfo.get_versions_count(ctx) - if versions_count > 1: - table_status = 1 - prior = "crit->warn" report += "{}: {} {} > {} ({});".format( db_table, key, value, threshold, prior ) @@ -94,9 +85,5 @@ def check_metrics(ctx, metrics, config): triggers.sort(reverse=True, key=lambda x: x[0]) status = triggers[0][0] message = " ".join(x[1] for x in triggers) - if versions_count == 0: - versions_count = ClickhouseInfo.get_versions_count(ctx) - if versions_count > 1: - message += " ClickHouse versions on replicas mismatch" return Result(code=status, message=message) diff --git a/ch_tools/monrun_checks/clickhouse_info.py b/ch_tools/monrun_checks/clickhouse_info.py index 3f71060b..fdfc0063 100644 --- a/ch_tools/monrun_checks/clickhouse_info.py +++ b/ch_tools/monrun_checks/clickhouse_info.py @@ -1,26 +1,9 @@ import functools -from ch_tools.monrun_checks.clickhouse_client import ClickhouseClient, ClickhousePort +from ch_tools.monrun_checks.clickhouse_client import ClickhouseClient class ClickhouseInfo: - @classmethod - @functools.lru_cache(maxsize=1) - def get_versions_count(cls, ctx): - """ - Count different clickhouse versions in cluster. - """ - ch_client = ClickhouseClient(ctx) - # I believe that all hosts in cluster have the same port set, so check current for security port - remote_command = ( - "remoteSecure" - if ch_client.check_port(ClickhousePort.TCP_SECURE) - else "remote" - ) - replicas = ",".join(cls.get_replicas(ctx)) - query = f"""SELECT uniq(version()) FROM {remote_command}('{replicas}', system.one)""" - return int(ch_client.execute(query)[0][0]) - @classmethod @functools.lru_cache(maxsize=1) def get_replicas(cls, ctx):