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

support get obproxy parameter value & fix the log of transaction_other_error_scene more info #722

Merged
merged 5 commits into from
Feb 10, 2025
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
10 changes: 10 additions & 0 deletions plugins/check/tasks/obproxy/parameter/request_buffer_length.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
info: 'Check obproxy request_buffer_length'
task:
- version: "[4.0.0,*]"
steps:
- type: get_obproxy_parameter
parameter: 'request_buffer_length'
result:
set_value: request_buffer_length
verify: '[[ $request_buffer_length == "4KB" ]]'
err_msg: "obproxy's parameter request_buffer_length is #{request_buffer_length}, not 4KB"
2 changes: 1 addition & 1 deletion plugins/rca/transaction_other_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def execute(self):
return
EASY_SLOW_nu = 0
for log_name in logs_name:
log_content = open(os.path.join(work_path_EASY_SLOW, log_name), "r").readlines()
log_content = open(log_name, "r").readlines()
EASY_SLOW_nu += len(log_content)
if EASY_SLOW_nu >= 1000:
self.record.add_record("EASY SLOW log number over 1000".format(EASY_SLOW_nu))
Expand Down
76 changes: 76 additions & 0 deletions src/handler/checker/step/get_obproxy_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*
# Copyright (c) 2022 OceanBase
# OceanBase Diagnostic Tool is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

"""
@time: 2023/9/26
@file: get_system_parameter.py
@desc:
"""

from src.handler.checker.check_exception import StepExecuteFailException
from src.common.tool import Util, StringUtils


class GetObproxyParameterHandler:
def __init__(self, context, step, task_variable_dict):
try:
self.context = context
self.stdio = context.stdio
self.ob_cluster = self.context.cluster_config
self.ob_cluster_name = self.ob_cluster.get("cluster_name")
self.tenant_mode = None
self.sys_database = None
self.database = None
self.ob_connector_pool = self.context.get_variable('check_obConnector_pool', None)
if self.ob_connector_pool is not None:
self.ob_connector = self.ob_connector_pool.get_connection()
if self.ob_connector is None:
raise Exception("self.ob_connector is None.")
except Exception as e:
self.stdio.error("GetObproxyParameterHandler init fail. Please check the OBCLUSTER conf. Exception : {0} .".format(e))
raise Exception("GetObproxyParameterHandler init fail. Please check the OBCLUSTER conf. Exception : {0} .".format(e))
self.task_variable_dict = task_variable_dict
self.step = step

def execute(self):
# check the ob_connector is based on the obproxy
try:
self.ob_connector.execute_sql("show proxyconfig")
except Exception as e:
raise StepExecuteFailException("ob_connector is not based on the obproxy. Please check the OBCLUSTER conf, the db_host, db_port must belong to obproxy. Exception : {0} .".format(e))
try:
if "parameter" not in self.step:
raise StepExecuteFailException("GetObproxyParameterHandler parameter is not set")
parameter = StringUtils.build_str_on_expr_by_dict(self.step["parameter"], self.task_variable_dict)

sql = "show proxyconfig like '{0}';".format(parameter)
self.stdio.verbose("GetObproxyParameterHandler execute: {0}".format(sql))
data = self.ob_connector.execute_sql_return_cursor_dictionary(sql).fetchall()
self.stdio.verbose("parameter result:{0}".format(data))
if data is None or len(data) == 0:
data = ""
else:
data = data[0]["value"]
if data is None:
data = ""
self.stdio.verbose("parameter result:{0}".format(Util.convert_to_number(str(data))))
if "result" in self.step and "set_value" in self.step["result"]:
self.stdio.verbose("sql execute update task_variable_dict: {0} = {1}".format(self.step["result"]["set_value"], Util.convert_to_number(data)))
self.task_variable_dict[self.step["result"]["set_value"]] = Util.convert_to_number(data)
except Exception as e:
self.stdio.error("GetObproxyParameterHandler execute Exception: {0}".format(e))
raise StepExecuteFailException("GetObproxyParameterHandler execute Exception: {0}".format(e))
finally:
self.ob_connector_pool.release_connection(self.ob_connector)

def update_step_variable_dict(self):
return self.task_variable_dict
3 changes: 3 additions & 0 deletions src/handler/checker/step/stepbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from src.handler.checker.check_exception import StepResultFailException, StepExecuteFailException, ResultFalseException, ResultFailException, StepResultFalseException
from src.handler.checker.step.data_size import DataSizeHandler
from src.handler.checker.step.get_obproxy_parameter import GetObproxyParameterHandler
from src.handler.checker.step.get_system_parameter import GetSystemParameterHandler
from src.handler.checker.result.result import CheckResult
from src.handler.checker.step.local_ssh import StepLocalHandler
Expand Down Expand Up @@ -61,6 +62,8 @@ def execute(self, report):
handler = DataSizeHandler(self.context, self.step, self.cluster, self.task_variable_dict)
elif self.step["type"] == "local_ssh":
handler = StepLocalHandler(self.context, self.step, self.cluster, self.task_variable_dict)
elif self.step["type"] == "get_obproxy_parameter":
handler = GetObproxyParameterHandler(self.context, self.step, task_variable_dict=self.task_variable_dict)
else:
raise StepExecuteFailException("the type not support: {0}".format(self.step["type"]))
self.stdio.verbose("task execute and result")
Expand Down