Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def _do_not_run(self):
# If I'm the master, ignore the command and raise a log
if self.app.is_master:
message = "Received message to not run. " \
"I am the Master arbiter, ignore and continue to run."
log... | [
"The master arbiter tells to its spare arbiters to not run.\n\n A master arbiter will ignore this request and it will return an object\n containing some properties:\n '_status': 'ERR' because of the error\n `_message`: some more explanations about the error\n\n :return: None\n ... |
Please provide a description of the function:def linkify_one_command_with_commands(self, commands, prop):
for i in self:
command = getattr(i, prop, '').strip()
if command:
setattr(i, prop, self.create_commandcall(i, commands, command))
else:
... | [
"\n Link a command to a property (check_command for example)\n\n :param commands: commands object\n :type commands: alignak.objects.command.Commands\n :param prop: property name\n :type prop: str\n :param default: default command to use if the property is not defined\n ... |
Please provide a description of the function:def linkify_command_list_with_commands(self, commands, prop):
for i in self:
if not hasattr(i, prop):
continue
commands_list = strip_and_uniq(getattr(i, prop, ''))
cmds_list = []
for command in... | [
"\n Link a command list (commands with , between) in real CommandCalls\n\n :param commands: commands object\n :type commands: alignak.objects.command.Commands\n :param prop: property name\n :type prop: str\n :return: None\n "
] |
Please provide a description of the function:def create_commandcall(prop, commands, command):
cc = {
'commands': commands,
'call': command
}
if hasattr(prop, 'enable_environment_macros'):
cc['enable_environment_macros'] = prop.enable_environment_macr... | [
"\n Create CommandCall object with command\n\n :param prop: property\n :type prop: str\n :param commands: all commands\n :type commands: alignak.objects.command.Commands\n :param command: a command object\n :type command: str\n :return: a commandCall object\n ... |
Please provide a description of the function:def _push_broks(self):
data = cherrypy.request.json
with self.app.arbiter_broks_lock:
logger.debug("Pushing %d broks", len(data['broks']))
self.app.arbiter_broks.extend([unserialize(elem, True) for elem in data['broks']]) | [
"Push the provided broks objects to the broker daemon\n\n Only used on a Broker daemon by the Arbiter\n\n :param: broks\n :type: list\n :return: None\n "
] |
Please provide a description of the function:def clean_params(self, params):
clean_p = {}
for elt in params:
elts = elt.split('=', 1)
if len(elts) == 1: # error, there is no = !
self.add_error("the parameter %s is malformed! (no = sign)" % elts[0])
... | [
"Convert a list of parameters (key=value) into a dict\n\n This function is used to transform Nagios (or ini) like formated parameters (key=value)\n to a dictionary.\n\n :param params: parameters list\n :type params: list\n :return: dict with key and value. Log error if malformed\n... |
Please provide a description of the function:def load_params(self, params):
logger.debug("Alignak parameters:")
for key, value in sorted(self.clean_params(params).items()):
update_attribute = None
# Maybe it's a variable as $USER$ or $ANOTHERVARIABLE$
# so l... | [
"Load parameters from main configuration file\n\n :param params: parameters list (converted right at the beginning)\n :type params:\n :return: None\n "
] |
Please provide a description of the function:def _cut_line(line):
# punct = '"#$%&\'()*+/<=>?@[\\]^`{|}~'
if re.search("([\t\n\r]+|[\x0b\x0c ]{3,})+", line):
tmp = re.split("([\t\n\r]+|[\x0b\x0c ]{3,})+", line, 1)
else:
tmp = re.split("[" + string.whitespace + "]... | [
"Split the line on whitespaces and remove empty chunks\n\n :param line: the line to split\n :type line: str\n :return: list of strings\n :rtype: list\n "
] |
Please provide a description of the function:def read_legacy_cfg_files(self, cfg_files, alignak_env_files=None):
# pylint: disable=too-many-nested-blocks,too-many-statements
# pylint: disable=too-many-branches, too-many-locals
cfg_buffer = ''
if not cfg_files:
return... | [
"Read and parse the Nagios legacy configuration files\n and store their content into a StringIO object which content\n will be returned as the function result\n\n :param cfg_files: list of file to read\n :type cfg_files: list\n :param alignak_env_files: name of the alignak environ... |
Please provide a description of the function:def read_config_buf(self, cfg_buffer):
# pylint: disable=too-many-locals, too-many-branches
objects = {}
if not self.read_config_silent:
if cfg_buffer:
logger.info("Parsing the legacy configuration files...")
... | [
"The legacy configuration buffer (previously returned by Config.read_config())\n\n If the buffer is empty, it will return an empty dictionary else it will return a\n dictionary containing dictionary items tha tmay be used to create Alignak\n objects\n\n :param cfg_buffer: buffer containi... |
Please provide a description of the function:def add_self_defined_objects(raw_objects):
logger.info("- creating internally defined commands...")
if 'command' not in raw_objects:
raw_objects['command'] = []
# Business rule
raw_objects['command'].append({
'... | [
"Add self defined command objects for internal processing ;\n bp_rule, _internal_host_up, _echo, _internal_host_check, _interna_service_check\n\n :param raw_objects: Raw config objects dict\n :type raw_objects: dict\n :return: raw_objects with some more commands\n :rtype: dict\n ... |
Please provide a description of the function:def early_create_objects(self, raw_objects):
types_creations = self.__class__.types_creations
early_created_types = self.__class__.early_created_types
logger.info("Creating objects...")
for o_type in sorted(types_creations):
... | [
"Create the objects needed for the post configuration file initialization\n\n :param raw_objects: dict with all object with str values\n :type raw_objects: dict\n :return: None\n "
] |
Please provide a description of the function:def create_objects(self, raw_objects):
types_creations = self.__class__.types_creations
early_created_types = self.__class__.early_created_types
logger.info("Creating objects...")
# Before really creating the objects, we add some gh... | [
"Create all the objects got after the post configuration file initialization\n\n :param raw_objects: dict with all object with str values\n :type raw_objects: dict\n :return: None\n "
] |
Please provide a description of the function:def create_objects_for_type(self, raw_objects, o_type):
# Ex: the above code do for timeperiods:
# timeperiods = []
# for timeperiodcfg in objects['timeperiod']:
# t = Timeperiod(timeperiodcfg)
# timeperiods.append(t)
... | [
"Generic function to create objects regarding the o_type\n\n This function create real Alignak objects from the raw data got from the configuration.\n\n :param raw_objects: Raw objects\n :type raw_objects: dict\n :param o_type: the object type we want to create\n :type o_type: obj... |
Please provide a description of the function:def early_arbiter_linking(self, arbiter_name, params):
if not self.arbiters:
params.update({
'name': arbiter_name, 'arbiter_name': arbiter_name,
'host_name': socket.gethostname(),
'address': '127.0... | [
" Prepare the arbiter for early operations\n\n :param arbiter_name: default arbiter name if no arbiter exist in the configuration\n :type arbiter_name: str\n :return: None\n "
] |
Please provide a description of the function:def linkify_one_command_with_commands(self, commands, prop):
if not hasattr(self, prop):
return
command = getattr(self, prop).strip()
if not command:
setattr(self, prop, None)
return
data = {"com... | [
"\n Link a command\n\n :param commands: object commands\n :type commands: object\n :param prop: property name\n :type prop: str\n :return: None\n "
] |
Please provide a description of the function:def linkify(self):
self.services.optimize_service_search(self.hosts)
# First linkify myself like for some global commands
self.linkify_one_command_with_commands(self.commands, 'host_perfdata_command')
self.linkify_one_command_with_c... | [
" Make 'links' between elements, like a host got a services list\n with all its services in it\n\n :return: None\n "
] |
Please provide a description of the function:def clean(self):
logger.debug("Cleaning configuration objects before configuration sending:")
types_creations = self.__class__.types_creations
for o_type in types_creations:
(_, _, inner_property, _, _) = types_creations[o_type]
... | [
"Wrapper for calling the clean method of services attribute\n\n :return: None\n "
] |
Please provide a description of the function:def warn_about_unmanaged_parameters(self):
properties = self.__class__.properties
unmanaged = []
for prop, entry in list(properties.items()):
if not entry.managed and hasattr(self, prop):
if entry.help:
... | [
"used to raise warning if the user got parameter\n that we do not manage from now\n\n :return: None\n "
] |
Please provide a description of the function:def explode(self):
# first elements, after groups
self.contacts.explode(self.contactgroups, self.notificationways)
self.contactgroups.explode()
self.hosts.explode(self.hostgroups, self.contactgroups)
self.hostgroups.explode(... | [
"Use to fill groups values on hosts and create new services\n (for host group ones)\n\n :return: None\n "
] |
Please provide a description of the function:def apply_dependencies(self):
self.hosts.apply_dependencies()
self.services.apply_dependencies(self.hosts) | [
"Creates dependencies links between elements.\n\n :return: None\n "
] |
Please provide a description of the function:def apply_inheritance(self):
# inheritance properties by template
self.hosts.apply_inheritance()
self.contacts.apply_inheritance()
self.services.apply_inheritance()
self.servicedependencies.apply_inheritance()
self.hos... | [
"Apply inheritance over templates\n Template can be used in the following objects::\n\n * hosts\n * contacts\n * services\n * servicedependencies\n * hostdependencies\n * timeperiods\n * hostsextinfo\n * servicesextinfo\n * serviceescalations\n ... |
Please provide a description of the function:def fill_default_configuration(self):
logger.debug("Filling the unset properties with their default value:")
types_creations = self.__class__.types_creations
for o_type in types_creations:
(_, _, inner_property, _, _) = types_cre... | [
"Fill objects properties with default value if necessary\n\n :return: None\n "
] |
Please provide a description of the function:def fill_default_realm(self):
if not getattr(self, 'realms', None):
# Create a default realm so all hosts without realm will be linked with it
default = Realm({
'realm_name': u'All', 'alias': u'Self created default rea... | [
"Check if a realm is defined, if not\n Create a new one (default) and tag everyone that do not have\n a realm prop to be put in this realm\n\n :return: None\n "
] |
Please provide a description of the function:def log_daemons_list(self):
daemons = [self.arbiters, self.schedulers, self.pollers,
self.brokers, self.reactionners, self.receivers]
for daemons_list in daemons:
if not daemons_list:
logger.debug("- %ss... | [
"Log Alignak daemons list\n\n :return:\n "
] |
Please provide a description of the function:def fill_default_satellites(self, alignak_launched=False):
# pylint: disable=too-many-branches, too-many-locals, too-many-statements
# Log all satellites list
logger.debug("Alignak configured daemons list:")
self.log_daemons_list()
... | [
"If a required satellite is missing in the configuration, we create a new satellite\n on localhost with some default values\n\n :param alignak_launched: created daemons are to be launched or not\n :type alignak_launched: bool\n :return: None\n "
] |
Please provide a description of the function:def got_broker_module_type_defined(self, module_type):
for broker_link in self.brokers:
for module in broker_link.modules:
if module.is_a_module(module_type):
return True
return False | [
"Check if a module type is defined in one of the brokers\n\n :param module_type: module type to search for\n :type module_type: str\n :return: True if mod_type is found else False\n :rtype: bool\n "
] |
Please provide a description of the function:def got_scheduler_module_type_defined(self, module_type):
for scheduler_link in self.schedulers:
for module in scheduler_link.modules:
if module.is_a_module(module_type):
return True
return False | [
"Check if a module type is defined in one of the schedulers\n\n :param module_type: module type to search for\n :type module_type: str\n :return: True if mod_type is found else False\n :rtype: bool\n TODO: Factorize it with got_broker_module_type_defined\n "
] |
Please provide a description of the function:def got_arbiter_module_type_defined(self, module_type):
for arbiter in self.arbiters:
# Do like the linkify will do after....
for module in getattr(arbiter, 'modules', []):
# So look at what the arbiter try to call as ... | [
"Check if a module type is defined in one of the arbiters\n Also check the module name\n\n :param module_type: module type to search for\n :type module_type: str\n :return: True if mod_type is found else False\n :rtype: bool\n TODO: Factorize it with got_broker_module_type_... |
Please provide a description of the function:def create_business_rules(self):
self.hosts.create_business_rules(self.hosts, self.services,
self.hostgroups, self.servicegroups,
self.macromodulations, self.timeperiods)
... | [
"Create business rules for hosts and services\n\n :return: None\n "
] |
Please provide a description of the function:def create_business_rules_dependencies(self):
for item in itertools.chain(self.hosts, self.services):
if not item.got_business_rule:
continue
bp_items = item.business_rule.list_all_elements()
for bp_item_... | [
"Create business rules dependencies for hosts and services\n\n :return: None\n "
] |
Please provide a description of the function:def hack_old_nagios_parameters(self):
# pylint: disable=too-many-branches
modules = []
# For status_dat
if getattr(self, 'status_file', None) and getattr(self, 'object_cache_file', None):
msg = "The configuration parameter... | [
" Check if modules exist for some of the Nagios legacy parameters.\n\n If no module of the required type is present, it alerts the user that the parameters will\n be ignored and the functions will be disabled, else it encourages the user to set the\n correct parameters in the installed modules.... |
Please provide a description of the function:def propagate_timezone_option(self):
if self.use_timezone:
# first apply myself
os.environ['TZ'] = self.use_timezone
time.tzset()
tab = [self.schedulers, self.pollers, self.brokers, self.receivers, self.reacti... | [
"Set our timezone value and give it too to unset satellites\n\n :return: None\n "
] |
Please provide a description of the function:def linkify_templates(self):
self.hosts.linkify_templates()
self.contacts.linkify_templates()
self.services.linkify_templates()
self.servicedependencies.linkify_templates()
self.hostdependencies.linkify_templates()
sel... | [
" Like for normal object, we link templates with each others\n\n :return: None\n "
] |
Please provide a description of the function:def check_error_on_hard_unmanaged_parameters(self):
valid = True
if self.use_regexp_matching:
msg = "use_regexp_matching parameter is not managed."
logger.warning(msg)
self.add_warning(msg)
valid &= Fal... | [
"Some parameters are just not managed like O*HP commands and regexp capabilities\n\n :return: True if we encounter an error, otherwise False\n :rtype: bool\n "
] |
Please provide a description of the function:def is_correct(self): # pylint: disable=too-many-branches, too-many-statements, too-many-locals
logger.info('Running pre-flight check on configuration data, initial state: %s',
self.conf_is_correct)
valid = self.conf_is_correct
... | [
"Check if all elements got a good configuration\n\n :return: True if the configuration is correct else False\n :rtype: bool\n "
] |
Please provide a description of the function:def explode_global_conf(self):
for cls, _, strclss, _, _ in list(self.types_creations.values()):
logger.debug("Applying global conf for the class '%s'...", strclss)
cls.load_global_conf(self) | [
"Explode parameters like cached_service_check_horizon in the\n Service class in a cached_check_horizon manner, o*hp commands etc\n\n :return: None\n "
] |
Please provide a description of the function:def remove_templates(self):
self.hosts.remove_templates()
self.contacts.remove_templates()
self.services.remove_templates()
self.servicedependencies.remove_templates()
self.hostdependencies.remove_templates()
self.time... | [
"Clean useless elements like templates because they are not needed anymore\n\n :return: None\n "
] |
Please provide a description of the function:def show_errors(self):
if self.configuration_warnings:
logger.warning("Configuration warnings:")
for msg in self.configuration_warnings:
logger.warning(msg)
if self.configuration_errors:
logger.warn... | [
"\n Loop over configuration warnings and log them as INFO log\n Loop over configuration errors and log them as INFO log\n\n Note that the warnings and errors are logged on the fly during the configuration parsing.\n It is not necessary to log as WARNING and ERROR in this function which i... |
Please provide a description of the function:def create_packs(self):
# pylint: disable=too-many-statements,too-many-locals,too-many-branches, unused-argument
logger.info("- creating hosts packs for the realms:")
# We create a graph with host in nodes
graph = Graph()
gra... | [
"Create packs of hosts and services (all dependencies are resolved)\n It create a graph. All hosts are connected to their\n parents, and hosts without parent are connected to host 'root'.\n services are linked to their host. Dependencies between hosts/services are managed.\n REF: doc/pac... |
Please provide a description of the function:def cut_into_parts(self):
# pylint: disable=too-many-branches, too-many-locals, too-many-statements
# User must have set a spare if he needed one
logger.info("Splitting the configuration into parts:")
nb_parts = 0
for realm in... | [
"Cut conf into part for scheduler dispatch.\n\n Basically it provides a set of host/services for each scheduler that\n have no dependencies between them\n\n :return: None\n "
] |
Please provide a description of the function:def prepare_for_sending(self):
if [arbiter_link for arbiter_link in self.arbiters if arbiter_link.spare]:
logger.info('Serializing the configuration for my spare arbiter...')
# Now serialize the whole configuration, for sending to sp... | [
"The configuration needs to be serialized before being sent to a spare arbiter\n\n :return: None\n "
] |
Please provide a description of the function:def dump(self, dump_file_name=None):
config_dump = {}
for _, _, category, _, _ in list(self.types_creations.values()):
try:
objs = [jsonify_r(i) for i in getattr(self, category)]
except (TypeError, AttributeEr... | [
"Dump configuration to a file in a JSON format\n\n :param dump_file_name: the file to dump configuration to\n :type dump_file_name: str\n :return: None\n "
] |
Please provide a description of the function:def add(self, elt):
if isinstance(elt, Brok):
# For brok, we tag the brok with our instance_id
elt.instance_id = self.instance_id
if elt.type == 'monitoring_log':
# The brok is a monitoring event
... | [
"Generic function to add objects to the daemon internal lists.\n Manage Broks, External commands\n\n :param elt: objects to add\n :type elt: alignak.AlignakObject\n :return: None\n "
] |
Please provide a description of the function:def push_broks_to_broker(self): # pragma: no cover - not used!
someone_is_concerned = False
sent = False
for broker_link in self.conf.brokers:
# Send only if the broker is concerned...
if not broker_link.manage_arbite... | [
"Send all broks from arbiter internal list to broker\n\n The arbiter get some broks and then pushes them to all the brokers.\n\n :return: None\n "
] |
Please provide a description of the function:def push_external_commands_to_schedulers(self): # pragma: no cover - not used!
# Now get all external commands and push them to the schedulers
for external_command in self.external_commands:
self.external_commands_manager.resolve_command... | [
"Send external commands to schedulers\n\n :return: None\n "
] |
Please provide a description of the function:def get_broks_from_satellites(self): # pragma: no cover - not used!
for satellites in [self.conf.brokers, self.conf.schedulers,
self.conf.pollers, self.conf.reactionners, self.conf.receivers]:
for satellite in satellit... | [
"Get broks from my all internal satellite links\n\n The arbiter get the broks from ALL the known satellites\n\n :return: None\n "
] |
Please provide a description of the function:def get_initial_broks_from_satellites(self):
for satellites in [self.conf.brokers, self.conf.schedulers,
self.conf.pollers, self.conf.reactionners, self.conf.receivers]:
for satellite in satellites:
# Ge... | [
"Get initial broks from my internal satellite links\n\n :return: None\n "
] |
Please provide a description of the function:def load_monitoring_config_file(self, clean=True):
# pylint: disable=too-many-branches,too-many-statements, too-many-locals
self.loading_configuration = True
_t_configuration = time.time()
if self.verify_only:
# Force add... | [
"Load main configuration file (alignak.cfg)::\n\n * Read all files given in the -c parameters\n * Read all .cfg files in cfg_dir\n * Read all files in cfg_file\n * Create objects (Arbiter, Module)\n * Set HTTP links info (ssl etc)\n * Load its own modules\n * Execute... |
Please provide a description of the function:def load_modules_configuration_objects(self, raw_objects): # pragma: no cover,
# not yet with unit tests.
# Now we ask for configuration modules if they
# got items for us
for instance in self.modules_manager.instances:
l... | [
"Load configuration objects from arbiter modules\n If module implements get_objects arbiter will call it and add create\n objects\n\n :param raw_objects: raw objects we got from reading config files\n :type raw_objects: dict\n :return: None\n "
] |
Please provide a description of the function:def load_modules_alignak_configuration(self): # pragma: no cover, not yet with unit tests.
alignak_cfg = {}
# Ask configured modules if they got configuration for us
for instance in self.modules_manager.instances:
if not hasattr(... | [
"Load Alignak configuration from the arbiter modules\n If module implements get_alignak_configuration, call this function\n\n :param raw_objects: raw objects we got from reading config files\n :type raw_objects: dict\n :return: None\n "
] |
Please provide a description of the function:def request_stop(self, message='', exit_code=0):
# Only a master arbiter can stop the daemons
if self.is_master:
# Stop the daemons
self.daemons_stop(timeout=self.conf.daemons_stop_timeout)
# Request the daemon stop
... | [
"Stop the Arbiter daemon\n\n :return: None\n "
] |
Please provide a description of the function:def start_daemon(self, satellite):
logger.info(" launching a daemon for: %s/%s...", satellite.type, satellite.name)
# The daemon startup script location may be defined in the configuration
daemon_script_location = getattr(self.conf, 'daemon... | [
"Manage the list of detected missing daemons\n\n If the daemon does not in exist `my_daemons`, then:\n - prepare daemon start arguments (port, name and log file)\n - start the daemon\n - make sure it started correctly\n\n :param satellite: the satellite for which a daemon i... |
Please provide a description of the function:def daemons_start(self, run_daemons=True):
result = True
if run_daemons:
logger.info("Alignak configured daemons start:")
else:
logger.info("Alignak configured daemons check:")
# Parse the list of the missing... | [
"Manage the list of the daemons in the configuration\n\n Check if the daemon needs to be started by the Arbiter.\n\n If so, starts the daemon if `run_daemons` is True\n\n :param run_daemons: run the daemons or make a simple check\n :type run_daemons: bool\n\n :return: True if all ... |
Please provide a description of the function:def daemons_check(self):
# First look if it's not too early to ping
start = time.time()
if self.daemons_last_check \
and self.daemons_last_check + self.conf.daemons_check_period > start:
logger.debug("Too early to ... | [
"Manage the list of Alignak launched daemons\n\n Check if the daemon process is running\n\n :return: True if all daemons are running, else False\n "
] |
Please provide a description of the function:def daemons_stop(self, timeout=30, kill_children=False):
def on_terminate(proc):
logger.debug("process %s terminated with exit code %s", proc.pid, proc.returncode)
result = True
if self.my_daemons:
logge... | [
"Stop the Alignak daemons\n\n Iterate over the self-launched daemons and their children list to send a TERM\n Wait for daemons to terminate and then send a KILL for those that are not yet stopped\n\n As a default behavior, only the launched daemons are killed, not their children.\n E... |
Please provide a description of the function:def daemons_reachability_check(self):
# First look if it's not too early to ping
start = time.time()
if self.daemons_last_reachable_check and \
self.daemons_last_reachable_check + self.conf.daemons_check_period > start:
... | [
"Manage the list of Alignak launched daemons\n\n Check if the daemon process is running\n\n :return: True if all daemons are running, else False\n "
] |
Please provide a description of the function:def setup_new_conf(self):
# pylint: disable=too-many-locals
# Execute the base class treatment...
super(Arbiter, self).setup_new_conf()
with self.conf_lock:
logger.info("I received a new configuration from my master")
... | [
" Setup a new configuration received from a Master arbiter.\n\n TODO: perharps we should not accept the configuration or raise an error if we do not\n find our own configuration data in the data. Thus this should never happen...\n :return: None\n "
] |
Please provide a description of the function:def wait_for_master_death(self):
logger.info("Waiting for master death")
timeout = 1.0
self.last_master_ping = time.time()
master_timeout = 300
for arbiter_link in self.conf.arbiters:
if not arbiter_link.spare:
... | [
"Wait for a master timeout and take the lead if necessary\n\n :return: None\n "
] |
Please provide a description of the function:def check_and_log_tp_activation_change(self):
for timeperiod in self.conf.timeperiods:
brok = timeperiod.check_and_log_activation_change()
if brok:
self.add(brok) | [
"Raise log for timeperiod change (useful for debug)\n\n :return: None\n "
] |
Please provide a description of the function:def manage_signal(self, sig, frame):
# Request the arbiter to stop
if sig in [signal.SIGINT, signal.SIGTERM]:
logger.info("received a signal: %s", SIGNALS_TO_NAMES_DICT[sig])
self.kill_request = True
self.kill_time... | [
"Manage signals caught by the process\n Specific behavior for the arbiter when it receives a sigkill or sigterm\n\n :param sig: signal caught by the process\n :type sig: str\n :param frame: current stack frame\n :type frame:\n :return: None\n "
] |
Please provide a description of the function:def configuration_dispatch(self, not_configured=None):
if not not_configured:
self.dispatcher = Dispatcher(self.conf, self.link_to_myself)
# I set my own dispatched configuration as the provided one...
# because I will not... | [
"Monitored configuration preparation and dispatch\n\n :return: None\n "
] |
Please provide a description of the function:def do_before_loop(self):
logger.info("I am the arbiter: %s", self.link_to_myself.name)
# If I am a spare, I do not have anything to do here...
if not self.is_master:
logger.debug("Waiting for my master death...")
ret... | [
"Called before the main daemon loop.\n\n :return: None\n "
] |
Please provide a description of the function:def do_loop_turn(self):
# pylint: disable=too-many-branches, too-many-statements, too-many-locals
# If I am a spare, I only wait for the master arbiter to die...
if not self.is_master:
logger.debug("Waiting for my master death..."... | [
"Loop turn for Arbiter\n\n If not a master daemon, wait for my master death...\n Else, run:\n * Check satellites are alive\n * Check and dispatch (if needed) the configuration\n * Get broks and external commands from the satellites\n * Push broks and external commands to th... |
Please provide a description of the function:def get_daemon_stats(self, details=False): # pylint: disable=too-many-branches
now = int(time.time())
# Call the base Daemon one
res = super(Arbiter, self).get_daemon_stats(details=details)
res.update({
'name': self.link... | [
"Increase the stats provided by the Daemon base class\n\n :return: stats dictionary\n :rtype: dict\n "
] |
Please provide a description of the function:def get_monitoring_problems(self):
res = self.get_id()
res['problems'] = {}
# Report our schedulers information, but only if a dispatcher exists
if getattr(self, 'dispatcher', None) is None:
return res
for satell... | [
"Get the schedulers satellites problems list\n\n :return: problems dictionary\n :rtype: dict\n "
] |
Please provide a description of the function:def get_livesynthesis(self):
res = self.get_id()
res['livesynthesis'] = {
'_overall': {
'_freshness': int(time.time()),
'livesynthesis': {
'hosts_total': 0,
'hosts_no... | [
"Get the schedulers satellites live synthesis\n\n :return: compiled livesynthesis dictionary\n :rtype: dict\n "
] |
Please provide a description of the function:def main(self):
try:
# Start the daemon
if not self.verify_only and not self.do_daemon_init_and_start():
self.exit_on_error(message="Daemon initialization error", exit_code=3)
if self.verify_only:
... | [
"Main arbiter function::\n\n * Set logger\n * Init daemon\n * Launch modules\n * Endless main process loop\n\n :return: None\n "
] |
Please provide a description of the function:def overall_state_id(self):
overall_state = 0
if not self.monitored:
overall_state = 5
elif self.acknowledged:
overall_state = 1
elif self.downtimed:
overall_state = 2
elif self.state_type =... | [
"Get the service overall state.\n\n The service overall state identifier is the service status including:\n - the monitored state\n - the acknowledged state\n - the downtime state\n\n The overall state is (prioritized):\n - a service is not monitored (5)\n - a servic... |
Please provide a description of the function:def fill_predictive_missing_parameters(self):
if self.initial_state == 'w':
self.state = u'WARNING'
elif self.initial_state == 'u':
self.state = u'UNKNOWN'
elif self.initial_state == 'c':
self.state = u'CRI... | [
"define state with initial_state\n\n :return: None\n "
] |
Please provide a description of the function:def get_name(self):
if hasattr(self, 'service_description'):
return self.service_description
if hasattr(self, 'name'):
return self.name
return 'SERVICE-DESCRIPTION-MISSING' | [
"Accessor to service_description attribute or name if first not defined\n\n :return: service name\n :rtype: str\n "
] |
Please provide a description of the function:def get_full_name(self):
if self.is_tpl():
return "tpl-%s/%s" % (getattr(self, 'host_name', 'XxX'), self.name)
if hasattr(self, 'host_name') and hasattr(self, 'service_description'):
return "%s/%s" % (self.host_name, self.serv... | [
"Get the full name for debugging (host_name/service_description)\n\n :return: service full name\n :rtype: str\n "
] |
Please provide a description of the function:def get_groupnames(self, sgs):
return ','.join([sgs[sg].get_name() for sg in self.servicegroups]) | [
"Get servicegroups list\n\n :return: comma separated list of servicegroups\n :rtype: str\n "
] |
Please provide a description of the function:def is_correct(self):
state = True
cls = self.__class__
hname = getattr(self, 'host_name', '')
hgname = getattr(self, 'hostgroup_name', '')
sdesc = getattr(self, 'service_description', '')
if not sdesc:
s... | [
"Check if this object configuration is correct ::\n\n * Check our own specific properties\n * Call our parent class is_correct checker\n\n :return: True if the configuration is correct, otherwise False\n :rtype: bool\n "
] |
Please provide a description of the function:def duplicate(self, host):
# pylint: disable=too-many-locals
duplicates = []
# In macro, it's all in UPPER case
prop = self.duplicate_foreach.strip().upper()
if prop not in host.customs: # If I do not have the property, we ... | [
"For a given host, look for all copy we must create for for_each property\n\n :param host: alignak host object\n :type host: alignak.objects.host.Host\n :return: list\n :rtype: list\n "
] |
Please provide a description of the function:def set_state_from_exit_status(self, status, notif_period, hosts, services):
now = time.time()
# we should put in last_state the good last state:
# if not just change the state by an problem/impact
# we can take current state. But if... | [
"Set the state in UP, WARNING, CRITICAL, UNKNOWN or UNREACHABLE\n according to the status of a check result.\n\n :param status: integer between 0 and 4\n :type status: int\n :return: None\n "
] |
Please provide a description of the function:def is_state(self, status):
# pylint: disable=too-many-return-statements
if status == self.state:
return True
# Now low status
if status == 'o' and self.state == u'OK':
return True
if status == 'c' and ... | [
"Return True if status match the current service status\n\n :param status: status to compare ( \"o\", \"c\", \"w\", \"u\", \"x\"). Usually comes from config files\n :type status: str\n :return: True if status <=> self.status, otherwise False\n :rtype: bool\n "
] |
Please provide a description of the function:def last_time_non_ok_or_up(self):
non_ok_times = [x for x in [self.last_time_warning,
self.last_time_critical,
self.last_time_unknown]
if x > self.last_time_ok]
... | [
"Get the last time the service was in a non-OK state\n\n :return: the nearest last time the service was not ok\n :rtype: int\n "
] |
Please provide a description of the function:def raise_check_result(self):
if not self.__class__.log_active_checks:
return
log_level = 'info'
if self.state in [u'WARNING', u'UNREACHABLE']:
log_level = 'warning'
elif self.state == u'CRITICAL':
... | [
"Raise ACTIVE CHECK RESULT entry\n Example : \"ACTIVE SERVICE CHECK: server;DOWN;HARD;1;I don't know what to say...\"\n\n :return: None\n "
] |
Please provide a description of the function:def raise_notification_log_entry(self, notif, contact, host_ref):
if self.__class__.log_notifications:
log_level = 'info'
command = notif.command_call
if notif.type in [u'DOWNTIMESTART', u'DOWNTIMEEND', u'DOWNTIMECANCELLED... | [
"Raise SERVICE NOTIFICATION entry (critical level)\n Format is : \"SERVICE NOTIFICATION: *contact.get_name()*;*host_name*;*self.get_name()*\n ;*state*;*command.get_name()*;*output*\"\n Example : \"SERVICE NOTIFICATION: superadmin;server;Load;UP;notify-by-rss;no output\"\n\n :... |
Please provide a description of the function:def raise_event_handler_log_entry(self, command):
if not self.__class__.log_event_handlers:
return
log_level = 'info'
if self.state == 'WARNING':
log_level = 'warning'
if self.state == 'CRITICAL':
... | [
"Raise SERVICE EVENT HANDLER entry (critical level)\n Format is : \"SERVICE EVENT HANDLER: *host_name*;*self.get_name()*;*state*;*state_type*\n ;*attempt*;*command.get_name()*\"\n Example : \"SERVICE EVENT HANDLER: server;Load;UP;HARD;1;notify-by-rss\"\n\n :param command: Han... |
Please provide a description of the function:def get_data_for_notifications(self, contact, notif, host_ref):
if not host_ref:
return [self, contact, notif]
return [host_ref, self, contact, notif] | [
"Get data for a notification\n\n :param contact: The contact to return\n :type contact:\n :param notif: the notification to return\n :type notif:\n :return: list containing the service, the host and the given parameters\n :rtype: list\n "
] |
Please provide a description of the function:def is_blocking_notifications(self, notification_period, hosts, services, n_type, t_wished):
# pylint: disable=too-many-return-statements
logger.debug("Checking if a service %s (%s) notification is blocked...",
self.get_full_name... | [
"Check if a notification is blocked by the service.\n Conditions are ONE of the following::\n\n * enable_notification is False (global)\n * not in a notification_period\n * notifications_enable is False (local)\n * notification_options is 'n' or matches the state ('UNKNOWN' <=> 'u... |
Please provide a description of the function:def get_short_status(self, hosts, services):
mapping = {
0: "O",
1: "W",
2: "C",
3: "U",
4: "N",
}
if self.got_business_rule:
return mapping.get(self.business_rule.get_st... | [
"Get the short status of this host\n\n :return: \"O\", \"W\", \"C\", \"U', or \"n/a\" based on service state_id or business_rule state\n :rtype: str\n "
] |
Please provide a description of the function:def get_status(self, hosts, services):
if self.got_business_rule:
mapping = {
0: u'OK',
1: u'WARNING',
2: u'CRITICAL',
3: u'UNKNOWN',
4: u'UNREACHABLE',
... | [
"Get the status of this host\n\n :return: \"OK\", \"WARNING\", \"CRITICAL\", \"UNKNOWN\" or \"n/a\" based on\n service state_id or business_rule state\n :rtype: str\n "
] |
Please provide a description of the function:def add_template(self, tpl):
objcls = self.inner_class.my_type
name = getattr(tpl, 'name', '')
sdesc = getattr(tpl, 'service_description', '')
hname = getattr(tpl, 'host_name', '')
logger.debug("Adding a %s template: host_name... | [
"\n Adds and index a template into the `templates` container.\n\n This implementation takes into account that a service has two naming\n attribute: `host_name` and `service_description`.\n\n :param tpl: The template to add\n :type tpl:\n :return: None\n "
] |
Please provide a description of the function:def apply_inheritance(self):
super(Services, self).apply_inheritance()
# add_item only ensure we can build a key for services later (after explode)
for item in list(self.items.values()):
self.add_item(item, False) | [
" For all items and templates inherit properties and custom\n variables.\n\n :return: None\n "
] |
Please provide a description of the function:def find_srvs_by_hostname(self, host_name):
if hasattr(self, 'hosts'):
host = self.hosts.find_by_name(host_name)
if host is None:
return None
return host.get_services()
return None | [
"Get all services from a host based on a host_name\n\n :param host_name: the host name we want services\n :type host_name: str\n :return: list of services\n :rtype: list[alignak.objects.service.Service]\n "
] |
Please provide a description of the function:def find_srv_by_name_and_hostname(self, host_name, sdescr):
key = (host_name, sdescr)
return self.name_to_item.get(key, None) | [
"Get a specific service based on a host_name and service_description\n\n :param host_name: host name linked to needed service\n :type host_name: str\n :param sdescr: service name we need\n :type sdescr: str\n :return: the service found or None\n :rtype: alignak.objects.ser... |
Please provide a description of the function:def linkify(self, hosts, commands, timeperiods, contacts, # pylint: disable=R0913
resultmodulations, businessimpactmodulations, escalations,
servicegroups, checkmodulations, macromodulations):
self.linkify_with_timeperiods(ti... | [
"Create link between objects::\n\n * service -> host\n * service -> command\n * service -> timeperiods\n * service -> contacts\n\n :param hosts: hosts to link\n :type hosts: alignak.objects.host.Hosts\n :param timeperiods: timeperiods to link\n :type timep... |
Please provide a description of the function:def override_properties(self, hosts):
ovr_re = re.compile(r'^([^,]+),([^\s]+)\s+(.*)$')
ovr_hosts = [h for h in hosts if getattr(h, 'service_overrides', None)]
for host in ovr_hosts:
# We're only looking for hosts having service o... | [
"Handle service_overrides property for hosts\n ie : override properties for relevant services\n\n :param hosts: hosts we need to apply override properties\n :type hosts: alignak.objects.host.Hosts\n :return: None\n "
] |
Please provide a description of the function:def linkify_s_by_hst(self, hosts):
for serv in self:
# If we do not have a host_name, we set it as
# a template element to delete. (like Nagios)
if not hasattr(serv, 'host_name'):
serv.host = None
... | [
"Link services with their parent host\n\n :param hosts: Hosts to look for simple host\n :type hosts: alignak.objects.host.Hosts\n :return: None\n "
] |
Please provide a description of the function:def linkify_s_by_sg(self, servicegroups):
for serv in self:
new_servicegroups = []
if hasattr(serv, 'servicegroups') and serv.servicegroups != '':
for sg_name in serv.servicegroups:
sg_name = sg_nam... | [
"Link services with servicegroups\n\n :param servicegroups: Servicegroups\n :type servicegroups: alignak.objects.servicegroup.Servicegroups\n :return: None\n "
] |
Please provide a description of the function:def apply_implicit_inheritance(self, hosts):
for prop in ('contacts', 'contact_groups', 'notification_interval',
'notification_period', 'resultmodulations', 'business_impact_modulations',
'escalations', 'poller_tag',... | [
"Apply implicit inheritance for special properties:\n contact_groups, notification_interval , notification_period\n So service will take info from host if necessary\n\n :param hosts: hosts list needed to look for a simple host\n :type hosts: alignak.objects.host.Hosts\n :return: N... |
Please provide a description of the function:def apply_dependencies(self, hosts):
for service in self:
if service.host and service.host_dependency_enabled:
host = hosts[service.host]
if host.active_checks_enabled:
service.act_depend_of.app... | [
"Wrapper to loop over services and call Service.fill_daddy_dependency()\n\n :return: None\n "
] |
Please provide a description of the function:def clean(self):
to_del = []
for serv in self:
if not serv.host:
to_del.append(serv.uuid)
for service_uuid in to_del:
del self.items[service_uuid] | [
"Remove services without host object linked to\n\n Note that this should not happen!\n\n :return: None\n "
] |
Please provide a description of the function:def explode_services_from_hosts(self, hosts, service, hnames):
duplicate_for_hosts = [] # get the list of our host_names if more than 1
not_hosts = [] # the list of !host_name so we remove them after
for hname in hnames:
hname =... | [
"\n Explodes a service based on a list of hosts.\n\n :param hosts: The hosts container\n :type hosts:\n :param service: The base service to explode\n :type service:\n :param hnames: The host_name list to explode service on\n :type hnames: str\n :return: None\... |
Please provide a description of the function:def _local_create_service(self, hosts, host_name, service):
host = hosts.find_by_name(host_name.strip())
if host.is_excluded_for(service):
return None
# Creates a real service instance from the template
new_s = service.co... | [
"Create a new service based on a host_name and service instance.\n\n :param hosts: The hosts items instance.\n :type hosts: alignak.objects.host.Hosts\n :param host_name: The host_name to create a new service.\n :type host_name: str\n :param service: The service to be used as temp... |
Please provide a description of the function:def explode_services_from_templates(self, hosts, service_template):
hname = getattr(service_template, "host_name", None)
if not hname:
logger.debug("Service template %s is declared without an host_name",
service_t... | [
"\n Explodes services from templates. All hosts holding the specified\n templates are bound with the service.\n\n :param hosts: The hosts container.\n :type hosts: alignak.objects.host.Hosts\n :param service_template: The service to explode.\n :type service_template: aligna... |
Please provide a description of the function:def explode_services_duplicates(self, hosts, service):
hname = getattr(service, "host_name", None)
if hname is None:
return
# the generator case, we must create several new services
# we must find our host, and get all ke... | [
"\n Explodes services holding a `duplicate_foreach` clause.\n\n :param hosts: The hosts container\n :type hosts: alignak.objects.host.Hosts\n :param service: The service to explode\n :type service: alignak.objects.service.Service\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.