1195
1195
def install_nrpe_scripts():
1196
1196
scripts_src = os.path.join(os.environ["CHARM_DIR"], "files",
1198
scripts_dst = "/usr/lib/nagios/plugins"
1199
if not os.path.exists(scripts_dst):
1200
os.makedirs(scripts_dst)
1198
if not os.path.exists(nrpe_scripts_dest):
1199
os.makedirs(nrpe_scripts_dest)
1201
1200
for fname in glob.glob(os.path.join(scripts_src, "*.sh")):
1202
1201
shutil.copy2(fname,
1203
os.path.join(scripts_dst, os.path.basename(fname)))
1206
def update_nrpe_config():
1207
install_nrpe_scripts()
1202
os.path.join(nrpe_scripts_dest, os.path.basename(fname)))
1205
def remove_nrpe_scripts():
1206
scripts_src = os.path.join(os.environ["CHARM_DIR"], "files",
1208
for fname in glob.glob(os.path.join(scripts_src, "*.sh")):
1210
os.remove(os.path.join(nrpe_scripts_dest,
1211
os.path.basename(fname)))
1216
def update_nrpe_config():
1217
config_data = config_get()
1208
1218
nrpe_compat = nrpe.NRPE()
1209
nrpe_compat.add_check('haproxy', 'Check HAProxy', 'check_haproxy.sh')
1210
nrpe_compat.add_check('haproxy_queue', 'Check HAProxy queue depth',
1211
'check_haproxy_queue_depth.sh')
1220
('haproxy', 'Check HAProxy', 'check_haproxy.sh'),
1221
('haproxy_queue', 'Check HAProxy queue depth', 'check_haproxy_queue_depth.sh'),
1223
if config_data['enable_monitoring'] is True:
1224
install_nrpe_scripts()
1225
for check_args in checks_args:
1226
nrpe_compat.add_check(*check_args)
1228
for check_args in checks_args:
1229
if os.path.isfile(nrpe_scripts_dest + '/' + check_args[2]):
1230
nrpe_compat.remove_check(shortname=check_args[0],
1231
description=check_args[1],
1232
check_cmd=check_args[2])
1233
remove_nrpe_scripts()
1212
1234
nrpe_compat.write()