1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
OK = 0
WARN = 1
CRIT = 2
UNKNOWN = 3
def extract_values(info):
values = {}
for line in info:
key = line[0].replace(':','')
value = " ".join(line[1:])
values[key] = value
return values
def inventory_mysql_repl_status(info):
inventory = []
try:
values = extract_values(info)
if 'Slave_IO_Running' in values:
inventory.append(('Slave_IO_Running', ['IO']))
if 'Slave_SQL_Running' in values:
inventory.append(('Slave_SQL_Running', ['SQL']))
return inventory
except Exception, e:
return []
def str2float(str):
try:
return float(str)
except ValueError:
return 0.0
def check_mysql_repl_status(item, params, info):
try:
values = extract_values(info)
perfdata = [ ("Seconds_Behind_Master", str2float(values['Seconds_Behind_Master']), 5, 10, "", "") ]
if item in values:
if values[item] == 'Yes':
return (OK, 'Slave %s is running' % params[0], perfdata)
return (CRIT, 'Slave %s is not(!!) running: %s' % (params[0], values['Last_%s_Error' % params[0]]), perfdata)
except Exception, e:
return (UNKNOWN, "mysql_repl check failed: %", e.message)
check_info["mysql_repl"] = {
'check_function': check_mysql_repl_status,
'inventory_function': inventory_mysql_repl_status,
'service_description': 'mySQL Replication CLient Status',
'has_perfdata': True,
}
|