Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions checkman/mysql.galeradonor
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions checkman/mysql.galerasize
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions checkman/mysql.galerastartup
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions checkman/mysql.galerastatus
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions checkman/mysql.galerasync
Original file line number Diff line number Diff line change
@@ -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.
164 changes: 164 additions & 0 deletions checks/mysql
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

values.get('KEY') is not None

  1. 'get' returns None if key not found
  2. use 'is' operator for checking agains object's identity ('==' to check equality)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has been written that way because wsrep_provider may also return False if set and then the if does not eval correctly.

@si-23 si-23 Jul 30, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure it does:

`

d = {}
d['k'] = False
d.get('k', 'none') != 'none'
True
d.get('k') is not None
True
d.get('l', 'none') != 'none'
False
d.get('l') is not None
False
`

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",
}