Skip to content

Error trying to monitor MariaDB slave #574

@jesusbagpuss

Description

@jesusbagpuss

Using the mysql script to monitor a MariaDB instance that is configured as a slave.

MariaDB doesn't recognise NONBLOCKING or NOLOCK in the first two commands here:

$result = run_query("SHOW SLAVE STATUS NONBLOCKING", $conn);
if ( !$result ) {
$result = run_query("SHOW SLAVE STATUS NOLOCK", $conn);
if ( !$result ) {
$result = run_query("SHOW SLAVE STATUS", $conn);
}
}

Resulting in this error:

<<<mysql>>>
PHP Fatal error:  Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NONBLOCKING' at line 1 in /usr/lib/check_mk_agent/local/mysql:1307
Stack trace:
#0 /usr/lib/check_mk_agent/local/mysql(1307): mysqli_query()
#1 /usr/lib/check_mk_agent/local/mysql(416): run_query()
#2 /usr/lib/check_mk_agent/local/mysql(135): ss_get_mysql_stats()
#3 {main}
  thrown in /usr/lib/check_mk_agent/local/mysql on line 1307

A fix would be to wrap the calls to @mysqli_query($conn, $sql); in run_query in a try/catch block, although this is changing a heavily used function, so may need more validation for some versions of php.

MariaDB version: 10.5.27
PHP version: 8.2.28

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions