diff --git a/checkman/mysql.galeradonor b/checkman/mysql.galeradonor new file mode 100644 index 00000000000..8161b1ca17a --- /dev/null +++ b/checkman/mysql.galeradonor @@ -0,0 +1,18 @@ +title: MySQL Database: Galera sync status +agents: linux +catalog: app/mysql +license: GPL +distribution: check_mk +description: + This checks monitors if the value of wsrep_sst_donor has changed + since service discovery or last tabula rasa. + + This check needs the agent plugin {mk_mysql} to be installed. + Further details about this plugin and monitoring of MySQL can be + found in the Check_MK online documentation in the article + "Monitoring MySQL with Check_MK". + +inventory: + On each host where the agent plugin {mk_mysql} is being installed + and the MySQL daemon is running one service per instance is being generated + if the instance has Galera enabled. diff --git a/checkman/mysql.galerasize b/checkman/mysql.galerasize new file mode 100644 index 00000000000..0062ded6081 --- /dev/null +++ b/checkman/mysql.galerasize @@ -0,0 +1,18 @@ +title: MySQL Database: Galera sync status +agents: linux +catalog: app/mysql +license: GPL +distribution: check_mk +description: + This checks monitors the size of the Galera cluster and compares + it to size size of the cluster at service discovery. + + This check needs the agent plugin {mk_mysql} to be installed. + Further details about this plugin and monitoring of MySQL can be + found in the Check_MK online documentation in the article + "Monitoring MySQL with Check_MK". + +inventory: + On each host where the agent plugin {mk_mysql} is being installed + and the MySQL daemon is running one service per instance is being generated + if the instance has Galera enabled. diff --git a/checkman/mysql.galerastartup b/checkman/mysql.galerastartup new file mode 100644 index 00000000000..315fea03d72 --- /dev/null +++ b/checkman/mysql.galerastartup @@ -0,0 +1,17 @@ +title: MySQL Database: Galera sync status +agents: linux +catalog: app/mysql +license: GPL +distribution: check_mk +description: + This checks monitors the value of the Galera cluster address. + + This check needs the agent plugin {mk_mysql} to be installed. + Further details about this plugin and monitoring of MySQL can be + found in the Check_MK online documentation in the article + "Monitoring MySQL with Check_MK". + +inventory: + On each host where the agent plugin {mk_mysql} is being installed + and the MySQL daemon is running one service per instance is being generated + if the instance has Galera enabled. diff --git a/checkman/mysql.galerastatus b/checkman/mysql.galerastatus new file mode 100644 index 00000000000..8b7fe37ab90 --- /dev/null +++ b/checkman/mysql.galerastatus @@ -0,0 +1,18 @@ +title: MySQL Database: Galera sync status +agents: linux +catalog: app/mysql +license: GPL +distribution: check_mk +description: + This checks monitors the status of the local Galera node and + returns CRIT when it is not "Primary". + + This check needs the agent plugin {mk_mysql} to be installed. + Further details about this plugin and monitoring of MySQL can be + found in the Check_MK online documentation in the article + "Monitoring MySQL with Check_MK". + +inventory: + On each host where the agent plugin {mk_mysql} is being installed + and the MySQL daemon is running one service per instance is being generated + if the instance has Galera enabled. diff --git a/checkman/mysql.galerasync b/checkman/mysql.galerasync new file mode 100644 index 00000000000..9912d1e4cff --- /dev/null +++ b/checkman/mysql.galerasync @@ -0,0 +1,18 @@ +title: MySQL Database: Galera sync status +agents: linux +catalog: app/mysql +license: GPL +distribution: check_mk +description: + For Galera enabled MySQL instances this check monitors the + state of the sync on the local instance. + + This check needs the agent plugin {mk_mysql} to be installed. + Further details about this plugin and monitoring of MySQL can be + found in the Check_MK online documentation in the article + "Monitoring MySQL with Check_MK". + +inventory: + On each host where the agent plugin {mk_mysql} is being installed + and the MySQL daemon is running one service per instance is being generated + if the instance has Galera enabled. diff --git a/checks/mysql b/checks/mysql index 03276ce1451..302eb81f850 100644 --- a/checks/mysql +++ b/checks/mysql @@ -221,3 +221,167 @@ check_info['mysql.connections'] = { "group": "mysql_connections", "has_perfdata": True, } + +#. +# .--Galera Sync Status--------------------------------------------------. +# | ____ _ ____ | +# | / ___| __ _| | ___ _ __ __ _ / ___| _ _ _ __ ___ | +# | | | _ / _` | |/ _ \ '__/ _` | \___ \| | | | '_ \ / __| | +# | | |_| | (_| | | __/ | | (_| | ___) | |_| | | | | (__ | +# | \____|\__,_|_|\___|_| \__,_| |____/ \__, |_| |_|\___| | +# | |___/ | +# | ____ _ _ | +# | / ___|| |_ __ _| |_ _ _ ___ | +# | \___ \| __/ _` | __| | | / __| | +# | ___) | || (_| | |_| |_| \__ \ | +# | |____/ \__\__,_|\__|\__,_|___/ | +# | | +# +----------------------------------------------------------------------+ + +def inventory_mysql_galerasync(parsed): + for instance, values in parsed.iteritems(): + if values.get('wsrep_provider', 'none') != 'none' and u'wsrep_local_state_comment' in values: + yield instance, {} + +@get_parsed_item_data +def check_mysql_galerasync(item, _no_params, data): + if u'wsrep_local_state_comment' in data: + if data[u'wsrep_local_state_comment'] == 'Synced': + state = 0 + else: + state = 2 + return (state, 'WSREP local state comment: %s' % data[u'wsrep_local_state_comment']) + +check_info['mysql.galerasync'] = { + "inventory_function" : inventory_mysql_galerasync, + "check_function" : check_mysql_galerasync, + "service_description" : "MySQL Galera Sync %s", +} + +#. +# .--Galera Donor--------------------------------------------------------. +# | ____ _ ____ | +# | / ___| __ _| | ___ _ __ __ _ | _ \ ___ _ __ ___ _ __ | +# | | | _ / _` | |/ _ \ '__/ _` | | | | |/ _ \| '_ \ / _ \| '__| | +# | | |_| | (_| | | __/ | | (_| | | |_| | (_) | | | | (_) | | | +# | \____|\__,_|_|\___|_| \__,_| |____/ \___/|_| |_|\___/|_| | +# | | +# +----------------------------------------------------------------------+ + +def inventory_mysql_galeradonor(parsed): + for instance, values in parsed.iteritems(): + if values.get('wsrep_provider', 'none') != 'none' and u'wsrep_sst_donor' in values: + yield instance, {'wsrep_sst_donor': values['wsrep_sst_donor']} + +@get_parsed_item_data +def check_mysql_galeradonor(item, params, data): + if u'wsrep_sst_donor' in data: + if data[u'wsrep_sst_donor'] == params['wsrep_sst_donor']: + return (0, 'WSREP sst donor contains "%s"' % data[u'wsrep_sst_donor']) + else: + return (1, 'WSREP sst donor contains "%s" (was at discovery "%s")' % (data[u'wsrep_sst_donor'], params['wsrep_sst_donor'])) + +check_info['mysql.galeradonor'] = { + "inventory_function" : inventory_mysql_galeradonor, + "check_function" : check_mysql_galeradonor, + "service_description" : "MySQL Galera Donor %s", +} + +#. +# .--Galera Startup------------------------------------------------------. +# | ____ _ ____ _ _ | +# | / ___| __ _| | ___ _ __ __ _ / ___|| |_ __ _ _ __| |_ _ _ _ __ | +# || | _ / _` | |/ _ \ '__/ _` | \___ \| __/ _` | '__| __| | | | '_ \ | +# || |_| | (_| | | __/ | | (_| | ___) | || (_| | | | |_| |_| | |_) | | +# | \____|\__,_|_|\___|_| \__,_| |____/ \__\__,_|_| \__|\__,_| .__/ | +# | |_| | +# +----------------------------------------------------------------------+ + +def inventory_mysql_galerastartup(parsed): + for instance, values in parsed.iteritems(): + if values.get('wsrep_provider', 'none') != 'none' and u'wsrep_cluster_address' in values: + yield instance, {} + +@get_parsed_item_data +def check_mysql_galerastartup(item, _no_params, data): + if u'wsrep_cluster_address' in data: + if data[u'wsrep_cluster_address'] == 'gcomm://': + return (2, 'WSREP cluster address is empty') + else: + return (0, 'WSREP cluster address contains %s' % data[u'wsrep_cluster_address']) + +check_info['mysql.galerastartup'] = { + "inventory_function" : inventory_mysql_galerastartup, + "check_function" : check_mysql_galerastartup, + "service_description" : "MySQL Galera Startup %s", +} + +#. +# .--Galera Cluster Size-------------------------------------------------. +# | ____ _ ____ _ _ | +# | / ___| __ _| | ___ _ __ __ _ / ___| |_ _ ___| |_ ___ _ __ | +# | | | _ / _` | |/ _ \ '__/ _` | | | | | | | / __| __/ _ \ '__| | +# | | |_| | (_| | | __/ | | (_| | | |___| | |_| \__ \ || __/ | | +# | \____|\__,_|_|\___|_| \__,_| \____|_|\__,_|___/\__\___|_| | +# | | +# | ____ _ | +# | / ___|(_)_______ | +# | \___ \| |_ / _ \ | +# | ___) | |/ / __/ | +# | |____/|_/___\___| | +# | | +# +----------------------------------------------------------------------+ + +def inventory_mysql_galerasize(parsed): + for instance, values in parsed.iteritems(): + if values.get('wsrep_provider', 'none') != 'none' and u'wsrep_cluster_size' in values: + yield instance, {'invsize': saveint(values[u'wsrep_cluster_size'])} + +@get_parsed_item_data +def check_mysql_galerasize(item, params, data): + if u'wsrep_cluster_size' in data: + size = saveint(data[u'wsrep_cluster_size']) + res = 0 + txt = 'Cluster Size is %d' % size + perfdata = [('galera_size', size)] + if size != params['invsize']: + res = 2 + txt += ' (was at discovery %d)' % params['invsize'] + return (res, txt, perfdata) + +check_info['mysql.galerasize'] = { + "inventory_function" : inventory_mysql_galerasize, + "check_function" : check_mysql_galerasize, + "service_description" : "MySQL Galera Size %s", + "has_perfdata" : True, +} + +#. +# .--Galera Status-------------------------------------------------------. +# | ____ _ ____ _ _ | +# | / ___| __ _| | ___ _ __ __ _ / ___|| |_ __ _| |_ _ _ ___ | +# | | | _ / _` | |/ _ \ '__/ _` | \___ \| __/ _` | __| | | / __| | +# | | |_| | (_| | | __/ | | (_| | ___) | || (_| | |_| |_| \__ \ | +# | \____|\__,_|_|\___|_| \__,_| |____/ \__\__,_|\__|\__,_|___/ | +# | | +# +----------------------------------------------------------------------+ + +def inventory_mysql_galerastatus(parsed): + for instance, values in parsed.iteritems(): + if values.get('wsrep_provider', 'none') != 'none' and u'wsrep_cluster_status' in values: + yield instance, {} + +@get_parsed_item_data +def check_mysql_galerastatus(item, _no_params, data): + if u'wsrep_cluster_status' in data: + if data[u'wsrep_cluster_status'] == 'Primary': + state = 0 + else: + state = 2 + return (state, 'WSREP cluster status: %s' % data[u'wsrep_cluster_status']) + +check_info['mysql.galerastatus'] = { + "inventory_function" : inventory_mysql_galerastatus, + "check_function" : check_mysql_galerastatus, + "service_description" : "MySQL Galera Status %s", +}