def update_nrpe_config(checks_to_remove=None): """ Update the checks for the nagios plugin. :param checks_to_remove: list of short names of nrpe checks to remove. For example, pass ['radosgw'] to remove the check for the default systemd radosgw service, to make way for per host services. :type checks_to_remove: list """ # python-dbus is used by check_upstart_job apt_install('python-dbus') hostname = nrpe.get_nagios_hostname() current_unit = nrpe.get_nagios_unit_name() nrpe_setup = nrpe.NRPE(hostname=hostname) nrpe.copy_nrpe_checks() if checks_to_remove is not None: log("Removing the following nrpe checks: {}".format(checks_to_remove), level=DEBUG) for svc in checks_to_remove: nrpe_setup.remove_check(shortname=svc) nrpe.add_init_service_checks(nrpe_setup, services(), current_unit) nrpe.add_haproxy_checks(nrpe_setup, current_unit) nrpe_setup.write()
def update_nrpe_config(): # python-dbus is used by check_upstart_job apt_install('python-dbus') hostname = nrpe.get_nagios_hostname() current_unit = nrpe.get_nagios_unit_name() nrpe_setup = nrpe.NRPE(hostname=hostname) nrpe.copy_nrpe_checks() nrpe.add_init_service_checks(nrpe_setup, services(), current_unit) nrpe.add_haproxy_checks(nrpe_setup, current_unit) nrpe_setup.write()
#!/usr/bin/env python2 import re from collections import defaultdict from textx.metamodel import metamodel_from_str from textx.exceptions import TextXSyntaxError from ipaddr import IPv4Network, NetmaskValueError from utils import protocols, services ################################################################################ # GLOBALS/UTILS protocols = protocols() services = services() # Additional service names having different names and/or not # included in `/etc/services`. cservices = [('lpd', 515), ('netbios-ss', 139), ('cmd', 514), ('www', 80), ('ident', 113)] for name, port in cservices: if not name in services: services[name] = port def read_blocks(contents): blocks = contents.split('!') return filter(lambda b: len(b.strip()) > 0, blocks)