View | Details | Raw Unified | Return to bug 48617
Collapse All | Expand All

(-)a/nagios/univention-nagios/usr/lib/nagios/plugins/check_univention_slapd_mdb_maxsize (-6 / +7 lines)
 Lines 50-61   args = parser.parse_args() Link Here 
50
ucr = ConfigRegistry()
50
ucr = ConfigRegistry()
51
ucr.load()
51
ucr.load()
52
52
53
service_prefix = 'LISTENER' if args.listener_only else 'SLAPD'
53
service = 'univention-directory-listener' if args.listener_only else 'slapd'
54
service = 'univention-directory-listener' if args.listener_only else 'slapd'
54
ucr_variable = 'listener/cache/mdb/maxsize' if args.listener_only else 'ldap/database/mdb/maxsize'
55
ucr_variable = 'listener/cache/mdb/maxsize' if args.listener_only else 'ldap/database/mdb/maxsize'
55
56
56
57
57
def nagios_exit(state, msg):
58
def nagios_exit(state, msg):
58
	print('%s %s: %s' % (service, {STATE_OK: 'MDB OK', STATE_WARNING: 'MDB WARNING', STATE_CRITICAL: 'MDB CRITICAL'}.get(state, 'MDB UNKNOWN'), msg))
59
	print('%s %s: %s' % (service_prefix, {STATE_OK: 'MDB OK', STATE_WARNING: 'MDB WARNING', STATE_CRITICAL: 'MDB CRITICAL'}.get(state, 'MDB UNKNOWN'), msg))
59
	sys.exit(state)
60
	sys.exit(state)
60
61
61
62
 Lines 70-80   else: Link Here 
70
71
71
files = [file_ for file_ in files if os.path.exists('%s/data.mdb' % (file_))]
72
files = [file_ for file_ in files if os.path.exists('%s/data.mdb' % (file_))]
72
73
73
if files and not os.path.exists('/usr/bin/mdb_stat'):
74
	nagios_exit(STATE_WARNING, 'mdb_stat not found, please install lmdb-utils')
75
76
if not files:
74
if not files:
77
	nagios_exit(STATE_OK, 'Slapd backend is not mdb')
75
	nagios_exit(STATE_OK, 'OpenLDAP backend is not mdb')
76
77
if not os.path.exists('/usr/bin/mdb_stat'):
78
	nagios_exit(STATE_WARNING, 'mdb_stat not found, please install lmdb-utils')
78
79
79
errors = []
80
errors = []
80
warnings = []
81
warnings = []
 Lines 89-95   for mdb_dir in files: Link Here 
89
	try:
90
	try:
90
		in_use = int((int(stat['number of pages used']) * 100) / int(stat['max pages']))
91
		in_use = int((int(stat['number of pages used']) * 100) / int(stat['max pages']))
91
	except KeyError:  # API change in the future
92
	except KeyError:  # API change in the future
92
		nagios_exit(STATE_CRITICAL, 'mdb_stat output could not be parsed: %s' % (output,))
93
		nagios_exit(STATE_CRITICAL, 'output of "mdb_stat -e %s" could not be parsed: %s' % (mdb_dir, output,))
93
94
94
	if in_use >= args.critical:
95
	if in_use >= args.critical:
95
		errors.append("More than %s%% (in fact %s%%) of mdb database %s is use, please increase %s (and restart %s)" % (args.critical, in_use, mdb_dir, ucr_variable, service))
96
		errors.append("More than %s%% (in fact %s%%) of mdb database %s is use, please increase %s (and restart %s)" % (args.critical, in_use, mdb_dir, ucr_variable, service))

Return to bug 48617