Module: check_mk
Branch: master
Commit: 3873a8291346e2c5a68909fe9808a0109f6c379e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3873a8291346e2…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Apr 15 11:46:57 2016 +0200
3411 mysql_slave: now max time and related state can be configured if slave-IO and
slave-SQL are not running
---
.werks/3411 | 9 +++++
ChangeLog | 1 +
checks/mysql_slave | 73 +++++++++++++++++++++++-----------
web/plugins/wato/check_parameters.py | 13 ++++++
4 files changed, 72 insertions(+), 24 deletions(-)
diff --git a/.werks/3411 b/.werks/3411
new file mode 100644
index 0000000..daefe79
--- /dev/null
+++ b/.werks/3411
@@ -0,0 +1,9 @@
+Title: mysql_slave: now max time and related state can be configured if slave-IO and
slave-SQL are not running
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1460713517
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index a671347..0aedf0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,7 @@
NOTE: Please refer to the migration notes!
* 3027 mtr (Matt's traceroute): New agent plugin...
* 3410 ipmi: now monitors compact/discrete sensors...
+ * 3411 mysql_slave: now max time and related state can be configured if slave-IO and
slave-SQL are not running
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/checks/mysql_slave b/checks/mysql_slave
index 6d89d6e..aa73d9f 100644
--- a/checks/mysql_slave
+++ b/checks/mysql_slave
@@ -78,40 +78,65 @@ def inventory_mysql_slave(parsed):
def check_mysql_slave(item, params, parsed):
if item in parsed:
data = parsed[item]
-
state = 0
perfdata = []
- output = []
- if data['Slave_IO_Running']:
- output.append('Slave-IO: running')
- else:
- output.append('Slave-IO: not running(!!)')
- state = 2
-
- if data['Slave_SQL_Running']:
- output.append('Slave-SQL: running')
+ if data['Slave_IO_Running'] and data['Slave_SQL_Running']:
+ infotext = 'Slave-IO: running, Slave-SQL: running'
+ seconds_behind_master = data['Seconds_Behind_Master']
+ warn, crit = params.get('seconds_behind_master', (None,
None))
+ set_item_state("slave_running", time.time())
# Makes only sense to monitor the age when the SQL slave is running
- if data['Seconds_Behind_Master'] == 'NULL':
- output.append('Time behind master: NULL (Lost connection?)(!!)')
+ if seconds_behind_master == 'NULL':
+ infotext += ', Time behind master: NULL (Lost connection?)(!!)'
state = 2
else:
- out = 'Time behind Master: %s' %
get_age_human_readable(data['Seconds_Behind_Master'])
- warn, crit = params.get('seconds_behind_master', (None, None))
- if crit != None and data['Seconds_Behind_Master'] > crit:
+ infotext += ', Time behind Master: %s' %
get_age_human_readable(seconds_behind_master)
+ if crit != None and seconds_behind_master > crit:
state = 2
- out += '(!!)'
- elif warn != None and data['Seconds_Behind_Master'] > warn:
- state = max(state, 1)
- out += '(!)'
- output.append(out)
- perfdata.append(('sync_latency',
data['Seconds_Behind_Master'], warn, crit))
- else:
- output.append('Slave-SQL: not running(!!)')
+ elif warn != None and seconds_behind_master > warn:
+ state = 1
+
+ if state:
+ infotext += " (warn crit at %s/%s)" % \
+ (get_age_human_readable(warn),
+ get_age_human_readable(crit))
+
+ perfdata.append(('sync_latency', seconds_behind_master, warn,
crit))
+
+ elif not data['Slave_IO_Running'] and not
data['Slave_SQL_Running']:
+ old_value = get_item_state("slave_running")
+ not_running_state, not_running_max_seconds = \
+ params.get("slave_not_running", (None, None))
+
+ if old_value != None and not_running_state != None and \
+ not_running_max_seconds != None:
+
+ not_running_age = time.time() - old_value
+ infotext = 'Slave-IO: not running, Slave-SQL: not running, Age: %s
(crit at %s)' % \
+ (get_age_human_readable(not_running_age),
+ get_age_human_readable(not_running_max_seconds))
+
+ if not_running_age < not_running_max_seconds:
+ state = not_running_state
+ else:
+ state = 2
+
+ else:
+ infotext = "Slave-IO: not running(!!), Slave-SQL: not
running(!!)"
+ state = 2
+
+ elif not data['Slave_IO_Running'] and data['Slave_SQL_Running']:
+ infotext = 'Slave-IO: not running(!!), Slave-SQL: running'
+ state = 2
+
+ elif data['Slave_IO_Running'] and not data['Slave_SQL_Running']:
+ infotext = 'Slave-IO: running, Slave-SQL: not running(!!)'
state = 2
- return state, ', '.join(output), perfdata
+ return state, infotext, perfdata
+
check_info['mysql_slave'] = {
"parse_function" : parse_mysql_slave,
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 9d717e1..f2db844 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -6695,6 +6695,19 @@ register_check_parameters(
]
)
),
+ ( "slave_not_running",
+ Tuple(
+ title = _("State and max. time if slave is not running"),
+ help = _("This rule allows you to configure the state which
will be "
+ "reported until the configured time will be
exceeded."),
+ elements = [
+ MonitoringState(
+ default_value = 2,
+ ),
+ Age(),
+ ]
+ ),
+ ),
],
optional_keys = None),
TextAscii(