diff --git a/check-plugins/mysql-table-indexes/README.rst b/check-plugins/mysql-table-indexes/README.rst index 697ceff5..113f41e9 100644 --- a/check-plugins/mysql-table-indexes/README.rst +++ b/check-plugins/mysql-table-indexes/README.rst @@ -71,7 +71,9 @@ Output: .. code-block:: text - Tables without indexes: employees.current_dept_emp, employees.dept_emp_latest_date [WARNING] + Tables without indexes [WARNING]: + * employees.current_dept_emp + * employees.dept_emp_latest_date States diff --git a/check-plugins/mysql-table-indexes/mysql-table-indexes b/check-plugins/mysql-table-indexes/mysql-table-indexes index 87280c85..34ea4a80 100755 --- a/check-plugins/mysql-table-indexes/mysql-table-indexes +++ b/check-plugins/mysql-table-indexes/mysql-table-indexes @@ -99,6 +99,7 @@ def main(): # init some vars msg = '' state = STATE_OK + tables = [] # TABLE_SCHEMA and TABLE_NAME must be uppercase due to MySQL 8+ sql = ''' @@ -132,20 +133,17 @@ def main(): '''.format(schema['TABLE_SCHEMA'], table['TABLE_NAME']) user_indexes = lib.base.coe(lib.db_mysql.select(conn, sql)) if len(user_indexes) == 0: - msg += '{}.{}, '.format( - schema['TABLE_SCHEMA'], - table['TABLE_NAME'], - ) + tables.append('{}.{}'.format(schema['TABLE_SCHEMA'], table['TABLE_NAME'])) lib.db_mysql.close(conn) - if not msg: + if not tables: msg = 'Everyhing is ok.' else: state = STATE_WARN - msg = 'Tables without indexes: {}{}'.format( - msg[:-2], - lib.base.state2str(state, prefix=' ') + msg = 'Tables without indexes {}:\n* {}'.format( + lib.base.state2str(state), + '\n* '.join(tables), ) # over and out