Code
stringlengths
103
85.9k
Summary
sequencelengths
0
94
Please provide a description of the function:def _get_object(self, o_type, o_name=None): try: o_found = None o_list = self._get_objects(o_type) if o_list: if o_name is None: return serialize(o_list, True) if o_list else None # We expected a name... o_found = o_list.find_by_name(o_name) if not o_found: # ... but perharps we got an object uuid o_found = o_list[o_name] except Exception: # pylint: disable=broad-except return None return serialize(o_found, True) if o_found else None
[ "Get an object from the scheduler\n\n Returns None if the required object type (`o_type`) is not known.\n Else returns the serialized object if found. The object is searched first with\n o_name as its name and then with o_name as its uuid.\n\n :param o_type: searched object type\n :type o_type: str\n :param name: searched object name\n :type name: str\n :return: serialized object\n :rtype: str\n " ]
Please provide a description of the function:def is_a_module(self, module_type): if hasattr(self, 'type'): return module_type in self.type return module_type in self.module_types
[ "\n Is the module of the required type?\n\n :param module_type: module type to check\n :type: str\n :return: True / False\n " ]
Please provide a description of the function:def serialize(self): res = super(Module, self).serialize() cls = self.__class__ for prop in self.__dict__: if prop in cls.properties or prop in cls.running_properties or prop in ['properties', 'my_daemon']: continue res[prop] = getattr(self, prop) return res
[ "A module may have some properties that are not defined in the class properties list.\n Serializing a module is the same as serializing an Item but we also also include all the\n existing properties that are not defined in the properties or running_properties\n class list.\n\n We must also exclude the reference to the daemon that loaded the module!\n " ]
Please provide a description of the function:def linkify_s_by_plug(self): for module in self: new_modules = [] for related in getattr(module, 'modules', []): related = related.strip() if not related: continue o_related = self.find_by_name(related) if o_related is not None: new_modules.append(o_related.uuid) else: self.add_error("the module '%s' for the module '%s' is unknown!" % (related, module.get_name())) module.modules = new_modules
[ "Link a module to some other modules\n\n :return: None\n " ]
Please provide a description of the function:def get_start_of_day(year, month, day): # DST is not known in the provided date try: timestamp = time.mktime((year, month, day, 00, 00, 00, 0, 0, -1)) except (OverflowError, ValueError): # Windows mktime sometimes crashes on (1970, 1, 1, ...) timestamp = 0.0 return int(timestamp)
[ "Get the timestamp associated to the first second of a specific day\n\n :param year: date year\n :type year: int\n :param month: date month\n :type month: int\n :param day: date day\n :type day: int\n :return: timestamp\n :rtype: int\n " ]
Please provide a description of the function:def get_end_of_day(year, month, day): # DST is not known in the provided date timestamp = time.mktime((year, month, day, 23, 59, 59, 0, 0, -1)) return int(timestamp)
[ "Get the timestamp associated to the last second of a specific day\n\n :param year: date year\n :type year: int\n :param month: date month (int)\n :type month: int\n :param day: date day\n :type day: int\n :return: timestamp\n :rtype: int\n " ]
Please provide a description of the function:def get_sec_from_morning(timestamp): t_lt = time.localtime(timestamp) return t_lt.tm_hour * 3600 + t_lt.tm_min * 60 + t_lt.tm_sec
[ "Get the number of seconds elapsed since the beginning of the\n day deducted from the provided timestamp\n\n :param timestamp: time to use for computation\n :type timestamp: int\n :return: timestamp\n :rtype: int\n " ]
Please provide a description of the function:def find_day_by_weekday_offset(year, month, weekday, offset): # thanks calendar :) cal = calendar.monthcalendar(year, month) # If we ask for a -1 day, just reverse cal if offset < 0: offset = abs(offset) cal.reverse() # ok go for it nb_found = 0 try: for i in range(0, offset + 1): # in cal 0 mean "there are no day here :)" if cal[i][weekday] != 0: nb_found += 1 if nb_found == offset: return cal[i][weekday] return None except KeyError: return None
[ "Get the day number based on a date and offset\n\n :param year: date year\n :type year: int\n :param month: date month\n :type month: int\n :param weekday: date week day\n :type weekday: int\n :param offset: offset (-1 is last, 1 is first etc)\n :type offset: int\n :return: day number in the month\n :rtype: int\n\n >>> find_day_by_weekday_offset(2010, 7, 1, -1)\n 27\n " ]
Please provide a description of the function:def find_day_by_offset(year, month, offset): (_, days_in_month) = calendar.monthrange(year, month) if offset >= 0: return min(offset, days_in_month) return max(1, days_in_month + offset + 1)
[ "Get the month day based on date and offset\n\n :param year: date year\n :type year: int\n :param month: date month\n :type month: int\n :param offset: offset in day to compute (usually negative)\n :type offset: int\n :return: day number in the month\n :rtype: int\n\n >>> find_day_by_offset(2015, 7, -1)\n 31\n " ]
Please provide a description of the function:def serialize(self): return {"hstart": self.hstart, "mstart": self.mstart, "hend": self.hend, "mend": self.mend, "is_valid": self.is_valid}
[ "This function serialize into a simple dict object.\n It is used when transferring data to other daemons over the network (http)\n\n Here we directly return all attributes\n\n :return: json representation of a Timerange\n :rtype: dict\n " ]
Please provide a description of the function:def get_first_sec_out_from_morning(self): # If start at 0:0, the min out is the end if self.hstart == 0 and self.mstart == 0: return self.hend * 3600 + self.mend * 60 return 0
[ "Get the first second (from midnight) where we are out of the timerange\n\n :return: seconds from midnight where timerange is not effective\n :rtype: int\n " ]
Please provide a description of the function:def is_time_valid(self, timestamp): sec_from_morning = get_sec_from_morning(timestamp) return (self.is_valid and self.hstart * 3600 + self.mstart * 60 <= sec_from_morning <= self.hend * 3600 + self.mend * 60)
[ "Check if time is valid for this Timerange\n\n If sec_from_morning is not provided, get the value.\n\n :param timestamp: time to check\n :type timestamp: int\n :return: True if time is valid (in interval), False otherwise\n :rtype: bool\n " ]
Please provide a description of the function:def is_time_valid(self, timestamp): if self.is_time_day_valid(timestamp): for timerange in self.timeranges: if timerange.is_time_valid(timestamp): return True return False
[ "Check if time is valid for one of the timerange.\n\n :param timestamp: time to check\n :type timestamp: int\n :return: True if one of the timerange is valid for t, False otherwise\n :rtype: bool\n " ]
Please provide a description of the function:def get_min_sec_from_morning(self): mins = [] for timerange in self.timeranges: mins.append(timerange.get_sec_from_morning()) return min(mins)
[ "Get the first second from midnight where a timerange is effective\n\n :return: smallest amount of second from midnight of all timerange\n :rtype: int\n " ]
Please provide a description of the function:def get_min_sec_out_from_morning(self): mins = [] for timerange in self.timeranges: mins.append(timerange.get_first_sec_out_from_morning()) return min(mins)
[ "Get the first second (from midnight) where we are out of a timerange\n\n :return: smallest seconds from midnight of all timerange where it is not effective\n :rtype: int\n " ]
Please provide a description of the function:def get_min_from_t(self, timestamp): if self.is_time_valid(timestamp): return timestamp t_day_epoch = get_day(timestamp) tr_mins = self.get_min_sec_from_morning() return t_day_epoch + tr_mins
[ "Get next time from t where a timerange is valid (withing range)\n\n :param timestamp: base time to look for the next one\n :return: time where a timerange is valid\n :rtype: int\n " ]
Please provide a description of the function:def is_time_day_valid(self, timestamp): (start_time, end_time) = self.get_start_and_end_time(timestamp) return start_time <= timestamp <= end_time
[ "Check if it is within start time and end time of the DateRange\n\n :param timestamp: time to check\n :type timestamp: int\n :return: True if t in range, False otherwise\n :rtype: bool\n " ]
Please provide a description of the function:def get_next_future_timerange_valid(self, timestamp): sec_from_morning = get_sec_from_morning(timestamp) starts = [] for timerange in self.timeranges: tr_start = timerange.hstart * 3600 + timerange.mstart * 60 if tr_start >= sec_from_morning: starts.append(tr_start) if starts != []: return min(starts) return None
[ "Get the next valid timerange (next timerange start in timeranges attribute)\n\n :param timestamp: base time\n :type timestamp: int\n :return: next time when a timerange is valid\n :rtype: None | int\n " ]
Please provide a description of the function:def get_next_future_timerange_invalid(self, timestamp): sec_from_morning = get_sec_from_morning(timestamp) ends = [] for timerange in self.timeranges: tr_end = timerange.hend * 3600 + timerange.mend * 60 if tr_end >= sec_from_morning: # Remove the last second of the day for 00->24h" if tr_end == 86400: tr_end = 86399 ends.append(tr_end) if ends != []: return min(ends) return None
[ "Get next invalid time for timeranges\n\n :param timestamp: time to check\n :type timestamp: int\n :return: next time when a timerange is not valid\n :rtype: None | int\n " ]
Please provide a description of the function:def get_next_valid_day(self, timestamp): if self.get_next_future_timerange_valid(timestamp) is None: # this day is finish, we check for next period (start_time, _) = self.get_start_and_end_time(get_day(timestamp) + 86400) else: (start_time, _) = self.get_start_and_end_time(timestamp) if timestamp <= start_time: return get_day(start_time) if self.is_time_day_valid(timestamp): return get_day(timestamp) return None
[ "Get next valid day for timerange\n\n :param timestamp: time we compute from\n :type timestamp: int\n :return: timestamp of the next valid day (midnight) in LOCAL time.\n :rtype: int | None\n " ]
Please provide a description of the function:def get_next_valid_time_from_t(self, timestamp): if self.is_time_valid(timestamp): return timestamp # First we search for the day of t t_day = self.get_next_valid_day(timestamp) if t_day is None: return t_day # We search for the min of all tr.start > sec_from_morning # if it's the next day, use a start of the day search for timerange if timestamp < t_day: sec_from_morning = self.get_next_future_timerange_valid(t_day) else: # it is in this day, so look from t (can be in the evening or so) sec_from_morning = self.get_next_future_timerange_valid(timestamp) if sec_from_morning is not None: if t_day is not None and sec_from_morning is not None: return t_day + sec_from_morning # Then we search for the next day of t # The sec will be the min of the day timestamp = get_day(timestamp) + 86400 t_day2 = self.get_next_valid_day(timestamp) sec_from_morning = self.get_next_future_timerange_valid(t_day2) if t_day2 is not None and sec_from_morning is not None: return t_day2 + sec_from_morning # I did not found any valid time return None
[ "Get next valid time for time range\n\n :param timestamp: time we compute from\n :type timestamp: int\n :return: timestamp of the next valid time (LOCAL TIME)\n :rtype: int | None\n " ]
Please provide a description of the function:def get_next_invalid_day(self, timestamp): # pylint: disable=no-else-return if self.is_time_day_invalid(timestamp): return timestamp next_future_timerange_invalid = self.get_next_future_timerange_invalid(timestamp) # If today there is no more unavailable timerange, search the next day if next_future_timerange_invalid is None: # this day is finish, we check for next period (start_time, end_time) = self.get_start_and_end_time(get_day(timestamp)) else: (start_time, end_time) = self.get_start_and_end_time(timestamp) # (start_time, end_time) = self.get_start_and_end_time(t) # The next invalid day can be t day if there a possible # invalid time range (timerange is not 00->24 if next_future_timerange_invalid is not None: if start_time <= timestamp <= end_time: return get_day(timestamp) if start_time >= timestamp: return get_day(start_time) else: # Else, there is no possibility than in our start_time<->end_time we got # any invalid time (full period out). So it's end_time+1 sec (tomorrow of end_time) return get_day(end_time + 1) return None
[ "Get next day where timerange is not active\n\n :param timestamp: time we compute from\n :type timestamp: int\n :return: timestamp of the next invalid day (midnight) in LOCAL time.\n :rtype: int | None\n " ]
Please provide a description of the function:def get_next_invalid_time_from_t(self, timestamp): if not self.is_time_valid(timestamp): return timestamp # First we search for the day of time range t_day = self.get_next_invalid_day(timestamp) # We search for the min of all tr.start > sec_from_morning # if it's the next day, use a start of the day search for timerange if timestamp < t_day: sec_from_morning = self.get_next_future_timerange_invalid(t_day) else: # it is in this day, so look from t (can be in the evening or so) sec_from_morning = self.get_next_future_timerange_invalid(timestamp) # tr can't be valid, or it will be return at the beginning # sec_from_morning = self.get_next_future_timerange_invalid(t) # Ok we've got a next invalid day and a invalid possibility in # timerange, so the next invalid is this day+sec_from_morning if t_day is not None and sec_from_morning is not None: return t_day + sec_from_morning + 1 # We've got a day but no sec_from_morning: the timerange is full (0->24h) # so the next invalid is this day at the day_start if t_day is not None and sec_from_morning is None: return t_day # Then we search for the next day of t # The sec will be the min of the day timestamp = get_day(timestamp) + 86400 t_day2 = self.get_next_invalid_day(timestamp) sec_from_morning = self.get_next_future_timerange_invalid(t_day2) if t_day2 is not None and sec_from_morning is not None: return t_day2 + sec_from_morning + 1 if t_day2 is not None and sec_from_morning is None: return t_day2 # I did not found any valid time return None
[ "Get next invalid time for time range\n\n :param timestamp: time we compute from\n :type timestamp: int\n :return: timestamp of the next invalid time (LOCAL TIME)\n :rtype: int\n " ]
Please provide a description of the function:def serialize(self): return {'syear': self.syear, 'smon': self.smon, 'smday': self.smday, 'swday': self.swday, 'swday_offset': self.swday_offset, 'eyear': self.eyear, 'emon': self.emon, 'emday': self.emday, 'ewday': self.ewday, 'ewday_offset': self.ewday_offset, 'skip_interval': self.skip_interval, 'other': self.other, 'timeranges': [t.serialize() for t in self.timeranges]}
[ "This function serialize into a simple dict object.\n It is used when transferring data to other daemons over the network (http)\n\n Here we directly return all attributes\n\n :return: json representation of a Daterange\n :rtype: dict\n " ]
Please provide a description of the function:def get_start_and_end_time(self, ref=None): return (get_start_of_day(self.syear, int(self.smon), self.smday), get_end_of_day(self.eyear, int(self.emon), self.emday))
[ "Specific function to get start time and end time for CalendarDaterange\n\n :param ref: time in seconds\n :type ref: int\n :return: tuple with start and end time\n :rtype: tuple (int, int)\n " ]
Please provide a description of the function:def serialize(self): return {'day': self.day, 'other': self.other, 'timeranges': [t.serialize() for t in self.timeranges]}
[ "This function serialize into a simple dict object.\n It is used when transferring data to other daemons over the network (http)\n\n Here we directly return all attributes\n\n :return: json representation of a Daterange\n :rtype: dict\n " ]
Please provide a description of the function:def is_correct(self): valid = self.day in Daterange.weekdays if not valid: logger.error("Error: %s is not a valid day", self.day) # Check also if Daterange is correct. valid &= super(StandardDaterange, self).is_correct() return valid
[ "Check if the Daterange is correct : weekdays are valid\n\n :return: True if weekdays are valid, False otherwise\n :rtype: bool\n " ]
Please provide a description of the function:def get_start_and_end_time(self, ref=None): now = time.localtime(ref) self.syear = now.tm_year self.month = now.tm_mon self.wday = now.tm_wday day_id = Daterange.get_weekday_id(self.day) today_morning = get_start_of_day(now.tm_year, now.tm_mon, now.tm_mday) tonight = get_end_of_day(now.tm_year, now.tm_mon, now.tm_mday) day_diff = (day_id - now.tm_wday) % 7 morning = datetime.fromtimestamp(today_morning) + timedelta(days=day_diff) night = datetime.fromtimestamp(tonight) + timedelta(days=day_diff) return (int(morning.strftime("%s")), int(night.strftime("%s")))
[ "Specific function to get start time and end time for StandardDaterange\n\n :param ref: time in seconds\n :type ref: int\n :return: tuple with start and end time\n :rtype: tuple (int, int)\n " ]
Please provide a description of the function:def is_correct(self): valid = True valid &= self.swday in range(7) if not valid: logger.error("Error: %s is not a valid day", self.swday) valid &= self.ewday in range(7) if not valid: logger.error("Error: %s is not a valid day", self.ewday) return valid
[ "Check if the Daterange is correct : weekdays are valid\n\n :return: True if weekdays are valid, False otherwise\n :rtype: bool\n " ]
Please provide a description of the function:def get_start_and_end_time(self, ref=None): now = time.localtime(ref) if self.syear == 0: self.syear = now.tm_year day_start = find_day_by_weekday_offset(self.syear, self.smon, self.swday, self.swday_offset) start_time = get_start_of_day(self.syear, self.smon, day_start) if self.eyear == 0: self.eyear = now.tm_year day_end = find_day_by_weekday_offset(self.eyear, self.emon, self.ewday, self.ewday_offset) end_time = get_end_of_day(self.eyear, self.emon, day_end) now_epoch = time.mktime(now) if start_time > end_time: # the period is between years if now_epoch > end_time: # check for next year day_end = find_day_by_weekday_offset(self.eyear + 1, self.emon, self.ewday, self.ewday_offset) end_time = get_end_of_day(self.eyear + 1, self.emon, day_end) else: # it s just that the start was the last year day_start = find_day_by_weekday_offset(self.syear - 1, self.smon, self.swday, self.swday_offset) start_time = get_start_of_day(self.syear - 1, self.smon, day_start) else: if now_epoch > end_time: # just have to check for next year if necessary day_start = find_day_by_weekday_offset(self.syear + 1, self.smon, self.swday, self.swday_offset) start_time = get_start_of_day(self.syear + 1, self.smon, day_start) day_end = find_day_by_weekday_offset(self.eyear + 1, self.emon, self.ewday, self.ewday_offset) end_time = get_end_of_day(self.eyear + 1, self.emon, day_end) return (start_time, end_time)
[ "Specific function to get start time and end time for MonthWeekDayDaterange\n\n :param ref: time in seconds\n :type ref: int | None\n :return: tuple with start and end time\n :rtype: tuple\n " ]
Please provide a description of the function:def get_start_and_end_time(self, ref=None): now = time.localtime(ref) if self.syear == 0: self.syear = now.tm_year day_start = find_day_by_offset(self.syear, self.smon, self.smday) start_time = get_start_of_day(self.syear, self.smon, day_start) if self.eyear == 0: self.eyear = now.tm_year day_end = find_day_by_offset(self.eyear, self.emon, self.emday) end_time = get_end_of_day(self.eyear, self.emon, day_end) now_epoch = time.mktime(now) if start_time > end_time: # the period is between years if now_epoch > end_time: # check for next year day_end = find_day_by_offset(self.eyear + 1, self.emon, self.emday) end_time = get_end_of_day(self.eyear + 1, self.emon, day_end) else: # it s just that start was the last year day_start = find_day_by_offset(self.syear - 1, self.smon, self.emday) start_time = get_start_of_day(self.syear - 1, self.smon, day_start) else: if now_epoch > end_time: # just have to check for next year if necessary day_start = find_day_by_offset(self.syear + 1, self.smon, self.smday) start_time = get_start_of_day(self.syear + 1, self.smon, day_start) day_end = find_day_by_offset(self.eyear + 1, self.emon, self.emday) end_time = get_end_of_day(self.eyear + 1, self.emon, day_end) return (start_time, end_time)
[ "Specific function to get start time and end time for MonthDateDaterange\n\n :param ref: time in seconds\n :type ref: int\n :return: tuple with start and end time\n :rtype: tuple (int, int)\n " ]
Please provide a description of the function:def get_start_and_end_time(self, ref=None): now = time.localtime(ref) # If no year, it's our year if self.syear == 0: self.syear = now.tm_year month_start_id = now.tm_mon day_start = find_day_by_weekday_offset(self.syear, month_start_id, self.swday, self.swday_offset) start_time = get_start_of_day(self.syear, month_start_id, day_start) # Same for end year if self.eyear == 0: self.eyear = now.tm_year month_end_id = now.tm_mon day_end = find_day_by_weekday_offset(self.eyear, month_end_id, self.ewday, self.ewday_offset) end_time = get_end_of_day(self.eyear, month_end_id, day_end) # Maybe end_time is before start. So look for the # next month if start_time > end_time: month_end_id += 1 if month_end_id > 12: month_end_id = 1 self.eyear += 1 day_end = find_day_by_weekday_offset(self.eyear, month_end_id, self.ewday, self.ewday_offset) end_time = get_end_of_day(self.eyear, month_end_id, day_end) now_epoch = time.mktime(now) # But maybe we look not enought far. We should add a month if end_time < now_epoch: month_end_id += 1 month_start_id += 1 if month_end_id > 12: month_end_id = 1 self.eyear += 1 if month_start_id > 12: month_start_id = 1 self.syear += 1 # First start day_start = find_day_by_weekday_offset(self.syear, month_start_id, self.swday, self.swday_offset) start_time = get_start_of_day(self.syear, month_start_id, day_start) # Then end day_end = find_day_by_weekday_offset(self.eyear, month_end_id, self.ewday, self.ewday_offset) end_time = get_end_of_day(self.eyear, month_end_id, day_end) return (start_time, end_time)
[ "Specific function to get start time and end time for WeekDayDaterange\n\n :param ref: time in seconds\n :type ref: int\n :return: tuple with start and end time\n :rtype: tuple (int, int)\n " ]
Please provide a description of the function:def get_start_and_end_time(self, ref=None): now = time.localtime(ref) if self.syear == 0: self.syear = now.tm_year month_start_id = now.tm_mon day_start = find_day_by_offset(self.syear, month_start_id, self.smday) start_time = get_start_of_day(self.syear, month_start_id, day_start) if self.eyear == 0: self.eyear = now.tm_year month_end_id = now.tm_mon day_end = find_day_by_offset(self.eyear, month_end_id, self.emday) end_time = get_end_of_day(self.eyear, month_end_id, day_end) now_epoch = time.mktime(now) if start_time > end_time: month_start_id -= 1 if month_start_id < 1: month_start_id = 12 self.syear -= 1 day_start = find_day_by_offset(self.syear, month_start_id, self.smday) start_time = get_start_of_day(self.syear, month_start_id, day_start) if end_time < now_epoch: month_end_id += 1 month_start_id += 1 if month_end_id > 12: month_end_id = 1 self.eyear += 1 if month_start_id > 12: month_start_id = 1 self.syear += 1 # For the start day_start = find_day_by_offset(self.syear, month_start_id, self.smday) start_time = get_start_of_day(self.syear, month_start_id, day_start) # For the end day_end = find_day_by_offset(self.eyear, month_end_id, self.emday) end_time = get_end_of_day(self.eyear, month_end_id, day_end) return (start_time, end_time)
[ "Specific function to get start time and end time for MonthDayDaterange\n\n :param ref: time in seconds\n :type ref: int\n :return: tuple with start and end time\n :rtype: tuple (int, int)\n " ]
Please provide a description of the function:def send_an_element(self, element): # Comment this log because it raises an encoding exception on Travis CI with python 2.7! # logger.debug("Sending to %s for %s", self.daemon, element) if hasattr(self.daemon, "add"): func = getattr(self.daemon, "add") if isinstance(func, collections.Callable): try: func(element) except Exception as exp: # pylint: disable=broad-except logger.critical("Daemon report exception: %s", exp) return logger.critical("External command or Brok could not be sent to any daemon!")
[ "Send an element (Brok, Comment,...) to our daemon\n\n Use the daemon `add` function if it exists, else raise an error log\n\n :param element: elementto be sent\n :type: alignak.Brok, or Comment, or Downtime, ...\n :return:\n " ]
Please provide a description of the function:def resolve_command(self, excmd): # Maybe the command is invalid. Bailout try: command = excmd.cmd_line except AttributeError as exp: # pragma: no cover, simple protection logger.warning("resolve_command, error with command %s", excmd) logger.exception("Exception: %s", exp) return None # Parse command command = command.strip() cmd = self.get_command_and_args(command, excmd) if cmd is None: return cmd # If we are a receiver, bail out here... do not try to execute the command if self.mode == 'receiver' and not cmd.get('internal', False): return cmd if self.mode == 'applyer' and self.log_external_commands: make_a_log = True # #912: only log an external command if it is not a passive check if self.my_conf.log_passive_checks and cmd['c_name'] \ in ['process_host_check_result', 'process_service_check_result']: # Do not log the command make_a_log = False if make_a_log: # I am a command dispatcher, notifies to my arbiter self.send_an_element(make_monitoring_log('info', 'EXTERNAL COMMAND: ' + command)) if not cmd['global']: # Execute the command c_name = cmd['c_name'] args = cmd['args'] logger.debug("Execute command: %s %s", c_name, str(args)) logger.debug("Command time measurement: %s (%d s)", excmd.creation_timestamp, time.time() - excmd.creation_timestamp) statsmgr.timer('external-commands.latency', time.time() - excmd.creation_timestamp) getattr(self, c_name)(*args) else: # Send command to all our schedulers for scheduler_link in self.my_conf.schedulers: logger.debug("Preparing an external command '%s' for the scheduler %s", excmd, scheduler_link.name) scheduler_link.pushed_commands.append(excmd.cmd_line) return cmd
[ "Parse command and dispatch it (to schedulers for example) if necessary\n If the command is not global it will be executed.\n\n :param excmd: external command to handle\n :type excmd: alignak.external_command.ExternalCommand\n :return: result of command parsing. None for an invalid command.\n " ]
Please provide a description of the function:def search_host_and_dispatch(self, host_name, command, extcmd): # pylint: disable=too-many-branches logger.debug("Calling search_host_and_dispatch for %s", host_name) host_found = False # If we are a receiver, just look in the receiver if self.mode == 'receiver': logger.debug("Receiver is searching a scheduler for the external command %s %s", host_name, command) scheduler_link = self.daemon.get_scheduler_from_hostname(host_name) if scheduler_link: host_found = True logger.debug("Receiver pushing external command to scheduler %s", scheduler_link.name) scheduler_link.pushed_commands.append(extcmd) else: logger.warning("I did not found a scheduler for the host: %s", host_name) else: for cfg_part in list(self.cfg_parts.values()): if cfg_part.hosts.find_by_name(host_name) is not None: logger.debug("Host %s found in a configuration", host_name) if cfg_part.is_assigned: host_found = True scheduler_link = cfg_part.scheduler_link logger.debug("Sending command to the scheduler %s", scheduler_link.name) scheduler_link.push_external_commands([command]) # scheduler_link.my_daemon.external_commands.append(command) break else: logger.warning("Problem: the host %s was found in a configuration, " "but this configuration is not assigned to any scheduler!", host_name) if not host_found: if self.accept_passive_unknown_check_results: brok = self.get_unknown_check_result_brok(command) if brok: self.send_an_element(brok) else: logger.warning("External command was received for the host '%s', " "but the host could not be found! Command is: %s", host_name, command) else: logger.warning("External command was received for host '%s', " "but the host could not be found!", host_name)
[ "Try to dispatch a command for a specific host (so specific scheduler)\n because this command is related to a host (change notification interval for example)\n\n :param host_name: host name to search\n :type host_name: str\n :param command: command line\n :type command: str\n :param extcmd: external command object (the object will be added to sched commands list)\n :type extcmd: alignak.external_command.ExternalCommand\n :return: None\n " ]
Please provide a description of the function:def get_unknown_check_result_brok(cmd_line): match = re.match( r'^\[([0-9]{10})] PROCESS_(SERVICE)_CHECK_RESULT;' r'([^\;]*);([^\;]*);([^\;]*);([^\|]*)(?:\|(.*))?', cmd_line) if not match: match = re.match( r'^\[([0-9]{10})] PROCESS_(HOST)_CHECK_RESULT;' r'([^\;]*);([^\;]*);([^\|]*)(?:\|(.*))?', cmd_line) if not match: return None data = { 'time_stamp': int(match.group(1)), 'host_name': match.group(3), } if match.group(2) == 'SERVICE': data['service_description'] = match.group(4) data['return_code'] = match.group(5) data['output'] = match.group(6) data['perf_data'] = match.group(7) else: data['return_code'] = match.group(4) data['output'] = match.group(5) data['perf_data'] = match.group(6) return Brok({'type': 'unknown_%s_check_result' % match.group(2).lower(), 'data': data})
[ "Create unknown check result brok and fill it with command data\n\n :param cmd_line: command line to extract data\n :type cmd_line: str\n :return: unknown check result brok\n :rtype: alignak.objects.brok.Brok\n " ]
Please provide a description of the function:def get_command_and_args(self, command, extcmd=None): # pylint: disable=too-many-return-statements, too-many-nested-blocks # pylint: disable=too-many-locals,too-many-branches,too-many-statements # danger!!! passive check results with perfdata elts = split_semicolon(command) try: timestamp, c_name = elts[0].split() except ValueError as exp: splitted_command = elts[0].split() if len(splitted_command) == 1: # Assume no timestamp and only a command timestamp = "[%s]" % int(time.time()) logger.warning("Missing timestamp in command '%s', using %s as a timestamp.", elts[0], timestamp) c_name = elts[0].split()[0] else: logger.warning("Malformed command '%s'", command) # logger.exception("Malformed command exception: %s", exp) if self.log_external_commands: # The command failed, make a monitoring log to inform self.send_an_element(make_monitoring_log( 'error', "Malformed command: '%s'" % command)) return None c_name = c_name.lower() # Is timestamp already an integer value? try: timestamp = int(timestamp) except ValueError as exp: # Else, remove enclosing characters: [], (), {}, ... timestamp = timestamp[1:-1] # Finally, check that the timestamp is really a timestamp try: self.current_timestamp = int(timestamp) except ValueError as exp: logger.warning("Malformed command '%s'", command) # logger.exception("Malformed command exception: %s", exp) if self.log_external_commands: # The command failed, make a monitoring log to inform self.send_an_element(make_monitoring_log( 'error', "Malformed command: '%s'" % command)) return None if c_name not in ExternalCommandManager.commands: logger.warning("External command '%s' is not recognized, sorry", c_name) if self.log_external_commands: # The command failed, make a monitoring log to inform self.send_an_element(make_monitoring_log( 'error', "Command '%s' is not recognized, sorry" % command)) return None # Split again based on the number of args we expect. We cannot split # on every ; because this character may appear in the perfdata of # passive check results. entry = ExternalCommandManager.commands[c_name] # Look if the command is purely internal (Alignak) or not internal = False if 'internal' in entry and entry['internal']: internal = True numargs = len(entry['args']) if numargs and 'service' in entry['args']: numargs += 1 elts = split_semicolon(command, numargs) logger.debug("mode= %s, global= %s", self.mode, str(entry['global'])) if self.mode in ['dispatcher', 'receiver'] and entry['global']: if not internal: logger.debug("Command '%s' is a global one, we resent it to all schedulers", c_name) return {'global': True, 'cmd': command} args = [] i = 1 in_service = False tmp_host = '' obsolete_arg = 0 try: for elt in elts[1:]: try: elt = elt.decode('utf8', 'ignore') except AttributeError: # Python 3 will raise an error... pass except UnicodeEncodeError: pass logger.debug("Searching for a new arg: %s (%d)", elt, i) val = elt.strip() if val.endswith('\n'): val = val[:-1] logger.debug("For command arg: %s", val) if not in_service: type_searched = entry['args'][i - 1] logger.debug("Type searched: %s", type_searched) if type_searched == 'host': if self.mode == 'dispatcher' or self.mode == 'receiver': self.search_host_and_dispatch(val, command, extcmd) return None host = self.hosts.find_by_name(val) if host is None: if self.accept_passive_unknown_check_results: brok = self.get_unknown_check_result_brok(command) if brok: self.daemon.add_brok(brok) else: logger.warning("A command was received for the host '%s', " "but the host could not be found!", val) return None args.append(host) elif type_searched == 'contact': contact = self.contacts.find_by_name(val) if contact is not None: args.append(contact) elif type_searched == 'time_period': timeperiod = self.timeperiods.find_by_name(val) if timeperiod is not None: args.append(timeperiod) elif type_searched == 'obsolete': obsolete_arg += 1 elif type_searched == 'to_bool': args.append(to_bool(val)) elif type_searched == 'to_int': args.append(to_int(val)) elif type_searched in ('author', None): args.append(val) elif type_searched == 'command': command = self.commands.find_by_name(val) if command is not None: # the find will be redone by # the commandCall creation, but != None # is useful so a bad command will be caught args.append(val) elif type_searched == 'host_group': hostgroup = self.hostgroups.find_by_name(val) if hostgroup is not None: args.append(hostgroup) elif type_searched == 'service_group': servicegroup = self.servicegroups.find_by_name(val) if servicegroup is not None: args.append(servicegroup) elif type_searched == 'contact_group': contactgroup = self.contactgroups.find_by_name(val) if contactgroup is not None: args.append(contactgroup) # special case: service are TWO args host;service, so one more loop # to get the two parts elif type_searched == 'service': in_service = True tmp_host = elt.strip() if tmp_host[-1] == '\n': tmp_host = tmp_host[:-1] if self.mode == 'dispatcher': self.search_host_and_dispatch(tmp_host, command, extcmd) return None i += 1 else: in_service = False srv_name = elt if srv_name[-1] == '\n': srv_name = srv_name[:-1] # If we are in a receiver, bailout now. if self.mode == 'receiver': self.search_host_and_dispatch(tmp_host, command, extcmd) return None serv = self.services.find_srv_by_name_and_hostname(tmp_host, srv_name) if serv is None: if self.accept_passive_unknown_check_results: brok = self.get_unknown_check_result_brok(command) self.send_an_element(brok) else: logger.warning("A command was received for the service '%s' on " "host '%s', but the service could not be found!", srv_name, tmp_host) return None args.append(serv) logger.debug("Got args: %s", args) except IndexError as exp: logger.warning("Sorry, the arguments for the command '%s' are not correct") logger.exception("Arguments parsing exception: %s", exp) if self.log_external_commands: # The command failed, make a monitoring log to inform self.send_an_element(make_monitoring_log( 'error', "Arguments are not correct for the command: '%s'" % command)) else: if len(args) == (len(entry['args']) - obsolete_arg): return { 'global': False, 'internal': internal, 'c_name': c_name, 'args': args } logger.warning("Sorry, the arguments for the command '%s' are not correct (%s)", command, (args)) if self.log_external_commands: # The command failed, make a monitoring log to inform self.send_an_element(make_monitoring_log( 'error', "Arguments are not correct for the command: '%s'" % command)) return None
[ "Parse command and get args\n\n :param command: command line to parse\n :type command: str\n :param extcmd: external command object (used to dispatch)\n :type extcmd: None | object\n :return: Dict containing command and arg ::\n\n {'global': False, 'c_name': c_name, 'args': args}\n\n :rtype: dict | None\n " ]
Please provide a description of the function:def change_contact_host_notification_timeperiod(self, contact, notification_timeperiod): # todo: deprecate this contact.modified_host_attributes |= DICT_MODATTR["MODATTR_NOTIFICATION_TIMEPERIOD"].value contact.host_notification_period = notification_timeperiod self.send_an_element(contact.get_update_status_brok())
[ "Change contact host notification timeperiod value\n Format of the line that triggers function call::\n\n CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>\n\n :param contact: contact to edit\n :type contact: alignak.objects.contact.Contact\n :param notification_timeperiod: timeperiod to set\n :type notification_timeperiod: alignak.objects.timeperiod.Timeperiod\n :return: None\n " ]
Please provide a description of the function:def add_svc_comment(self, service, author, comment): data = { 'author': author, 'comment': comment, 'comment_type': 2, 'entry_type': 1, 'source': 1, 'expires': False, 'ref': service.uuid } comm = Comment(data) service.add_comment(comm) self.send_an_element(service.get_update_status_brok()) try: brok = make_monitoring_log('info', "SERVICE COMMENT: %s;%s;%s;%s" % (self.hosts[service.host].get_name(), service.get_name(), str(author, 'utf-8'), str(comment, 'utf-8'))) except TypeError: brok = make_monitoring_log('info', "SERVICE COMMENT: %s;%s;%s;%s" % (self.hosts[service.host].get_name(), service.get_name(), author, comment)) self.send_an_element(brok) self.send_an_element(comm.get_comment_brok( self.hosts[service.host].get_name(), service.get_name()))
[ "Add a service comment\n Format of the line that triggers function call::\n\n ADD_SVC_COMMENT;<host_name>;<service_description>;<persistent:obsolete>;<author>;<comment>\n\n :param service: service to add the comment\n :type service: alignak.objects.service.Service\n :param author: author name\n :type author: str\n :param comment: text comment\n :type comment: str\n :return: None\n " ]
Please provide a description of the function:def add_host_comment(self, host, author, comment): data = { 'author': author, 'comment': comment, 'comment_type': 1, 'entry_type': 1, 'source': 1, 'expires': False, 'ref': host.uuid } comm = Comment(data) host.add_comment(comm) self.send_an_element(host.get_update_status_brok()) try: brok = make_monitoring_log('info', "HOST COMMENT: %s;%s;%s" % (host.get_name(), str(author, 'utf-8'), str(comment, 'utf-8'))) except TypeError: brok = make_monitoring_log('info', "HOST COMMENT: %s;%s;%s" % (host.get_name(), author, comment)) self.send_an_element(brok) self.send_an_element(comm.get_comment_brok(self.hosts[host].get_name()))
[ "Add a host comment\n Format of the line that triggers function call::\n\n ADD_HOST_COMMENT;<host_name>;<persistent:obsolete>;<author>;<comment>\n\n :param host: host to add the comment\n :type host: alignak.objects.host.Host\n :param author: author name\n :type author: str\n :param comment: text comment\n :type comment: str\n :return: None\n " ]
Please provide a description of the function:def acknowledge_svc_problem(self, service, sticky, notify, author, comment): notification_period = None if getattr(service, 'notification_period', None) is not None: notification_period = self.daemon.timeperiods[service.notification_period] service.acknowledge_problem(notification_period, self.hosts, self.services, sticky, notify, author, comment)
[ "Acknowledge a service problem\n Format of the line that triggers function call::\n\n ACKNOWLEDGE_SVC_PROBLEM;<host_name>;<service_description>;<sticky>;<notify>;\n <persistent:obsolete>;<author>;<comment>\n\n :param service: service to acknowledge the problem\n :type service: alignak.objects.service.Service\n :param sticky: if sticky == 2, the acknowledge will remain until the service returns to an\n OK state else the acknowledge will be removed as soon as the service state changes\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: str\n :param comment: comment (description) of the acknowledge\n :type comment: str\n :return: None\n " ]
Please provide a description of the function:def acknowledge_host_problem(self, host, sticky, notify, author, comment): notification_period = None if getattr(host, 'notification_period', None) is not None: notification_period = self.daemon.timeperiods[host.notification_period] host.acknowledge_problem(notification_period, self.hosts, self.services, sticky, notify, author, comment)
[ "Acknowledge a host problem\n Format of the line that triggers function call::\n\n ACKNOWLEDGE_HOST_PROBLEM;<host_name>;<sticky>;<notify>;<persistent:obsolete>;<author>;\n <comment>\n\n :param host: host to acknowledge the problem\n :type host: alignak.objects.host.Host\n :param sticky: if sticky == 2, the acknowledge will remain until the host returns to an\n UP state else the acknowledge will be removed as soon as the host state changes\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: str\n :param comment: comment (description) of the acknowledge\n :type comment: str\n :return: None\n TODO: add a better ACK management\n " ]
Please provide a description of the function:def change_contact_svc_notification_timeperiod(self, contact, notification_timeperiod): contact.modified_service_attributes |= \ DICT_MODATTR["MODATTR_NOTIFICATION_TIMEPERIOD"].value contact.service_notification_period = notification_timeperiod self.send_an_element(contact.get_update_status_brok())
[ "Change contact service notification timeperiod value\n Format of the line that triggers function call::\n\n CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD;<contact_name>;<notification_timeperiod>\n\n :param contact: contact to edit\n :type contact: alignak.objects.contact.Contact\n :param notification_timeperiod: timeperiod to set\n :type notification_timeperiod: alignak.objects.timeperiod.Timeperiod\n :return: None\n " ]
Please provide a description of the function:def change_custom_contact_var(self, contact, varname, varvalue): if varname.upper() in contact.customs: contact.modified_attributes |= DICT_MODATTR["MODATTR_CUSTOM_VARIABLE"].value contact.customs[varname.upper()] = varvalue self.send_an_element(contact.get_update_status_brok())
[ "Change custom contact variable\n Format of the line that triggers function call::\n\n CHANGE_CUSTOM_CONTACT_VAR;<contact_name>;<varname>;<varvalue>\n\n :param contact: contact to edit\n :type contact: alignak.objects.contact.Contact\n :param varname: variable name to change\n :type varname: str\n :param varvalue: variable new value\n :type varvalue: str\n :return: None\n " ]
Please provide a description of the function:def change_custom_host_var(self, host, varname, varvalue): if varname.upper() in host.customs: host.modified_attributes |= DICT_MODATTR["MODATTR_CUSTOM_VARIABLE"].value host.customs[varname.upper()] = varvalue self.send_an_element(host.get_update_status_brok())
[ "Change custom host variable\n Format of the line that triggers function call::\n\n CHANGE_CUSTOM_HOST_VAR;<host_name>;<varname>;<varvalue>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :param varname: variable name to change\n :type varname: str\n :param varvalue: variable new value\n :type varvalue: str\n :return: None\n " ]
Please provide a description of the function:def change_custom_svc_var(self, service, varname, varvalue): if varname.upper() in service.customs: service.modified_attributes |= DICT_MODATTR["MODATTR_CUSTOM_VARIABLE"].value service.customs[varname.upper()] = varvalue self.send_an_element(service.get_update_status_brok())
[ "Change custom service variable\n Format of the line that triggers function call::\n\n CHANGE_CUSTOM_SVC_VAR;<host_name>;<service_description>;<varname>;<varvalue>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :param varname: variable name to change\n :type varvalue: str\n :param varvalue: variable new value\n :type varname: str\n :return: None\n " ]
Please provide a description of the function:def change_host_check_command(self, host, check_command): host.modified_attributes |= DICT_MODATTR["MODATTR_CHECK_COMMAND"].value data = {"commands": self.commands, "call": check_command, "poller_tag": host.poller_tag} host.change_check_command(data) self.send_an_element(host.get_update_status_brok())
[ "Modify host check command\n Format of the line that triggers function call::\n\n CHANGE_HOST_CHECK_COMMAND;<host_name>;<check_command>\n\n :param host: host to modify check command\n :type host: alignak.objects.host.Host\n :param check_command: command line\n :type check_command:\n :return: None\n " ]
Please provide a description of the function:def change_host_check_timeperiod(self, host, timeperiod): host.modified_attributes |= DICT_MODATTR["MODATTR_CHECK_TIMEPERIOD"].value host.check_period = timeperiod self.send_an_element(host.get_update_status_brok())
[ "Modify host check timeperiod\n Format of the line that triggers function call::\n\n CHANGE_HOST_CHECK_TIMEPERIOD;<host_name>;<timeperiod>\n\n :param host: host to modify check timeperiod\n :type host: alignak.objects.host.Host\n :param timeperiod: timeperiod object\n :type timeperiod: alignak.objects.timeperiod.Timeperiod\n :return: None\n " ]
Please provide a description of the function:def change_host_event_handler(self, host, event_handler_command): host.modified_attributes |= DICT_MODATTR["MODATTR_EVENT_HANDLER_COMMAND"].value data = {"commands": self.commands, "call": event_handler_command} host.change_event_handler(data) self.send_an_element(host.get_update_status_brok())
[ "Modify host event handler\n Format of the line that triggers function call::\n\n CHANGE_HOST_EVENT_HANDLER;<host_name>;<event_handler_command>\n\n :param host: host to modify event handler\n :type host: alignak.objects.host.Host\n :param event_handler_command: event handler command line\n :type event_handler_command:\n :return: None\n " ]
Please provide a description of the function:def change_host_snapshot_command(self, host, snapshot_command): host.modified_attributes |= DICT_MODATTR["MODATTR_EVENT_HANDLER_COMMAND"].value data = {"commands": self.commands, "call": snapshot_command} host.change_snapshot_command(data) self.send_an_element(host.get_update_status_brok())
[ "Modify host snapshot command\n Format of the line that triggers function call::\n\n CHANGE_HOST_SNAPSHOT_COMMAND;<host_name>;<event_handler_command>\n\n :param host: host to modify snapshot command\n :type host: alignak.objects.host.Host\n :param snapshot_command: snapshot command command line\n :type snapshot_command:\n :return: None\n " ]
Please provide a description of the function:def change_host_modattr(self, host, value): # todo: deprecate this # We need to change each of the needed attributes. previous_value = host.modified_attributes changes = int(value) # For all boolean and non boolean attributes for modattr in ["MODATTR_NOTIFICATIONS_ENABLED", "MODATTR_ACTIVE_CHECKS_ENABLED", "MODATTR_PASSIVE_CHECKS_ENABLED", "MODATTR_EVENT_HANDLER_ENABLED", "MODATTR_FLAP_DETECTION_ENABLED", "MODATTR_PERFORMANCE_DATA_ENABLED", "MODATTR_FRESHNESS_CHECKS_ENABLED", "MODATTR_EVENT_HANDLER_COMMAND", "MODATTR_CHECK_COMMAND", "MODATTR_NORMAL_CHECK_INTERVAL", "MODATTR_RETRY_CHECK_INTERVAL", "MODATTR_MAX_CHECK_ATTEMPTS", "MODATTR_FRESHNESS_CHECKS_ENABLED", "MODATTR_CHECK_TIMEPERIOD", "MODATTR_CUSTOM_VARIABLE", "MODATTR_NOTIFICATION_TIMEPERIOD"]: if changes & DICT_MODATTR[modattr].value: # Toggle the concerned service attribute setattr(host, DICT_MODATTR[modattr].attribute, not getattr(host, DICT_MODATTR[modattr].attribute)) host.modified_attributes = previous_value ^ changes # And we need to push the information to the scheduler. self.send_an_element(host.get_update_status_brok())
[ "Change host modified attributes\n Format of the line that triggers function call::\n\n CHANGE_HOST_MODATTR;<host_name>;<value>\n\n For boolean attributes, toggles the service attribute state (enable/disable)\n For non boolean attribute, only indicates that the corresponding attribute is to be saved\n in the retention.\n\n Value can be:\n MODATTR_NONE 0\n MODATTR_NOTIFICATIONS_ENABLED 1\n MODATTR_ACTIVE_CHECKS_ENABLED 2\n MODATTR_PASSIVE_CHECKS_ENABLED 4\n MODATTR_EVENT_HANDLER_ENABLED 8\n MODATTR_FLAP_DETECTION_ENABLED 16\n MODATTR_PERFORMANCE_DATA_ENABLED 64\n MODATTR_EVENT_HANDLER_COMMAND 256\n MODATTR_CHECK_COMMAND 512\n MODATTR_NORMAL_CHECK_INTERVAL 1024\n MODATTR_RETRY_CHECK_INTERVAL 2048\n MODATTR_MAX_CHECK_ATTEMPTS 4096\n MODATTR_FRESHNESS_CHECKS_ENABLED 8192\n MODATTR_CHECK_TIMEPERIOD 16384\n MODATTR_CUSTOM_VARIABLE 32768\n MODATTR_NOTIFICATION_TIMEPERIOD 65536\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :param value: new value to set\n :type value: str\n :return: None\n " ]
Please provide a description of the function:def change_max_host_check_attempts(self, host, check_attempts): host.modified_attributes |= DICT_MODATTR["MODATTR_MAX_CHECK_ATTEMPTS"].value host.max_check_attempts = check_attempts if host.state_type == u'HARD' and host.state == u'UP' and host.attempt > 1: host.attempt = host.max_check_attempts self.send_an_element(host.get_update_status_brok())
[ "Modify max host check attempt\n Format of the line that triggers function call::\n\n CHANGE_MAX_HOST_CHECK_ATTEMPTS;<host_name>;<check_attempts>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :param check_attempts: new value to set\n :type check_attempts: int\n :return: None\n " ]
Please provide a description of the function:def change_max_svc_check_attempts(self, service, check_attempts): service.modified_attributes |= DICT_MODATTR["MODATTR_MAX_CHECK_ATTEMPTS"].value service.max_check_attempts = check_attempts if service.state_type == u'HARD' and service.state == u'OK' and service.attempt > 1: service.attempt = service.max_check_attempts self.send_an_element(service.get_update_status_brok())
[ "Modify max service check attempt\n Format of the line that triggers function call::\n\n CHANGE_MAX_SVC_CHECK_ATTEMPTS;<host_name>;<service_description>;<check_attempts>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :param check_attempts: new value to set\n :type check_attempts: int\n :return: None\n " ]
Please provide a description of the function:def change_normal_host_check_interval(self, host, check_interval): host.modified_attributes |= DICT_MODATTR["MODATTR_NORMAL_CHECK_INTERVAL"].value old_interval = host.check_interval host.check_interval = check_interval # If there were no regular checks (interval=0), then schedule # a check immediately. if old_interval == 0 and host.checks_enabled: host.schedule(self.daemon.hosts, self.daemon.services, self.daemon.timeperiods, self.daemon.macromodulations, self.daemon.checkmodulations, self.daemon.checks, force=False, force_time=int(time.time())) self.send_an_element(host.get_update_status_brok())
[ "Modify host check interval\n Format of the line that triggers function call::\n\n CHANGE_NORMAL_HOST_CHECK_INTERVAL;<host_name>;<check_interval>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :param check_interval: new value to set\n :type check_interval:\n :return: None\n " ]
Please provide a description of the function:def change_retry_host_check_interval(self, host, check_interval): host.modified_attributes |= DICT_MODATTR["MODATTR_RETRY_CHECK_INTERVAL"].value host.retry_interval = check_interval self.send_an_element(host.get_update_status_brok())
[ "Modify host retry interval\n Format of the line that triggers function call::\n\n CHANGE_RETRY_HOST_CHECK_INTERVAL;<host_name>;<check_interval>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :param check_interval: new value to set\n :type check_interval:\n :return: None\n " ]
Please provide a description of the function:def change_retry_svc_check_interval(self, service, check_interval): service.modified_attributes |= DICT_MODATTR["MODATTR_RETRY_CHECK_INTERVAL"].value service.retry_interval = check_interval self.send_an_element(service.get_update_status_brok())
[ "Modify service retry interval\n Format of the line that triggers function call::\n\n CHANGE_RETRY_SVC_CHECK_INTERVAL;<host_name>;<service_description>;<check_interval>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :param check_interval: new value to set\n :type check_interval:\n :return: None\n " ]
Please provide a description of the function:def change_svc_check_command(self, service, check_command): service.modified_attributes |= DICT_MODATTR["MODATTR_CHECK_COMMAND"].value data = {"commands": self.commands, "call": check_command, "poller_tag": service.poller_tag} service.change_check_command(data) self.send_an_element(service.get_update_status_brok())
[ "Modify service check command\n Format of the line that triggers function call::\n\n CHANGE_SVC_CHECK_COMMAND;<host_name>;<service_description>;<check_command>\n\n :param service: service to modify check command\n :type service: alignak.objects.service.Service\n :param check_command: command line\n :type check_command:\n :return: None\n " ]
Please provide a description of the function:def change_svc_check_timeperiod(self, service, check_timeperiod): service.modified_attributes |= DICT_MODATTR["MODATTR_CHECK_TIMEPERIOD"].value service.check_period = check_timeperiod self.send_an_element(service.get_update_status_brok())
[ "Modify service check timeperiod\n Format of the line that triggers function call::\n\n CHANGE_SVC_CHECK_TIMEPERIOD;<host_name>;<service_description>;<check_timeperiod>\n\n :param service: service to modify check timeperiod\n :type service: alignak.objects.service.Service\n :param check_timeperiod: timeperiod object\n :type check_timeperiod: alignak.objects.timeperiod.Timeperiod\n :return: None\n " ]
Please provide a description of the function:def change_svc_event_handler(self, service, event_handler_command): service.modified_attributes |= DICT_MODATTR["MODATTR_EVENT_HANDLER_COMMAND"].value data = {"commands": self.commands, "call": event_handler_command} service.change_event_handler(data) self.send_an_element(service.get_update_status_brok())
[ "Modify service event handler\n Format of the line that triggers function call::\n\n CHANGE_SVC_EVENT_HANDLER;<host_name>;<service_description>;<event_handler_command>\n\n :param service: service to modify event handler\n :type service: alignak.objects.service.Service\n :param event_handler_command: event handler command line\n :type event_handler_command:\n :return: None\n " ]
Please provide a description of the function:def change_svc_snapshot_command(self, service, snapshot_command): service.modified_attributes |= DICT_MODATTR["MODATTR_EVENT_HANDLER_COMMAND"].value data = {"commands": self.commands, "call": snapshot_command} service.change_snapshot_command(data) self.send_an_element(service.get_update_status_brok())
[ "Modify host snapshot command\n Format of the line that triggers function call::\n\n CHANGE_HOST_SNAPSHOT_COMMAND;<host_name>;<event_handler_command>\n\n :param service: service to modify snapshot command\n :type service: alignak.objects.service.Service\n :param snapshot_command: snapshot command command line\n :type snapshot_command:\n :return: None\n " ]
Please provide a description of the function:def change_svc_modattr(self, service, value): # todo: deprecate this # We need to change each of the needed attributes. previous_value = service.modified_attributes changes = int(value) # For all boolean and non boolean attributes for modattr in ["MODATTR_NOTIFICATIONS_ENABLED", "MODATTR_ACTIVE_CHECKS_ENABLED", "MODATTR_PASSIVE_CHECKS_ENABLED", "MODATTR_EVENT_HANDLER_ENABLED", "MODATTR_FLAP_DETECTION_ENABLED", "MODATTR_PERFORMANCE_DATA_ENABLED", "MODATTR_FRESHNESS_CHECKS_ENABLED", "MODATTR_EVENT_HANDLER_COMMAND", "MODATTR_CHECK_COMMAND", "MODATTR_NORMAL_CHECK_INTERVAL", "MODATTR_RETRY_CHECK_INTERVAL", "MODATTR_MAX_CHECK_ATTEMPTS", "MODATTR_FRESHNESS_CHECKS_ENABLED", "MODATTR_CHECK_TIMEPERIOD", "MODATTR_CUSTOM_VARIABLE", "MODATTR_NOTIFICATION_TIMEPERIOD"]: if changes & DICT_MODATTR[modattr].value: # Toggle the concerned service attribute setattr(service, DICT_MODATTR[modattr].attribute, not getattr(service, DICT_MODATTR[modattr].attribute)) service.modified_attributes = previous_value ^ changes # And we need to push the information to the scheduler. self.send_an_element(service.get_update_status_brok())
[ "Change service modified attributes\n Format of the line that triggers function call::\n\n CHANGE_SVC_MODATTR;<host_name>;<service_description>;<value>\n\n For boolean attributes, toggles the service attribute state (enable/disable)\n For non boolean attribute, only indicates that the corresponding attribute is to be saved\n in the retention.\n\n Value can be:\n MODATTR_NONE 0\n MODATTR_NOTIFICATIONS_ENABLED 1\n MODATTR_ACTIVE_CHECKS_ENABLED 2\n MODATTR_PASSIVE_CHECKS_ENABLED 4\n MODATTR_EVENT_HANDLER_ENABLED 8\n MODATTR_FLAP_DETECTION_ENABLED 16\n MODATTR_PERFORMANCE_DATA_ENABLED 64\n MODATTR_EVENT_HANDLER_COMMAND 256\n MODATTR_CHECK_COMMAND 512\n MODATTR_NORMAL_CHECK_INTERVAL 1024\n MODATTR_RETRY_CHECK_INTERVAL 2048\n MODATTR_MAX_CHECK_ATTEMPTS 4096\n MODATTR_FRESHNESS_CHECKS_ENABLED 8192\n MODATTR_CHECK_TIMEPERIOD 16384\n MODATTR_CUSTOM_VARIABLE 32768\n MODATTR_NOTIFICATION_TIMEPERIOD 65536\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :param value: new value to set / unset\n :type value: str\n :return: None\n " ]
Please provide a description of the function:def change_svc_notification_timeperiod(self, service, notification_timeperiod): service.modified_attributes |= DICT_MODATTR["MODATTR_NOTIFICATION_TIMEPERIOD"].value service.notification_period = notification_timeperiod self.send_an_element(service.get_update_status_brok())
[ "Change service notification timeperiod\n Format of the line that triggers function call::\n\n CHANGE_SVC_NOTIFICATION_TIMEPERIOD;<host_name>;<service_description>;\n <notification_timeperiod>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :param notification_timeperiod: timeperiod to set\n :type notification_timeperiod: alignak.objects.timeperiod.Timeperiod\n :return: None\n " ]
Please provide a description of the function:def delay_host_notification(self, host, notification_time): host.first_notification_delay = notification_time self.send_an_element(host.get_update_status_brok())
[ "Modify host first notification delay\n Format of the line that triggers function call::\n\n DELAY_HOST_NOTIFICATION;<host_name>;<notification_time>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :param notification_time: new value to set\n :type notification_time:\n :return: None\n " ]
Please provide a description of the function:def delay_svc_notification(self, service, notification_time): service.first_notification_delay = notification_time self.send_an_element(service.get_update_status_brok())
[ "Modify service first notification delay\n Format of the line that triggers function call::\n\n DELAY_SVC_NOTIFICATION;<host_name>;<service_description>;<notification_time>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :param notification_time: new value to set\n :type notification_time:\n :return: None\n " ]
Please provide a description of the function:def del_all_host_comments(self, host): comments = list(host.comments.keys()) for uuid in comments: host.del_comment(uuid) self.send_an_element(host.get_update_status_brok())
[ "Delete all host comments\n Format of the line that triggers function call::\n\n DEL_ALL_HOST_COMMENTS;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def del_all_host_downtimes(self, host): for downtime in host.downtimes: self.del_host_downtime(downtime) self.send_an_element(host.get_update_status_brok())
[ "Delete all host downtimes\n Format of the line that triggers function call::\n\n DEL_ALL_HOST_DOWNTIMES;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def del_all_svc_comments(self, service): comments = list(service.comments.keys()) for uuid in comments: service.del_comment(uuid) self.send_an_element(service.get_update_status_brok())
[ "Delete all service comments\n Format of the line that triggers function call::\n\n DEL_ALL_SVC_COMMENTS;<host_name>;<service_description>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :return: None\n " ]
Please provide a description of the function:def del_all_svc_downtimes(self, service): for downtime in service.downtimes: self.del_svc_downtime(downtime) self.send_an_element(service.get_update_status_brok())
[ "Delete all service downtime\n Format of the line that triggers function call::\n\n DEL_ALL_SVC_DOWNTIMES;<host_name>;<service_description>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :return: None\n " ]
Please provide a description of the function:def del_contact_downtime(self, downtime_id): for item in self.daemon.contacts: if downtime_id in item.downtimes: item.downtimes[downtime_id].cancel(self.daemon.contacts) break else: self.send_an_element(make_monitoring_log( 'warning', 'DEL_CONTACT_DOWNTIME: downtime id: %s does not exist ' 'and cannot be deleted.' % downtime_id))
[ "Delete a contact downtime\n Format of the line that triggers function call::\n\n DEL_CONTACT_DOWNTIME;<downtime_id>\n\n :param downtime_id: downtime id to delete\n :type downtime_id: int\n :return: None\n " ]
Please provide a description of the function:def del_host_comment(self, comment_id): for item in self.daemon.hosts: if comment_id in item.comments: item.del_comment(comment_id) self.send_an_element(item.get_update_status_brok()) break else: self.send_an_element(make_monitoring_log( 'warning', 'DEL_HOST_COMMENT: comment id: %s does not exist ' 'and cannot be deleted.' % comment_id))
[ "Delete a host comment\n Format of the line that triggers function call::\n\n DEL_HOST_COMMENT;<comment_id>\n\n :param comment_id: comment id to delete\n :type comment_id: int\n :return: None\n " ]
Please provide a description of the function:def del_host_downtime(self, downtime_id): broks = [] for item in self.daemon.hosts: if downtime_id in item.downtimes: broks.extend(item.downtimes[downtime_id].cancel(self.daemon.timeperiods, self.daemon.hosts, self.daemon.services)) break else: self.send_an_element(make_monitoring_log( 'warning', 'DEL_HOST_DOWNTIME: downtime id: %s does not exist ' 'and cannot be deleted.' % downtime_id)) for brok in broks: self.send_an_element(brok)
[ "Delete a host downtime\n Format of the line that triggers function call::\n\n DEL_HOST_DOWNTIME;<downtime_id>\n\n :param downtime_id: downtime id to delete\n :type downtime_id: int\n :return: None\n " ]
Please provide a description of the function:def del_svc_comment(self, comment_id): for svc in self.daemon.services: if comment_id in svc.comments: svc.del_comment(comment_id) self.send_an_element(svc.get_update_status_brok()) break else: self.send_an_element(make_monitoring_log( 'warning', 'DEL_SVC_COMMENT: comment id: %s does not exist ' 'and cannot be deleted.' % comment_id))
[ "Delete a service comment\n Format of the line that triggers function call::\n\n DEL_SVC_COMMENT;<comment_id>\n\n :param comment_id: comment id to delete\n :type comment_id: int\n :return: None\n " ]
Please provide a description of the function:def del_svc_downtime(self, downtime_id): broks = [] for svc in self.daemon.services: if downtime_id in svc.downtimes: broks.extend(svc.downtimes[downtime_id].cancel(self.daemon.timeperiods, self.daemon.hosts, self.daemon.services)) break else: self.send_an_element(make_monitoring_log( 'warning', 'DEL_SVC_DOWNTIME: downtime id: %s does not exist ' 'and cannot be deleted.' % downtime_id)) for brok in broks: self.send_an_element(brok)
[ "Delete a service downtime\n Format of the line that triggers function call::\n\n DEL_SVC_DOWNTIME;<downtime_id>\n\n :param downtime_id: downtime id to delete\n :type downtime_id: int\n :return: None\n " ]
Please provide a description of the function:def disable_contactgroup_host_notifications(self, contactgroup): for contact_id in contactgroup.get_contacts(): self.disable_contact_host_notifications(self.daemon.contacts[contact_id])
[ "Disable host notifications for a contactgroup\n Format of the line that triggers function call::\n\n DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>\n\n :param contactgroup: contactgroup to disable\n :type contactgroup: alignak.objects.contactgroup.Contactgroup\n :return: None\n " ]
Please provide a description of the function:def disable_contactgroup_svc_notifications(self, contactgroup): for contact_id in contactgroup.get_contacts(): self.disable_contact_svc_notifications(self.daemon.contacts[contact_id])
[ "Disable service notifications for a contactgroup\n Format of the line that triggers function call::\n\n DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>\n\n :param contactgroup: contactgroup to disable\n :type contactgroup: alignak.objects.contactgroup.Contactgroup\n :return: None\n " ]
Please provide a description of the function:def disable_contact_host_notifications(self, contact): if contact.host_notifications_enabled: contact.modified_attributes |= DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value contact.host_notifications_enabled = False self.send_an_element(contact.get_update_status_brok())
[ "Disable host notifications for a contact\n Format of the line that triggers function call::\n\n DISABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>\n\n :param contact: contact to disable\n :type contact: alignak.objects.contact.Contact\n :return: None\n " ]
Please provide a description of the function:def disable_contact_svc_notifications(self, contact): if contact.service_notifications_enabled: contact.modified_attributes |= DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value contact.service_notifications_enabled = False self.send_an_element(contact.get_update_status_brok())
[ "Disable service notifications for a contact\n Format of the line that triggers function call::\n\n DISABLE_CONTACT_SVC_NOTIFICATIONS;<contact_name>\n\n :param contact: contact to disable\n :type contact: alignak.objects.contact.Contact\n :return: None\n " ]
Please provide a description of the function:def disable_event_handlers(self): # todo: #783 create a dedicated brok for global parameters if self.my_conf.enable_event_handlers: self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_EVENT_HANDLER_ENABLED"].value self.my_conf.enable_event_handlers = False self.my_conf.explode_global_conf() self.daemon.update_program_status()
[ "Disable event handlers (globally)\n Format of the line that triggers function call::\n\n DISABLE_EVENT_HANDLERS\n\n :return: None\n " ]
Please provide a description of the function:def disable_flap_detection(self): # todo: #783 create a dedicated brok for global parameters if self.my_conf.enable_flap_detection: self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_FLAP_DETECTION_ENABLED"].value self.my_conf.enable_flap_detection = False self.my_conf.explode_global_conf() self.daemon.update_program_status() # Is need, disable flap state for hosts and services for service in self.my_conf.services: if service.is_flapping: service.is_flapping = False service.flapping_changes = [] self.send_an_element(service.get_update_status_brok()) for host in self.my_conf.hosts: if host.is_flapping: host.is_flapping = False host.flapping_changes = [] self.send_an_element(host.get_update_status_brok())
[ "Disable flap detection (globally)\n Format of the line that triggers function call::\n\n DISABLE_FLAP_DETECTION\n\n :return: None\n " ]
Please provide a description of the function:def disable_hostgroup_host_checks(self, hostgroup): for host_id in hostgroup.get_hosts(): if host_id in self.daemon.hosts: self.disable_host_check(self.daemon.hosts[host_id])
[ "Disable host checks for a hostgroup\n Format of the line that triggers function call::\n\n DISABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to disable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n " ]
Please provide a description of the function:def disable_hostgroup_host_notifications(self, hostgroup): for host_id in hostgroup.get_hosts(): if host_id in self.daemon.hosts: self.disable_host_notifications(self.daemon.hosts[host_id])
[ "Disable host notifications for a hostgroup\n Format of the line that triggers function call::\n\n DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>\n\n :param hostgroup: hostgroup to disable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n " ]
Please provide a description of the function:def disable_hostgroup_passive_host_checks(self, hostgroup): for host_id in hostgroup.get_hosts(): if host_id in self.daemon.hosts: self.disable_passive_host_checks(self.daemon.hosts[host_id])
[ "Disable host passive checks for a hostgroup\n Format of the line that triggers function call::\n\n DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to disable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n " ]
Please provide a description of the function:def disable_hostgroup_passive_svc_checks(self, hostgroup): for host_id in hostgroup.get_hosts(): if host_id in self.daemon.hosts: for service_id in self.daemon.hosts[host_id].services: if service_id in self.daemon.services: self.disable_passive_svc_checks(self.daemon.services[service_id])
[ "Disable service passive checks for a hostgroup\n Format of the line that triggers function call::\n\n DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to disable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n " ]
Please provide a description of the function:def disable_hostgroup_svc_checks(self, hostgroup): for host_id in hostgroup.get_hosts(): if host_id in self.daemon.hosts: for service_id in self.daemon.hosts[host_id].services: if service_id in self.daemon.services: self.disable_svc_check(self.daemon.services[service_id])
[ "Disable service checks for a hostgroup\n Format of the line that triggers function call::\n\n DISABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to disable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n " ]
Please provide a description of the function:def disable_hostgroup_svc_notifications(self, hostgroup): for host_id in hostgroup.get_hosts(): if host_id in self.daemon.hosts: for service_id in self.daemon.hosts[host_id].services: if service_id in self.daemon.services: self.disable_svc_notifications(self.daemon.services[service_id])
[ "Disable service notifications for a hostgroup\n Format of the line that triggers function call::\n\n DISABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>\n\n :param hostgroup: hostgroup to disable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n " ]
Please provide a description of the function:def disable_host_check(self, host): if host.active_checks_enabled: host.modified_attributes |= DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value host.disable_active_checks(self.daemon.checks) self.send_an_element(host.get_update_status_brok())
[ "Disable checks for a host\n Format of the line that triggers function call::\n\n DISABLE_HOST_CHECK;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_host_event_handler(self, host): if host.event_handler_enabled: host.modified_attributes |= DICT_MODATTR["MODATTR_EVENT_HANDLER_ENABLED"].value host.event_handler_enabled = False self.send_an_element(host.get_update_status_brok())
[ "Disable event handlers for a host\n Format of the line that triggers function call::\n\n DISABLE_HOST_EVENT_HANDLER;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_host_flap_detection(self, host): if host.flap_detection_enabled: host.modified_attributes |= DICT_MODATTR["MODATTR_FLAP_DETECTION_ENABLED"].value host.flap_detection_enabled = False # Maybe the host was flapping, if so, stop flapping if host.is_flapping: host.is_flapping = False host.flapping_changes = [] self.send_an_element(host.get_update_status_brok())
[ "Disable flap detection for a host\n Format of the line that triggers function call::\n\n DISABLE_HOST_FLAP_DETECTION;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_host_freshness_check(self, host): if host.check_freshness: host.modified_attributes |= DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value host.check_freshness = False self.send_an_element(host.get_update_status_brok())
[ "Disable freshness check for a host\n Format of the line that triggers function call::\n\n DISABLE_HOST_FRESHNESS_CHECK;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_host_freshness_checks(self): if self.my_conf.check_host_freshness: self.my_conf.modified_attributes |= \ DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value self.my_conf.check_host_freshness = False self.my_conf.explode_global_conf() self.daemon.update_program_status()
[ "Disable freshness checks (globally)\n Format of the line that triggers function call::\n\n DISABLE_HOST_FRESHNESS_CHECKS\n\n :return: None\n " ]
Please provide a description of the function:def disable_host_notifications(self, host): if host.notifications_enabled: host.modified_attributes |= DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value host.notifications_enabled = False self.send_an_element(host.get_update_status_brok())
[ "Disable notifications for a host\n Format of the line that triggers function call::\n\n DISABLE_HOST_NOTIFICATIONS;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_host_svc_checks(self, host): for service_id in host.services: if service_id in self.daemon.services: service = self.daemon.services[service_id] self.disable_svc_check(service) self.send_an_element(service.get_update_status_brok())
[ "Disable service checks for a host\n Format of the line that triggers function call::\n\n DISABLE_HOST_SVC_CHECKS;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_host_svc_notifications(self, host): for service_id in host.services: if service_id in self.daemon.services: service = self.daemon.services[service_id] self.disable_svc_notifications(service) self.send_an_element(service.get_update_status_brok())
[ "Disable services notifications for a host\n Format of the line that triggers function call::\n\n DISABLE_HOST_SVC_NOTIFICATIONS;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_notifications(self): # todo: #783 create a dedicated brok for global parameters if self.my_conf.enable_notifications: self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value self.my_conf.enable_notifications = False self.my_conf.explode_global_conf() self.daemon.update_program_status()
[ "Disable notifications (globally)\n Format of the line that triggers function call::\n\n DISABLE_NOTIFICATIONS\n\n :return: None\n " ]
Please provide a description of the function:def disable_passive_host_checks(self, host): if host.passive_checks_enabled: host.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value host.passive_checks_enabled = False self.send_an_element(host.get_update_status_brok())
[ "Disable passive checks for a host\n Format of the line that triggers function call::\n\n DISABLE_PASSIVE_HOST_CHECKS;<host_name>\n\n :param host: host to edit\n :type host: alignak.objects.host.Host\n :return: None\n " ]
Please provide a description of the function:def disable_passive_svc_checks(self, service): if service.passive_checks_enabled: service.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value service.passive_checks_enabled = False self.send_an_element(service.get_update_status_brok())
[ "Disable passive checks for a service\n Format of the line that triggers function call::\n\n DISABLE_PASSIVE_SVC_CHECKS;<host_name>;<service_description>\n\n :param service: service to edit\n :type service: alignak.objects.service.Service\n :return: None\n " ]
Please provide a description of the function:def disable_performance_data(self): # todo: #783 create a dedicated brok for global parameters if self.my_conf.process_performance_data: self.my_conf.modified_attributes |= \ DICT_MODATTR["MODATTR_PERFORMANCE_DATA_ENABLED"].value self.my_conf.process_performance_data = False self.my_conf.explode_global_conf() self.daemon.update_program_status()
[ "Disable performance data processing (globally)\n Format of the line that triggers function call::\n\n DISABLE_PERFORMANCE_DATA\n\n :return: None\n " ]
Please provide a description of the function:def disable_servicegroup_host_checks(self, servicegroup): for service_id in servicegroup.get_services(): if service_id in self.daemon.services: host_id = self.daemon.services[service_id].host self.disable_host_check(self.daemon.hosts[host_id])
[ "Disable host checks for a servicegroup\n Format of the line that triggers function call::\n\n DISABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>\n\n :param servicegroup: servicegroup to disable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n " ]
Please provide a description of the function:def disable_servicegroup_host_notifications(self, servicegroup): for service_id in servicegroup.get_services(): if service_id in self.daemon.services: host_id = self.daemon.services[service_id].host self.disable_host_notifications(self.daemon.hosts[host_id])
[ "Disable host notifications for a servicegroup\n Format of the line that triggers function call::\n\n DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>\n\n :param servicegroup: servicegroup to disable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n " ]