checkmk icon indicating copy to clipboard operation
checkmk copied to clipboard

fix crash of check postgres_stats when relname contains semicolon

Open thomas1147 opened this issue 2 years ago • 2 comments

Hi,

we have a postgres database where the value of the relname column (table pg_class) contains a semicolon. Since the delimiter of the postgres_stats check is also a semicolon the check can not parse the result correctly and will crash in checkmk.

The Agent Output will be the following (note the two semicolons behind ms_ys, it should be only one): dbtest;ms_ys;;way_schema_history;-1;-1

Exception: ValueError (invalid literal for int() with base 10: 'way_schema_history')

Traceback (version 2.0.0p33):

  File "/omd/sites/prod_slave3/lib/python3/cmk/base/checking.py", line 564, in get_aggregated_result
    result = _aggregate_results(check_function(**kwargs))
  File "/omd/sites/prod_slave3/lib/python3/cmk/base/checking.py", line 796, in _aggregate_results
    perfdata, results = _consume_and_dispatch_result_types(subresults)
  File "/omd/sites/prod_slave3/lib/python3/cmk/base/checking.py", line 840, in _consume_and_dispatch_result_types
    for subr in subresults:
  File "/omd/sites/prod_slave3/lib/python3/cmk/base/api/agent_based/register/check_plugins.py", line 89, in filtered_generator
    for element in generator(*args, **kwargs):
  File "/omd/sites/prod_slave3/lib/python3/cmk/base/api/agent_based/register/check_plugins_legacy.py", line 183, in check_result_generator
    for subresult in subresults:
  File "/omd/sites/prod_slave3/share/check_mk/checks/postgres_stats", line 88, in check_postgres_stats
    last_time = int(value)

This fix will ensure that semicolons in the values of nspname/relname will be removed so that we don't have any issues with the delimiter of the check

thomas1147 avatar Aug 10 '23 12:08 thomas1147

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Aug 10 '23 12:08 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.

thomas1147 avatar Aug 10 '23 12:08 thomas1147