Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def register_service_into_servicegroups(service, servicegroups):
if hasattr(service, 'service_description'):
sname = service.service_description
shname = getattr(service, 'host_name', '')
if hasattr(service, 'servicegroups... | [
"\n Registers a service into the service groups declared in its\n `servicegroups` attribute.\n\n :param service: The service to register\n :type service:\n :param servicegroups: The servicegroups container\n :type servicegroups:\n :return: None\n "
] |
Please provide a description of the function:def register_service_dependencies(service, servicedependencies):
# We explode service_dependencies into Servicedependency
# We just create serviceDep with goods values (as STRING!),
# the link pass will be done after
sdeps = [d.strip(... | [
"\n Registers a service dependencies.\n\n :param service: The service to register\n :type service:\n :param servicedependencies: The servicedependencies container\n :type servicedependencies:\n :return: None\n "
] |
Please provide a description of the function:def explode(self, hosts, hostgroups, contactgroups, servicegroups, servicedependencies):
# pylint: disable=too-many-locals
# Then for every service create a copy of the service with just the host
# because we are adding services, we can't jus... | [
"\n Explodes services, from host, hostgroups, contactgroups, servicegroups and dependencies.\n\n :param hosts: The hosts container\n :type hosts: [alignak.object.host.Host]\n :param hostgroups: The hosts goups container\n :type hostgroups: [alignak.object.hostgroup.Hostgroup]\n ... |
Please provide a description of the function:def is_eligible(self, timestamp, status, notif_number, in_notif_time, interval, escal_period):
# pylint: disable=too-many-return-statements
short_states = {
u'WARNING': 'w', u'UNKNOWN': 'u', u'CRITICAL': 'c',
u'RECOVERY': 'r',... | [
"Check if the escalation is eligible (notification is escalated or not)\n\n Escalation is NOT eligible in ONE of the following condition is fulfilled::\n\n * escalation is not time based and notification number not in range\n [first_notification;last_notification] (if last_notif == 0, it's in... |
Please provide a description of the function:def get_next_notif_time(self, t_wished, status, creation_time, interval, escal_period):
short_states = {u'WARNING': 'w', u'UNKNOWN': 'u', u'CRITICAL': 'c',
u'RECOVERY': 'r', u'FLAPPING': 'f', u'DOWNTIME': 's',
... | [
"Get the next notification time for the escalation\n Only legit for time based escalation\n\n :param t_wished: time we would like to send a new notification (usually now)\n :type t_wished:\n :param status: status of the host or service\n :type status:\n :param creation_time... |
Please provide a description of the function:def is_correct(self):
state = True
# Internal checks before executing inherited function...
# If we got the _time parameters, we are time based. Unless, we are not :)
if hasattr(self, 'first_notification_time') or hasattr(self, 'las... | [
"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 linkify(self, timeperiods, contacts, services, hosts):
self.linkify_with_timeperiods(timeperiods, 'escalation_period')
self.linkify_with_contacts(contacts)
self.linkify_es_by_s(services)
self.linkify_es_by_h(hosts) | [
"Create link between objects::\n\n * escalation -> host\n * escalation -> service\n * escalation -> timeperiods\n * escalation -> contact\n\n :param timeperiods: timeperiods to link\n :type timeperiods: alignak.objects.timeperiod.Timeperiods\n :param contacts: co... |
Please provide a description of the function:def linkify_es_by_s(self, services):
for escalation in self:
# If no host, no hope of having a service
if not hasattr(escalation, 'host_name'):
continue
es_hname, sdesc = escalation.host_name, escalation.s... | [
"Add each escalation object into service.escalation attribute\n\n :param services: service list, used to look for a specific service\n :type services: alignak.objects.service.Services\n :return: None\n "
] |
Please provide a description of the function:def linkify_es_by_h(self, hosts):
for escal in self:
# If no host, no hope of having a service
if (not hasattr(escal, 'host_name') or escal.host_name.strip() == '' or
(hasattr(escal, 'service_description')
... | [
"Add each escalation object into host.escalation attribute\n\n :param hosts: host list, used to look for a specific host\n :type hosts: alignak.objects.host.Hosts\n :return: None\n "
] |
Please provide a description of the function:def explode(self, hosts, hostgroups, contactgroups):
for i in self:
# items::explode_host_groups_into_hosts
# take all hosts from our hostgroup_name into our host_name property
self.explode_host_groups_into_hosts(i, hosts,... | [
"Loop over all escalation and explode hostsgroups in host\n and contactgroups in contacts\n\n Call Item.explode_host_groups_into_hosts and Item.explode_contact_groups_into_contacts\n\n :param hosts: host list to explode\n :type hosts: alignak.objects.host.Hosts\n :param hostgroups... |
Please provide a description of the function:def get_hosts_by_explosion(self, hostgroups):
# pylint: disable=access-member-before-definition
# First we tag the hg so it will not be explode
# if a son of it already call it
self.already_exploded = True
# Now the recursive... | [
"\n Get hosts of this group\n\n :param hostgroups: Hostgroup object\n :type hostgroups: alignak.objects.hostgroup.Hostgroups\n :return: list of hosts of this group\n :rtype: list\n "
] |
Please provide a description of the function:def add_member(self, host_name, hostgroup_name):
hostgroup = self.find_by_name(hostgroup_name)
if not hostgroup:
hostgroup = Hostgroup({'hostgroup_name': hostgroup_name,
'alias': hostgroup_name,
... | [
"Add a host string to a hostgroup member\n if the host group do not exist, create it\n\n :param host_name: host name\n :type host_name: str\n :param hostgroup_name:hostgroup name\n :type hostgroup_name: str\n :return: None\n "
] |
Please provide a description of the function:def get_members_of_group(self, gname):
hostgroup = self.find_by_name(gname)
if hostgroup:
return hostgroup.get_hosts()
return [] | [
"Get all members of a group which name is given in parameter\n\n :param gname: name of the group\n :type gname: str\n :return: list of the hosts in the group\n :rtype: list[alignak.objects.host.Host]\n "
] |
Please provide a description of the function:def linkify(self, hosts=None, realms=None, forced_realms_hostgroups=True):
self.linkify_hostgroups_hosts(hosts)
self.linkify_hostgroups_realms_hosts(realms, hosts, forced_realms_hostgroups) | [
"Link hostgroups with hosts and realms\n\n :param hosts: all Hosts\n :type hosts: alignak.objects.host.Hosts\n :param realms: all Realms\n :type realms: alignak.objects.realm.Realms\n :return: None\n "
] |
Please provide a description of the function:def linkify_hostgroups_hosts(self, hosts):
for hostgroup in self:
members = hostgroup.get_hosts()
# The new members identifiers list
new_members = []
for member in members:
# member is an host n... | [
"We just search for each hostgroup the id of the hosts\n and replace the names by the found identifiers\n\n :param hosts: object Hosts\n :type hosts: alignak.objects.host.Hosts\n :return: None\n "
] |
Please provide a description of the function:def linkify_hostgroups_realms_hosts(self, realms, hosts, forced_realms_hostgroups=True):
# pylint: disable=too-many-locals, too-many-nested-blocks, too-many-branches
logger.info("Hostgroups / hosts / realms relation")
for hostgroup in self:
... | [
"Link between an hostgroup and a realm is already done in the configuration parsing\n function that defines and checks the default satellites, realms, hosts and hosts groups\n consistency.\n\n This function will only raise some alerts if hosts groups and hosts that are contained\n do not... |
Please provide a description of the function:def explode(self):
# We do not want a same hostgroup to be exploded again and again
# so we tag it
for tmp_hg in list(self.items.values()):
tmp_hg.already_exploded = False
for hostgroup in list(self.items.values()):
... | [
"\n Fill members with hostgroup_members\n\n :return: None\n "
] |
Please provide a description of the function:def run(self):
def _started_callback():
cherrypy.log("CherryPy engine started and listening...")
self.cherrypy_thread = None
try:
cherrypy.log("Starting CherryPy engine on %s" % (self.uri))
se... | [
"Wrapper to start the CherryPy server\n\n This function throws a PortNotFree exception if any socket error is raised.\n\n :return: None\n ",
"Callback function when Cherrypy Engine is started"
] |
Please provide a description of the function:def stop(self): # pylint: disable=no-self-use
cherrypy.log("Stopping CherryPy engine (current state: %s)..." % cherrypy.engine.state)
try:
cherrypy.engine.exit()
except RuntimeWarning:
pass
except SystemExit:
... | [
"Wrapper to stop the CherryPy server\n\n :return: None\n "
] |
Please provide a description of the function:def create_queues(self, manager=None):
self.clear_queues(manager)
# If no Manager() object, go with classic Queue()
if not manager:
self.from_q = Queue()
self.to_q = Queue()
else:
self.from_q = mana... | [
"\n Create the shared queues that will be used by alignak daemon\n process and this module process.\n But clear queues if they were already set before recreating new one.\n\n Note:\n If manager is None, then we are running the unit tests for the modules and\n we must create... |
Please provide a description of the function:def clear_queues(self, manager):
for queue in (self.to_q, self.from_q):
if queue is None:
continue
# If we got no manager, we directly call the clean
if not manager:
try:
... | [
"Release the resources associated to the queues of this instance\n\n :param manager: Manager() object\n :type manager: None | object\n :return: None\n "
] |
Please provide a description of the function:def start_module(self):
try:
self._main()
except Exception as exp:
logger.exception('%s', traceback.format_exc())
raise Exception(exp) | [
"Wrapper for _main function.\n Catch and raise any exception occurring in the main function\n\n :return: None\n "
] |
Please provide a description of the function:def start(self, http_daemon=None): # pylint: disable=unused-argument
if not self.is_external:
return
if self.process:
self.stop_process()
logger.info("Starting external process for module %s...", self.name)
... | [
"Actually restart the process if the module is external\n Try first to stop the process and create a new Process instance\n with target start_module.\n Finally start process.\n\n :param http_daemon: Not used here but can be used in other modules\n :type http_daemon: None | object\... |
Please provide a description of the function:def kill(self):
logger.info("Killing external module (pid=%d) for module %s...",
self.process.pid, self.name)
if os.name == 'nt':
self.process.terminate()
else:
self.process.terminate()
... | [
"Sometime terminate() is not enough, we must \"help\"\n external modules to die...\n\n :return: None\n "
] |
Please provide a description of the function:def stop_process(self):
if not self.process:
return
logger.info("I'm stopping module %r (pid=%d)", self.name, self.process.pid)
self.kill()
# Clean inner process reference
self.process = None | [
"Request the module process to stop and release it\n\n :return: None\n "
] |
Please provide a description of the function:def manage_brok(self, brok):
manage = getattr(self, 'manage_' + brok.type + '_brok', None)
if not manage:
return False
# Be sure the brok is prepared before calling the function
brok.prepare()
return manage(brok) | [
"Request the module to manage the given brok.\n There are a lot of different possible broks to manage. The list is defined\n in the Brok class.\n\n An internal module may redefine this function or, easier, define only the function\n for the brok it is interested with. Hence a module inte... |
Please provide a description of the function:def manage_signal(self, sig, frame): # pylint: disable=unused-argument
logger.info("received a signal: %s", SIGNALS_TO_NAMES_DICT[sig])
if sig == signal.SIGHUP:
# if SIGHUP, reload configuration in arbiter
logger.info("Modul... | [
"Generic function to handle signals\n\n Only called when the module process received SIGINT or SIGKILL.\n\n Set interrupted attribute to True, self.process to None and returns\n\n :param sig: signal sent\n :type sig:\n :param frame: frame before catching signal\n :type fram... |
Please provide a description of the function:def set_signal_handler(self, sigs=None):
if sigs is None:
sigs = (signal.SIGTERM, signal.SIGINT, signal.SIGUSR1, signal.SIGUSR2, signal.SIGHUP)
func = self.manage_signal
if os.name == "nt": # pragma: no cover, no Windows impleme... | [
"Set the signal handler to manage_signal (defined in this class)\n\n Only set handlers for:\n - signal.SIGTERM, signal.SIGINT\n - signal.SIGUSR1, signal.SIGUSR2\n - signal.SIGHUP\n\n :return: None\n "
] |
Please provide a description of the function:def _main(self):
self.set_proctitle(self.name)
self.set_signal_handler()
logger.info("process for module %s is now running (pid=%d)", self.name, os.getpid())
# Will block here!
try:
self.main()
except (IO... | [
"module \"main\" method. Only used by external modules.\n\n :return: None\n "
] |
Please provide a description of the function:def no_block_read(output):
_buffer = ""
if not fcntl:
return _buffer
o_fd = output.fileno()
o_fl = fcntl.fcntl(o_fd, fcntl.F_GETFL)
fcntl.fcntl(o_fd, fcntl.F_SETFL, o_fl | os.O_NONBLOCK)
try:
_buffer = output.read()
except Ex... | [
"Try to read a file descriptor in a non blocking mode\n\n If the fcntl is available (unix only) we try to read in a\n asynchronous mode, so we won't block the PIPE at 64K buffer\n (deadlock...)\n\n :param output: file or socket to read from\n :type output: file\n :return: data read from fd\n :r... |
Please provide a description of the function:def get_local_environnement(self):
# Do not use copy.copy() here, as the resulting copy still
# changes the real environment (it is still a os._Environment
# instance).
local_env = os.environ.copy()
for local_var in self.env:
... | [
"\n Mix the environment and the environment variables into a new local\n environment dictionary\n\n Note: We cannot just update the global os.environ because this\n would effect all other checks.\n\n :return: local environment variables\n :rtype: dict\n "
] |
Please provide a description of the function:def execute(self):
self.status = ACT_STATUS_LAUNCHED
self.check_time = time.time()
self.wait_time = 0.0001
self.last_poll = self.check_time
# Get a local env variables with our additional values
self.local_env = self.... | [
"Start this action command in a subprocess.\n\n :raise: ActionError\n 'toomanyopenfiles' if too many opened files on the system\n 'no_process_launched' if arguments parsing failed\n 'process_launch_failed': if the process launch failed\n\n :return: reference to the sta... |
Please provide a description of the function:def get_outputs(self, out, max_plugins_output_length):
# Squeeze all output after max_plugins_output_length
out = out[:max_plugins_output_length]
# manage escaped pipes
out = out.replace(r'\|', '___PROTECT_PIPE___')
# Then cut... | [
"Get check outputs from single output (split perfdata etc).\n\n Updates output, perf_data and long_output attributes.\n\n :param out: output data of a check\n :type out: str\n :param max_output: max plugin data length\n :type max_output: int\n :return: None\n "
] |
Please provide a description of the function:def check_finished(self, max_plugins_output_length):
# pylint: disable=too-many-branches
self.last_poll = time.time()
_, _, child_utime, child_stime, _ = os.times()
# Not yet finished...
if self.process.poll() is None:
... | [
"Handle action if it is finished (get stdout, stderr, exit code...)\n\n :param max_plugins_output_length: max plugin data length\n :type max_plugins_output_length: int\n :return: None\n "
] |
Please provide a description of the function:def copy_shell__(self, new_i):
for prop in ONLY_COPY_PROP:
setattr(new_i, prop, getattr(self, prop))
return new_i | [
"Create all attributes listed in 'ONLY_COPY_PROP' and return `self` with these attributes.\n\n :param new_i: object to\n :type new_i: object\n :return: object with new properties added\n :rtype: object\n "
] |
Please provide a description of the function:def get_contacts_by_explosion(self, contactgroups):
# pylint: disable=access-member-before-definition
# First we tag the hg so it will not be explode
# if a son of it already call it
self.already_exploded = True
# Now the rec... | [
"\n Get contacts of this group\n\n :param contactgroups: Contactgroups object, use to look for a specific one\n :type contactgroups: alignak.objects.contactgroup.Contactgroups\n :return: list of contact of this group\n :rtype: list[alignak.objects.contact.Contact]\n "
] |
Please provide a description of the function:def add_member(self, contact_name, contactgroup_name):
contactgroup = self.find_by_name(contactgroup_name)
if not contactgroup:
contactgroup = Contactgroup({'contactgroup_name': contactgroup_name,
... | [
"Add a contact string to a contact member\n if the contact group do not exist, create it\n\n :param contact_name: contact name\n :type contact_name: str\n :param contactgroup_name: contact group name\n :type contactgroup_name: str\n :return: None\n "
] |
Please provide a description of the function:def get_members_of_group(self, gname):
contactgroup = self.find_by_name(gname)
if contactgroup:
return contactgroup.get_contacts()
return [] | [
"Get all members of a group which name is given in parameter\n\n :param gname: name of the group\n :type gname: str\n :return: list of contacts in the group\n :rtype: list[alignak.objects.contact.Contact]\n "
] |
Please provide a description of the function:def linkify_contactgroups_contacts(self, contacts):
for contactgroup in self:
mbrs = contactgroup.get_contacts()
# The new member list, in id
new_mbrs = []
for mbr in mbrs:
mbr = mbr.strip() #... | [
"Link the contacts with contactgroups\n\n :param contacts: realms object to link with\n :type contacts: alignak.objects.contact.Contacts\n :return: None\n "
] |
Please provide a description of the function:def explode(self):
# We do not want a same hg to be explode again and again
# so we tag it
for tmp_cg in list(self.items.values()):
tmp_cg.already_exploded = False
for contactgroup in list(self.items.values()):
... | [
"\n Fill members with contactgroup_members\n\n :return:None\n "
] |
Please provide a description of the function:def get_return_from(self, e_handler):
for prop in ['exit_status', 'output', 'long_output', 'check_time', 'execution_time',
'perf_data']:
setattr(self, prop, getattr(e_handler, prop)) | [
"Setter of the following attributes::\n\n * exit_status\n * output\n * long_output\n * check_time\n * execution_time\n * perf_data\n\n :param e_handler: event handler to get data from\n :type e_handler: alignak.eventhandler.EventHandler\n :return: None\... |
Please provide a description of the function:def add_flapping_change(self, sample):
cls = self.__class__
# If this element is not in flapping check, or
# the flapping is globally disable, bailout
if not self.flap_detection_enabled or not cls.enable_flap_detection:
r... | [
"Add a flapping sample and keep cls.flap_history samples\n\n :param sample: Sample to add\n :type sample: bool\n :return: None\n "
] |
Please provide a description of the function:def update_flapping(self, notif_period, hosts, services):
flap_history = self.__class__.flap_history
# We compute the flapping change in %
res = 0.0
i = 0
for has_changed in self.flapping_changes:
i += 1
... | [
"Compute the sample list (self.flapping_changes) and determine\n whether the host/service is flapping or not\n\n :param notif_period: notification period object for this host/service\n :type notif_period: alignak.object.timeperiod.Timeperiod\n :param hosts: Hosts objects, used to create ... |
Please provide a description of the function:def add_attempt(self):
self.attempt += 1
self.attempt = min(self.attempt, self.max_check_attempts) | [
"Add an attempt when a object is a non-ok state\n\n :return: None\n "
] |
Please provide a description of the function:def do_check_freshness(self, hosts, services, timeperiods, macromodulations, checkmodulations,
checks, when):
# pylint: disable=too-many-nested-blocks, too-many-branches
now = when
# Before, check if class (host or... | [
"Check freshness and schedule a check now if necessary.\n\n This function is called by the scheduler if Alignak is configured to check the freshness.\n\n It is called for hosts that have the freshness check enabled if they are only\n passively checked.\n\n It is called for services that ... |
Please provide a description of the function:def set_myself_as_problem(self, hosts, services, timeperiods, bi_modulations):
# pylint: disable=too-many-locals
now = time.time()
self.is_problem = True
# we should warn potentials impact of our problem
# and they should be ... | [
" Raise all impact from my error. I'm setting myself\n as a problem, and I register myself as this in all\n hosts/services that depend_on_me. So they are now my\n impacts\n\n :param hosts: hosts objects, used to get impacts\n :type hosts: alignak.objects.host.Hosts\n :param... |
Please provide a description of the function:def update_business_impact_value(self, hosts, services, timeperiods, bi_modulations):
# First save our business_impact if not already do
if self.my_own_business_impact == -1:
self.my_own_business_impact = self.business_impact
# W... | [
"We update our 'business_impact' value with the max of\n the impacts business_impact if we got impacts. And save our 'configuration'\n business_impact if we do not have do it before\n If we do not have impacts, we revert our value\n\n :param hosts: hosts objects, used to get impacts\n ... |
Please provide a description of the function:def no_more_a_problem(self, hosts, services, timeperiods, bi_modulations):
was_pb = self.is_problem
if self.is_problem:
self.is_problem = False
# we warn impacts that we are no more a problem
for impact_id in self... | [
"Remove this objects as an impact for other schedulingitem.\n\n :param hosts: hosts objects, used to get impacts\n :type hosts: alignak.objects.host.Hosts\n :param services: services objects, used to get impacts\n :type services: alignak.objects.service.Services\n :param timeperio... |
Please provide a description of the function:def register_a_problem(self, prob, hosts, services, timeperiods, bi_modulations):
# pylint: disable=too-many-locals
# Maybe we already have this problem? If so, bailout too
if prob.uuid in self.source_problems:
return []
... | [
"Call recursively by potentials impacts so they\n update their source_problems list. But do not\n go below if the problem is not a real one for me\n like If I've got multiple parents for examples\n\n :param prob: problem to register\n :type prob: alignak.objects.schedulingitem.Sch... |
Please provide a description of the function:def unregister_a_problem(self, prob):
self.source_problems.remove(prob.uuid)
# For know if we are still an impact, maybe our dependencies
# are not aware of the remove of the impact state because it's not ordered
# so we can just loo... | [
"Remove the problem from our problems list\n and check if we are still 'impacted'\n\n :param prob: problem to remove\n :type prob: alignak.objects.schedulingitem.SchedulingItem\n :return: None\n "
] |
Please provide a description of the function:def is_enable_action_dependent(self, hosts, services):
# Use to know if notification is raise or not
enable_action = False
for (dep_id, status, _, _) in self.act_depend_of:
if 'n' in status:
enable_action = True
... | [
"\n Check if dependencies states match dependencies statuses\n This basically means that a dependency is in a bad state and\n it can explain this object state.\n\n :param hosts: hosts objects, used to get object in act_depend_of\n :type hosts: alignak.objects.host.Hosts\n :... |
Please provide a description of the function:def check_and_set_unreachability(self, hosts, services):
parent_is_down = []
for (dep_id, _, _, _) in self.act_depend_of:
if dep_id in hosts:
dep = hosts[dep_id]
else:
dep = services[dep_id]
... | [
"\n Check if all dependencies are down, if yes set this object\n as unreachable.\n\n todo: this function do not care about execution_failure_criteria!\n\n :param hosts: hosts objects, used to get object in act_depend_of\n :type hosts: alignak.objects.host.Hosts\n :param ser... |
Please provide a description of the function:def do_i_raise_dependency(self, status, inherit_parents, hosts, services, timeperiods):
# pylint: disable=too-many-locals
# Do I raise dep?
for stat in status:
if self.is_state(stat):
return True
# If we d... | [
"Check if this object or one of its dependency state (chk dependencies) match the status\n\n :param status: state list where dependency matters (notification failure criteria)\n :type status: list\n :param inherit_parents: recurse over parents\n :type inherit_parents: bool\n :para... |
Please provide a description of the function:def is_no_check_dependent(self, hosts, services, timeperiods):
now = time.time()
for (dep_id, status, _, timeperiod_id, inh_parent) in self.chk_depend_of:
timeperiod = timeperiods[timeperiod_id]
if timeperiod is None or timepe... | [
"Check if there is some host/service that this object depend on\n has a state in the status list .\n\n :param hosts: hosts objects, used to raise dependency check\n :type hosts: alignak.objects.host.Hosts\n :param services: services objects, used to raise dependency check\n :type ... |
Please provide a description of the function:def raise_dependencies_check(self, ref_check, hosts, services, timeperiods, macromodulations,
checkmodulations, checks):
# pylint: disable=too-many-locals, too-many-nested-blocks
now = time.time()
cls = self._... | [
"Get checks that we depend on if EVERY following conditions is met::\n\n * timeperiod is valid\n * dep.last_state_update < now - cls.cached_check_horizon (check of dependency is \"old\")\n\n :param ref_check: Check we want to get dependency from\n :type ref_check: alignak.check.Check\n ... |
Please provide a description of the function:def schedule(self, hosts, services, timeperiods, macromodulations, checkmodulations,
checks, force=False, force_time=None):
# pylint: disable=too-many-branches, too-many-arguments, too-many-locals
# next_chk is already set, do not ch... | [
"Main scheduling function\n If a check is in progress, or active check are disabled, do not schedule a check.\n The check interval change with HARD state::\n\n * SOFT: retry_interval\n * HARD: check_interval\n\n The first scheduling is evenly distributed, so all checks\n ar... |
Please provide a description of the function:def compensate_system_time_change(self, difference): # pragma: no cover,
# not with unit tests
# We only need to change some value
for prop in ('last_notification', 'last_state_change', 'last_hard_state_change'):
val = getattr(se... | [
"If a system time change occurs we have to update\n properties time related to reflect change\n\n :param difference: difference between new time and old time\n :type difference:\n :return: None\n "
] |
Please provide a description of the function:def disable_active_checks(self, checks):
self.active_checks_enabled = False
for chk_id in self.checks_in_progress:
chk = checks[chk_id]
chk.status = ACT_STATUS_WAIT_CONSUME
chk.exit_status = self.state_id
... | [
"Disable active checks for this host/service\n Update check in progress with current object information\n\n :param checks: Checks object, to change all checks in progress\n :type checks: alignak.objects.check.Checks\n :return: None\n "
] |
Please provide a description of the function:def remove_in_progress_check(self, check):
# The check is consumed, update the in_checking properties
if check in self.checks_in_progress:
self.checks_in_progress.remove(check)
self.update_in_checking() | [
"Remove check from check in progress\n\n :param check: Check to remove\n :type check: alignak.objects.check.Check\n :return: None\n "
] |
Please provide a description of the function:def remove_in_progress_notification(self, notification):
if notification.uuid in self.notifications_in_progress:
notification.status = ACT_STATUS_ZOMBIE
del self.notifications_in_progress[notification.uuid] | [
"\n Remove a notification and mark them as zombie\n\n :param notification: the notification to remove\n :type notification: alignak.notification.Notification\n :return: None\n "
] |
Please provide a description of the function:def remove_in_progress_notifications(self, master=True):
for notification in list(self.notifications_in_progress.values()):
if master and notification.contact:
continue
# Do not remove some specific notifications
... | [
"Remove all notifications from notifications_in_progress\n\n Preserves some specific notifications (downtime, ...)\n\n :param master: remove master notifications only if True (default value)\n :type master: bool\n :param force: force remove all notifications except if False\n :typ... |
Please provide a description of the function:def get_event_handlers(self, hosts, macromodulations, timeperiods, ext_cmd=False):
cls = self.__class__
# The external command always pass
# if not, only if we enable them (auto launch)
if not ext_cmd and (not self.event_handler_enab... | [
"Raise event handlers if NONE of the following conditions is met::\n\n * externalcmd is False and event_handlers are disabled (globally or locally)\n * externalcmd is False and object is in scheduled dowtime and no event handlers in downtime\n * self.event_handler and cls.global_event_handler a... |
Please provide a description of the function:def get_snapshot(self, hosts, macromodulations, timeperiods): # pragma: no cover, not yet!
# We should have a snapshot_command, to be enabled and of course
# in the good time and state :D
if self.snapshot_command is None:
return
... | [
"\n Raise snapshot event handlers if NONE of the following conditions is met::\n\n * snapshot_command is None\n * snapshot_enabled is disabled\n * snapshot_criteria does not matches current state\n * last_snapshot > now - snapshot_interval * interval_length (previous snapshot too ... |
Please provide a description of the function:def check_for_flexible_downtime(self, timeperiods, hosts, services):
status_updated = False
for downtime_id in self.downtimes:
downtime = self.downtimes[downtime_id]
# Activate flexible downtimes (do not activate triggered dow... | [
"Enter in a downtime if necessary and raise start notification\n When a non Ok state occurs we try to raise a flexible downtime.\n\n :param timeperiods: Timeperiods objects, used for downtime period\n :type timeperiods: alignak.objects.timeperiod.Timeperiods\n :param hosts: hosts objects... |
Please provide a description of the function:def update_hard_unknown_phase_state(self):
self.was_in_hard_unknown_reach_phase = self.in_hard_unknown_reach_phase
# We do not care about SOFT state at all
# and we are sure we are no more in such a phase
if self.state_type != 'HARD'... | [
"Update in_hard_unknown_reach_phase attribute and\n was_in_hard_unknown_reach_phase\n UNKNOWN during a HARD state are not so important, and they should\n not raise notif about it\n\n :return: None\n "
] |
Please provide a description of the function:def consume_result(self, chk, notification_period, hosts,
services, timeperiods, macromodulations, checkmodulations, bi_modulations,
res_modulations, checks, raise_log):
# pylint: disable=too-many-locals, too-many-argumen... | [
"Consume a check return and send action in return\n main function of reaction of checks like raise notifications\n\n Special cases::\n\n * is_flapping: immediate notif when problem\n * is_in_scheduled_downtime: no notification\n * is_volatile: notif immediately (service only)\n\n ... |
Please provide a description of the function:def update_event_and_problem_id(self):
ok_up = self.__class__.ok_up # OK for service, UP for host
if (self.state != self.last_state and self.last_state != 'PENDING' or
self.state != ok_up and self.last_state == 'PENDING'):
... | [
"Update current_event_id and current_problem_id\n Those attributes are used for macros (SERVICEPROBLEMID ...)\n\n :return: None\n "
] |
Please provide a description of the function:def prepare_notification_for_sending(self, notif, contact, macromodulations, timeperiods,
host_ref):
if notif.status == ACT_STATUS_POLLED:
self.update_notification_command(notif, contact, macromodulations,... | [
"Used by scheduler when a notification is ok to be sent (to reactionner).\n Here we update the command with status of now, and we add the contact to set of\n contact we notified. And we raise the log entry\n\n :param notif: notification to send\n :type notif: alignak.objects.notification... |
Please provide a description of the function:def update_notification_command(self, notif, contact, macromodulations, timeperiods,
host_ref=None):
cls = self.__class__
macrosolver = MacroResolver()
data = self.get_data_for_notifications(contact, notif,... | [
"Update the notification command by resolving Macros\n And because we are just launching the notification, we can say\n that this contact has been notified\n\n :param notif: notification to send\n :type notif: alignak.objects.notification.Notification\n :param contact: contact for... |
Please provide a description of the function:def is_escalable(self, notification, escalations, timeperiods):
cls = self.__class__
# We search since when we are in notification for escalations
# that are based on time
in_notif_time = time.time() - notification.creation_time
... | [
"Check if a notification can be escalated.\n Basically call is_eligible for each escalation\n\n :param notification: notification we would like to escalate\n :type notification: alignak.objects.notification.Notification\n :param escalations: Esclations objects, used to get escalation obj... |
Please provide a description of the function:def get_next_notification_time(self, notif, escalations, timeperiods):
# pylint: disable=too-many-locals
res = None
now = time.time()
cls = self.__class__
# Look at the minimum notification interval
notification_inter... | [
"Get the next notification time for a notification\n Take the standard notification_interval or ask for our escalation\n if one of them need a smaller value to escalade\n\n :param notif: Notification we need time\n :type notif: alignak.objects.notification.Notification\n :param es... |
Please provide a description of the function:def get_escalable_contacts(self, notification, escalations, timeperiods):
cls = self.__class__
# We search since when we are in notification for escalations
# that are based on this time
in_notif_time = time.time() - notification.cre... | [
"Get all contacts (uniq) from eligible escalations\n\n :param notification: Notification to get data from (notif number...)\n :type notification: alignak.objects.notification.Notification\n :param escalations: Esclations objects, used to get escalation objects (contact, period)\n :type e... |
Please provide a description of the function:def create_notifications(self, n_type, notification_period, hosts, services,
t_wished=None, author_data=None):
cls = self.__class__
# t_wished==None for the first notification launch after consume
# here we must l... | [
"Create a \"master\" notification here, which will later\n (immediately before the reactionner gets it) be split up\n in many \"child\" notifications, one for each contact.\n\n :param n_type: notification type (\"PROBLEM\", \"RECOVERY\" ...)\n :type n_type: str\n :param notificati... |
Please provide a description of the function:def scatter_notification(self, notif, contacts, notifways, timeperiods, macromodulations,
escalations, host_ref):
# pylint: disable=too-many-locals, too-many-boolean-expressions
if notif.contact:
# only master... | [
"In create_notifications we created a notification master (eg. a template).\n When it's time to hand it over to the reactionner, this master notification needs\n to be split in several child notifications, one for each contact\n\n To be more exact, one for each contact who is willing to accept\... |
Please provide a description of the function:def launch_check(self, timestamp, hosts, services, timeperiods,
macromodulations, checkmodulations, checks, ref_check=None, force=False,
dependent=False):
# pylint: disable=too-many-locals, too-many-arguments
# pylint... | [
"Launch a check (command)\n\n :param timestamp:\n :type timestamp: int\n :param checkmodulations: Checkmodulations objects, used to change check command if necessary\n :type checkmodulations: alignak.objects.checkmodulation.Checkmodulations\n :param ref_check:\n :type ref_c... |
Please provide a description of the function:def get_perfdata_command(self, hosts, macromodulations, timeperiods):
cls = self.__class__
if not cls.process_performance_data or not self.process_perf_data:
return
if cls.perfdata_command is not None:
macroresolver =... | [
"Add event_handler to process performance data if necessary (not disabled)\n\n :param macromodulations: Macro modulations objects, used in commands (notif, check)\n :type macromodulations: alignak.objects.macromodulation.Macromodulations\n :return: None\n "
] |
Please provide a description of the function:def create_business_rules(self, hosts, services, hostgroups, servicegroups,
macromodulations, timeperiods, running=False):
# pylint: disable=too-many-locals
cmdcall = getattr(self, 'check_command', None)
# If we... | [
"Create business rules if necessary (cmd contains bp_rule)\n\n :param hosts: Hosts object to look for objects\n :type hosts: alignak.objects.host.Hosts\n :param services: Services object to look for objects\n :type services: alignak.objects.service.Services\n :param running: flag ... |
Please provide a description of the function:def get_business_rule_output(self, hosts, services, macromodulations, timeperiods):
# pylint: disable=too-many-locals, too-many-branches
got_business_rule = getattr(self, 'got_business_rule', False)
# Checks that the service is a business rul... | [
"\n Returns a status string for business rules based items formatted\n using business_rule_output_template attribute as template.\n\n The template may embed output formatting for itself, and for its child\n (dependent) items. Child format string is expanded into the $( and )$,\n u... |
Please provide a description of the function:def fill_data_brok_from(self, data, brok_type):
super(SchedulingItem, self).fill_data_brok_from(data, brok_type)
# workaround/easy trick to have the command_name of this
# SchedulingItem in its check_result brok
if brok_type == 'check... | [
"Fill data brok dependent on the brok_type\n\n :param data: data to fill\n :type data: dict\n :param brok_type: brok type\n :type: str\n :return: None\n "
] |
Please provide a description of the function:def acknowledge_problem(self, notification_period, hosts, services, sticky, notify, author,
comment, end_time=0):
# pylint: disable=too-many-arguments
comm = None
logger.debug("Acknowledge requested for %s %s.", se... | [
"\n Add an acknowledge\n\n :param sticky: acknowledge will be always present is host return in UP state\n :type sticky: integer\n :param notify: if to 1, send a notification\n :type notify: integer\n :param author: name of the author or the acknowledge\n :type author... |
Please provide a description of the function:def check_for_expire_acknowledge(self):
if (self.acknowledgement and
self.acknowledgement.end_time != 0 and
self.acknowledgement.end_time < time.time()):
self.unacknowledge_problem() | [
"\n If have acknowledge and is expired, delete it\n\n :return: None\n "
] |
Please provide a description of the function:def unacknowledge_problem(self):
if self.problem_has_been_acknowledged:
logger.debug("[item::%s] deleting acknowledge of %s",
self.get_name(),
self.get_full_name())
self.problem_has_be... | [
"\n Remove the acknowledge, reset the flag. The comment is deleted\n\n :return: None\n "
] |
Please provide a description of the function:def unacknowledge_problem_if_not_sticky(self):
if hasattr(self, 'acknowledgement') and self.acknowledgement is not None:
if not self.acknowledgement.sticky:
self.unacknowledge_problem() | [
"\n Remove the acknowledge if it is not sticky\n\n :return: None\n "
] |
Please provide a description of the function:def raise_freshness_log_entry(self, t_stale_by):
logger.warning("The freshness period of %s '%s' is expired by %ss "
"(threshold=%ss + %ss). Attempt: %s / %s. "
"I'm forcing the state to freshness state (%s / %s)... | [
"Raise freshness alert entry (warning level)\n\n Example : \"The freshness period of host 'host_name' is expired\n by 0d 0h 17m 6s (threshold=0d 1h 0m 0s).\n Attempt: 1 / 1.\n I'm forcing the state to freshness state (d / HARD)\"\n\n :param t_stale... |
Please provide a description of the function:def set_impact_state(self):
cls = self.__class__
if cls.enable_problem_impacts_states_change:
logger.debug("%s is impacted and goes UNREACHABLE", self)
# Track the old state (problem occured before a new check)
se... | [
"We just go an impact, so we go unreachable\n But only if we enable this state change in the conf\n\n :return: None\n "
] |
Please provide a description of the function:def unset_impact_state(self):
cls = self.__class__
if cls.enable_problem_impacts_states_change and not self.state_changed_since_impact:
self.state = self.state_before_impact
self.state_id = self.state_id_before_impact | [
"Unset impact, only if impact state change is set in configuration\n\n :return: None\n "
] |
Please provide a description of the function:def set_unreachable(self):
self.state_id = 4
self.state = u'UNREACHABLE'
self.last_time_unreachable = int(time.time()) | [
"Set unreachable: all our parents (dependencies) are not ok\n Unreachable is different from down/critical\n\n :return:None\n "
] |
Please provide a description of the function:def is_correct(self):
# pylint: disable=too-many-branches
state = True
if hasattr(self, 'trigger') and getattr(self, 'trigger', None):
self.add_warning("[%s::%s] 'trigger' property is not allowed"
% (... | [
"\n 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 find_by_filter(self, filters, all_items):
items = []
for i in self:
failed = False
if hasattr(i, "host"):
all_items["service"] = i
else:
all_items["host"] = i
for fil... | [
"\n Find items by filters\n\n :param filters: list of filters\n :type filters: list\n :param all_items: monitoring items\n :type: dict\n :return: list of items\n :rtype: list\n "
] |
Please provide a description of the function:def add_act_dependency(self, son_id, parent_id, notif_failure_criteria, dep_period,
inherits_parents):
if son_id in self:
son = self[son_id]
else:
msg = "Dependency son (%s) unknown, configuration er... | [
"\n Add a logical dependency for actions between two hosts or services.\n\n :param son_id: uuid of son host\n :type son_id: str\n :param parent_id: uuid of parent host\n :type parent_id: str\n :param notif_failure_criteria: notification failure criteria,\n notificati... |
Please provide a description of the function:def del_act_dependency(self, son_id, parent_id): # pragma: no cover, not yet tested
son = self[son_id]
parent = self[parent_id]
to_del = []
# First we remove in my list
for (host, status, timeperiod, inherits_parent) in son.a... | [
"Remove act_dependency between two hosts or services.\n\n TODO: do we really intend to remove dynamically ?\n\n :param son_id: uuid of son host/service\n :type son_id: str\n :param parent_id: uuid of parent host/service\n :type parent_id: str\n :return: None\n "
] |
Please provide a description of the function:def add_chk_dependency(self, son_id, parent_id, notif_failure_criteria, dep_period,
inherits_parents):
son = self[son_id]
parent = self[parent_id]
son.chk_depend_of.append((parent_id, notif_failure_criteria, 'logic_... | [
"\n Add a logical dependency for checks between two hosts or services.\n\n :param son_id: uuid of son host/service\n :type son_id: str\n :param parent_id: uuid of parent host/service\n :type parent_id: str\n :param notif_failure_criteria: notification failure criteria,\n ... |
Please provide a description of the function:def create_business_rules(self, hosts, services, hostgroups, servicegroups,
macromodulations, timeperiods):
for item in self:
item.create_business_rules(hosts, services, hostgroups,
... | [
"\n Loop on hosts or services and call SchedulingItem.create_business_rules\n\n :param hosts: hosts to link to\n :type hosts: alignak.objects.host.Hosts\n :param services: services to link to\n :type services: alignak.objects.service.Services\n :param hostgroups: hostgroups... |
Please provide a description of the function:def get_services_by_explosion(self, servicegroups):
# pylint: disable=access-member-before-definition
# First we tag the hg so it will not be explode
# if a son of it already call it
self.already_exploded = True
# Now the rec... | [
"\n Get all services of this servicegroup and add it in members container\n\n :param servicegroups: servicegroups object\n :type servicegroups: alignak.objects.servicegroup.Servicegroups\n :return: return empty string or list of members\n :rtype: str or list\n "
] |
Please provide a description of the function:def add_member(self, service_name, servicegroup_name):
servicegroup = self.find_by_name(servicegroup_name)
if not servicegroup:
servicegroup = Servicegroup({'servicegroup_name': servicegroup_name,
... | [
"Add a member (service) to this servicegroup\n\n :param service_name: member (service) name\n :type service_name: str\n :param servicegroup_name: servicegroup name\n :type servicegroup_name: str\n :return: None\n "
] |
Please provide a description of the function:def get_members_of_group(self, gname):
hostgroup = self.find_by_name(gname)
if hostgroup:
return hostgroup.get_services()
return [] | [
"Get all members of a group which name is given in parameter\n\n :param gname: name of the group\n :type gname: str\n :return: list of the services in the group\n :rtype: list[alignak.objects.service.Service]\n "
] |
Please provide a description of the function:def linkify_servicegroups_services(self, hosts, services):
for servicegroup in self:
mbrs = servicegroup.get_services()
# The new member list, in id
new_mbrs = []
seek = 0
host_name = ''
... | [
"\n We just search for each host the id of the host\n and replace the name by the id\n TODO: very slow for high services, so search with host list,\n not service one\n\n :param hosts: hosts object\n :type hosts: alignak.objects.host.Hosts\n :param services: services ... |
Please provide a description of the function:def explode(self):
# We do not want a same service group to be exploded again and again
# so we tag it
for tmp_sg in list(self.items.values()):
tmp_sg.already_exploded = False
for servicegroup in list(self.items.values())... | [
"\n Get services and put them in members container\n\n :return: None\n "
] |
Please provide a description of the function:def main():
try:
args = parse_daemon_args(True)
# Protect for windows multiprocessing that will RELAUNCH all
while True:
daemon = Arbiter(**args.__dict__)
daemon.main()
if not daemon.need_config_reload:
... | [
"Parse args and run main daemon function\n\n :return: None\n "
] |
Please provide a description of the function:def setup_logger(logger_configuration_file, log_dir=None, process_name='', log_file=''):
# pylint: disable=too-many-branches
logger_ = logging.getLogger(ALIGNAK_LOGGER_NAME)
for handler in logger_.handlers:
if not process_name:
break
... | [
"\n Configure the provided logger\n - get and update the content of the Json configuration file\n - configure the logger with this file\n\n If a log_dir and process_name are provided, the format and filename in the configuration file\n are updated with the provided values if they contain the patterns... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.