74 lines
1.9 KiB
C++
74 lines
1.9 KiB
C++
#pragma once
|
|
|
|
/*
|
|
* Copyright (c) 2018 MariaDB Corporation Ab
|
|
*
|
|
* Use of this software is governed by the Business Source License included
|
|
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
|
|
*
|
|
* Change Date: 2020-01-01
|
|
*
|
|
* On the date above, in accordance with the Business Source License, use
|
|
* of this software will be governed by version 2 or later of the General
|
|
* Public License.
|
|
*/
|
|
|
|
#include <maxscale/cppdefs.hh>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <maxscale/monitor.h>
|
|
|
|
/** Utility macro for printing both MXS_ERROR and json error */
|
|
#define PRINT_MXS_JSON_ERROR(err_out, format, ...)\
|
|
do {\
|
|
MXS_ERROR(format, ##__VA_ARGS__);\
|
|
if (err_out)\
|
|
{\
|
|
*err_out = mxs_json_error_append(*err_out, format, ##__VA_ARGS__);\
|
|
}\
|
|
} while (false)
|
|
|
|
using std::string;
|
|
|
|
typedef std::vector<string> StringVector;
|
|
typedef std::vector<MXS_MONITORED_SERVER*> ServerVector;
|
|
|
|
extern const int64_t SERVER_ID_UNKNOWN;
|
|
|
|
/**
|
|
* Scan a server id from a string.
|
|
*
|
|
* @param id_string
|
|
* @return Server id, or -1 if scanning fails
|
|
*/
|
|
int64_t scan_server_id(const char* id_string);
|
|
|
|
/**
|
|
* Query one row of results, save strings to array. Any additional rows are ignored.
|
|
*
|
|
* @param database The database to query.
|
|
* @param query The query to execute.
|
|
* @param expected_cols How many columns the result should have.
|
|
* @param output The output array to populate.
|
|
* @return True on success.
|
|
*/
|
|
bool query_one_row(MXS_MONITORED_SERVER *database, const char* query, unsigned int expected_cols,
|
|
StringVector* output);
|
|
|
|
/**
|
|
* Get MariaDB connection error strings from all the given servers, form one string.
|
|
*
|
|
* @param slaves Servers with errors
|
|
* @return Concatenated string.
|
|
*/
|
|
string get_connection_errors(const ServerVector& servers);
|
|
|
|
/**
|
|
* Generates a list of server names separated by ', '
|
|
*
|
|
* @param array The servers
|
|
* @return Server names
|
|
*/
|
|
string monitored_servers_to_string(const ServerVector& array);
|