Code
stringlengths 103
85.9k
| Summary
sequencelengths 0
94
|
---|---|
Please provide a description of the function:def disable_servicegroup_passive_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_passive_host_checks(self.daemon.hosts[host_id]) | [
"Disable passive host checks for a servicegroup\n Format of the line that triggers function call::\n\n DISABLE_SERVICEGROUP_PASSIVE_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_passive_svc_checks(self, servicegroup):
for service_id in servicegroup.get_services():
self.disable_passive_svc_checks(self.daemon.services[service_id]) | [
"Disable passive service checks for a servicegroup\n Format of the line that triggers function call::\n\n DISABLE_SERVICEGROUP_PASSIVE_SVC_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_svc_checks(self, servicegroup):
for service_id in servicegroup.get_services():
self.disable_svc_check(self.daemon.services[service_id]) | [
"Disable service checks for a servicegroup\n Format of the line that triggers function call::\n\n DISABLE_SERVICEGROUP_SVC_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_svc_notifications(self, servicegroup):
for service_id in servicegroup.get_services():
self.disable_svc_notifications(self.daemon.services[service_id]) | [
"Disable service notifications for a servicegroup\n Format of the line that triggers function call::\n\n DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<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_service_flap_detection(self, service):
if service.flap_detection_enabled:
service.modified_attributes |= DICT_MODATTR["MODATTR_FLAP_DETECTION_ENABLED"].value
service.flap_detection_enabled = False
# Maybe the service was flapping, if so, stop flapping
if service.is_flapping:
service.is_flapping = False
service.flapping_changes = []
self.send_an_element(service.get_update_status_brok()) | [
"Disable flap detection for a service\n Format of the line that triggers function call::\n\n DISABLE_SERVICE_FLAP_DETECTION;<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_svc_freshness_check(self, service):
if service.check_freshness:
service.modified_attributes |= DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value
service.check_freshness = False
self.send_an_element(service.get_update_status_brok()) | [
"Disable freshness check for a service\n Format of the line that triggers function call::\n\n DISABLE_SERVICE_FRESHNESS_CHECK;<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_service_freshness_checks(self):
if self.my_conf.check_service_freshness:
self.my_conf.modified_attributes |= \
DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value
self.my_conf.check_service_freshness = False
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Disable service freshness checks (globally)\n Format of the line that triggers function call::\n\n DISABLE_SERVICE_FRESHNESS_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def disable_svc_check(self, service):
if service.active_checks_enabled:
service.disable_active_checks(self.daemon.checks)
service.modified_attributes |= \
DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
self.send_an_element(service.get_update_status_brok()) | [
"Disable checks for a service\n Format of the line that triggers function call::\n\n DISABLE_SVC_CHECK;<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_svc_event_handler(self, service):
if service.event_handler_enabled:
service.modified_attributes |= \
DICT_MODATTR["MODATTR_EVENT_HANDLER_ENABLED"].value
service.event_handler_enabled = False
self.send_an_element(service.get_update_status_brok()) | [
"Disable event handlers for a service\n Format of the line that triggers function call::\n\n DISABLE_SVC_EVENT_HANDLER;<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_svc_notifications(self, service):
if service.notifications_enabled:
service.modified_attributes |= \
DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value
service.notifications_enabled = False
self.send_an_element(service.get_update_status_brok()) | [
"Disable notifications for a service\n Format of the line that triggers function call::\n\n DISABLE_SVC_NOTIFICATIONS;<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 enable_contactgroup_host_notifications(self, contactgroup):
for contact_id in contactgroup.get_contacts():
self.enable_contact_host_notifications(self.daemon.contacts[contact_id]) | [
"Enable host notifications for a contactgroup\n Format of the line that triggers function call::\n\n ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS;<contactgroup_name>\n\n :param contactgroup: contactgroup to enable\n :type contactgroup: alignak.objects.contactgroup.Contactgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_contactgroup_svc_notifications(self, contactgroup):
for contact_id in contactgroup.get_contacts():
self.enable_contact_svc_notifications(self.daemon.contacts[contact_id]) | [
"Enable service notifications for a contactgroup\n Format of the line that triggers function call::\n\n ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS;<contactgroup_name>\n\n :param contactgroup: contactgroup to enable\n :type contactgroup: alignak.objects.contactgroup.Contactgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_contact_host_notifications(self, contact):
if not contact.host_notifications_enabled:
contact.modified_attributes |= \
DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value
contact.host_notifications_enabled = True
self.send_an_element(contact.get_update_status_brok()) | [
"Enable host notifications for a contact\n Format of the line that triggers function call::\n\n ENABLE_CONTACT_HOST_NOTIFICATIONS;<contact_name>\n\n :param contact: contact to enable\n :type contact: alignak.objects.contact.Contact\n :return: None\n "
] |
Please provide a description of the function:def enable_contact_svc_notifications(self, contact):
if not contact.service_notifications_enabled:
contact.modified_attributes |= \
DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value
contact.service_notifications_enabled = True
self.send_an_element(contact.get_update_status_brok()) | [
"Enable 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 enable\n :type contact: alignak.objects.contact.Contact\n :return: None\n "
] |
Please provide a description of the function:def enable_hostgroup_host_checks(self, hostgroup):
for host_id in hostgroup.get_hosts():
if host_id in self.daemon.hosts:
self.enable_host_check(self.daemon.hosts[host_id]) | [
"Enable host checks for a hostgroup\n Format of the line that triggers function call::\n\n ENABLE_HOSTGROUP_HOST_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to enable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_hostgroup_host_notifications(self, hostgroup):
for host_id in hostgroup.get_hosts():
if host_id in self.daemon.hosts:
self.enable_host_notifications(self.daemon.hosts[host_id]) | [
"Enable host notifications for a hostgroup\n Format of the line that triggers function call::\n\n ENABLE_HOSTGROUP_HOST_NOTIFICATIONS;<hostgroup_name>\n\n :param hostgroup: hostgroup to enable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_hostgroup_passive_host_checks(self, hostgroup):
for host_id in hostgroup.get_hosts():
if host_id in self.daemon.hosts:
self.enable_passive_host_checks(self.daemon.hosts[host_id]) | [
"Enable host passive checks for a hostgroup\n Format of the line that triggers function call::\n\n ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to enable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_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.enable_passive_svc_checks(self.daemon.services[service_id]) | [
"Enable service passive checks for a hostgroup\n Format of the line that triggers function call::\n\n ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to enable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_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.enable_svc_check(self.daemon.services[service_id]) | [
"Enable service checks for a hostgroup\n Format of the line that triggers function call::\n\n ENABLE_HOSTGROUP_SVC_CHECKS;<hostgroup_name>\n\n :param hostgroup: hostgroup to enable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_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.enable_svc_notifications(self.daemon.services[service_id]) | [
"Enable service notifications for a hostgroup\n Format of the line that triggers function call::\n\n ENABLE_HOSTGROUP_SVC_NOTIFICATIONS;<hostgroup_name>\n\n :param hostgroup: hostgroup to enable\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :return: None\n "
] |
Please provide a description of the function:def enable_host_check(self, host):
if not host.active_checks_enabled:
host.active_checks_enabled = True
host.modified_attributes |= \
DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
self.send_an_element(host.get_update_status_brok()) | [
"Enable checks for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_host_event_handler(self, host):
if not host.event_handler_enabled:
host.modified_attributes |= \
DICT_MODATTR["MODATTR_EVENT_HANDLER_ENABLED"].value
host.event_handler_enabled = True
self.send_an_element(host.get_update_status_brok()) | [
"Enable event handlers for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_host_flap_detection(self, host):
if not host.flap_detection_enabled:
host.modified_attributes |= \
DICT_MODATTR["MODATTR_FLAP_DETECTION_ENABLED"].value
host.flap_detection_enabled = True
self.send_an_element(host.get_update_status_brok()) | [
"Enable flap detection for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_host_freshness_check(self, host):
if not host.check_freshness:
host.modified_attributes |= DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value
host.check_freshness = True
self.send_an_element(host.get_update_status_brok()) | [
"Enable freshness check for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_host_freshness_checks(self):
if not self.my_conf.check_host_freshness:
self.my_conf.modified_attributes |= \
DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value
self.my_conf.check_host_freshness = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable freshness checks (globally)\n Format of the line that triggers function call::\n\n ENABLE_HOST_FRESHNESS_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def enable_host_notifications(self, host):
if not host.notifications_enabled:
host.modified_attributes |= \
DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value
host.notifications_enabled = True
self.send_an_element(host.get_update_status_brok()) | [
"Enable notifications for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_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.enable_svc_check(service)
self.send_an_element(service.get_update_status_brok()) | [
"Enable service checks for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_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.enable_svc_notifications(service)
self.send_an_element(service.get_update_status_brok()) | [
"Enable services notifications for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_notifications(self):
# todo: #783 create a dedicated brok for global parameters
if not self.my_conf.enable_notifications:
self.my_conf.modified_attributes |= \
DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value
self.my_conf.enable_notifications = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable notifications (globally)\n Format of the line that triggers function call::\n\n ENABLE_NOTIFICATIONS\n\n :return: None\n "
] |
Please provide a description of the function:def enable_passive_host_checks(self, host):
if not host.passive_checks_enabled:
host.modified_attributes |= \
DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
host.passive_checks_enabled = True
self.send_an_element(host.get_update_status_brok()) | [
"Enable passive checks for a host\n Format of the line that triggers function call::\n\n ENABLE_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 enable_passive_svc_checks(self, service):
if not service.passive_checks_enabled:
service.modified_attributes |= \
DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
service.passive_checks_enabled = True
self.send_an_element(service.get_update_status_brok()) | [
"Enable passive checks for a service\n Format of the line that triggers function call::\n\n ENABLE_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 enable_performance_data(self):
if not self.my_conf.process_performance_data:
self.my_conf.modified_attributes |= \
DICT_MODATTR["MODATTR_PERFORMANCE_DATA_ENABLED"].value
self.my_conf.process_performance_data = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable performance data processing (globally)\n Format of the line that triggers function call::\n\n ENABLE_PERFORMANCE_DATA\n\n :return: None\n "
] |
Please provide a description of the function:def enable_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.enable_host_check(self.daemon.hosts[host_id]) | [
"Enable host checks for a servicegroup\n Format of the line that triggers function call::\n\n ENABLE_SERVICEGROUP_HOST_CHECKS;<servicegroup_name>\n\n :param servicegroup: servicegroup to enable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n "
] |
Please provide a description of the function:def enable_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.enable_host_notifications(self.daemon.hosts[host_id]) | [
"Enable host notifications for a servicegroup\n Format of the line that triggers function call::\n\n ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS;<servicegroup_name>\n\n :param servicegroup: servicegroup to enable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n "
] |
Please provide a description of the function:def enable_servicegroup_passive_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.enable_passive_host_checks(self.daemon.hosts[host_id]) | [
"Enable passive host checks for a servicegroup\n Format of the line that triggers function call::\n\n ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS;<servicegroup_name>\n\n :param servicegroup: servicegroup to enable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n "
] |
Please provide a description of the function:def enable_servicegroup_passive_svc_checks(self, servicegroup):
for service_id in servicegroup.get_services():
self.enable_passive_svc_checks(self.daemon.services[service_id]) | [
"Enable passive service checks for a servicegroup\n Format of the line that triggers function call::\n\n ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS;<servicegroup_name>\n\n :param servicegroup: servicegroup to enable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n "
] |
Please provide a description of the function:def enable_servicegroup_svc_checks(self, servicegroup):
for service_id in servicegroup.get_services():
self.enable_svc_check(self.daemon.services[service_id]) | [
"Enable service checks for a servicegroup\n Format of the line that triggers function call::\n\n ENABLE_SERVICEGROUP_SVC_CHECKS;<servicegroup_name>\n\n :param servicegroup: servicegroup to enable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n "
] |
Please provide a description of the function:def enable_servicegroup_svc_notifications(self, servicegroup):
for service_id in servicegroup.get_services():
self.enable_svc_notifications(self.daemon.services[service_id]) | [
"Enable service notifications for a servicegroup\n Format of the line that triggers function call::\n\n ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS;<servicegroup_name>\n\n :param servicegroup: servicegroup to enable\n :type servicegroup: alignak.objects.servicegroup.Servicegroup\n :return: None\n "
] |
Please provide a description of the function:def enable_service_freshness_checks(self):
if not self.my_conf.check_service_freshness:
self.my_conf.modified_attributes |= \
DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value
self.my_conf.check_service_freshness = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable service freshness checks (globally)\n Format of the line that triggers function call::\n\n ENABLE_SERVICE_FRESHNESS_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def enable_svc_check(self, service):
if not service.active_checks_enabled:
service.modified_attributes |= \
DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
service.active_checks_enabled = True
self.send_an_element(service.get_update_status_brok()) | [
"Enable checks for a service\n Format of the line that triggers function call::\n\n ENABLE_SVC_CHECK;<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 enable_svc_event_handler(self, service):
if not service.event_handler_enabled:
service.modified_attributes |= \
DICT_MODATTR["MODATTR_EVENT_HANDLER_ENABLED"].value
service.event_handler_enabled = True
self.send_an_element(service.get_update_status_brok()) | [
"Enable event handlers for a service\n Format of the line that triggers function call::\n\n ENABLE_SVC_EVENT_HANDLER;<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 enable_svc_freshness_check(self, service):
if not service.check_freshness:
service.modified_attributes |= DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value
service.check_freshness = True
self.send_an_element(service.get_update_status_brok()) | [
"Enable freshness check for a service\n Format of the line that triggers function call::\n\n ENABLE_SERVICE_FRESHNESS_CHECK;<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 enable_svc_flap_detection(self, service):
if not service.flap_detection_enabled:
service.modified_attributes |= \
DICT_MODATTR["MODATTR_FLAP_DETECTION_ENABLED"].value
service.flap_detection_enabled = True
self.send_an_element(service.get_update_status_brok()) | [
"Enable flap detection for a service\n Format of the line that triggers function call::\n\n ENABLE_SVC_FLAP_DETECTION;<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 enable_svc_notifications(self, service):
if not service.notifications_enabled:
service.modified_attributes |= \
DICT_MODATTR["MODATTR_NOTIFICATIONS_ENABLED"].value
service.notifications_enabled = True
self.send_an_element(service.get_update_status_brok()) | [
"Enable notifications for a service\n Format of the line that triggers function call::\n\n ENABLE_SVC_NOTIFICATIONS;<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 process_host_check_result(self, host, status_code, plugin_output):
now = time.time()
cls = host.__class__
# If globally disabled OR host disabled, do not launch..
if not cls.accept_passive_checks or not host.passive_checks_enabled:
return
try:
plugin_output = plugin_output.decode('utf8', 'ignore')
logger.debug('%s > Passive host check plugin output: %s',
host.get_full_name(), plugin_output)
except AttributeError:
# Python 3 will raise an exception
pass
except UnicodeError:
pass
# Maybe the check is just too old, if so, bail out!
if self.current_timestamp < host.last_chk:
logger.debug('%s > Passive host check is too old (%.2f seconds). '
'Ignoring, check output: %s',
host.get_full_name(), self.current_timestamp < host.last_chk,
plugin_output)
return
chk = host.launch_check(now, self.hosts, self.services, self.timeperiods,
self.daemon.macromodulations, self.daemon.checkmodulations,
self.daemon.checks, force=True)
# We will not have a check if an host/service is checked but it has no defined check_command
if not chk:
return
# Now we 'transform the check into a result'
# So exit_status, output and status is eaten by the host
chk.exit_status = status_code
chk.get_outputs(plugin_output, host.max_plugins_output_length)
chk.status = ACT_STATUS_WAIT_CONSUME
chk.check_time = self.current_timestamp # we are using the external command timestamps
# Set the corresponding host's check type to passive
chk.set_type_passive()
# self.daemon.nb_check_received += 1
self.send_an_element(chk)
# Ok now this result will be read by the scheduler the next loop
# raise a passive check log only if needed
if self.my_conf.log_passive_checks:
log_level = 'info'
if status_code == 1: # DOWN
log_level = 'error'
if status_code == 2: # UNREACHABLE
log_level = 'warning'
self.send_an_element(make_monitoring_log(
log_level, 'PASSIVE HOST CHECK: %s;%d;%s;%s;%s' % (
host.get_name(), status_code, chk.output, chk.long_output, chk.perf_data))) | [
"Process host check result\n Format of the line that triggers function call::\n\n PROCESS_HOST_CHECK_RESULT;<host_name>;<status_code>;<plugin_output>\n\n :param host: host to process check to\n :type host: alignak.objects.host.Host\n :param status_code: exit code of plugin\n :type status_code: int\n :param plugin_output: plugin output\n :type plugin_output: str\n :return: None\n TODO: say that check is PASSIVE\n "
] |
Please provide a description of the function:def process_host_output(self, host, plugin_output):
self.process_host_check_result(host, host.state_id, plugin_output) | [
"Process host output\n Format of the line that triggers function call::\n\n PROCESS_HOST_OUTPUT;<host_name>;<plugin_output>\n\n :param host: host to process check to\n :type host: alignak.objects.host.Host\n :param plugin_output: plugin output\n :type plugin_output: str\n :return: None\n "
] |
Please provide a description of the function:def process_service_check_result(self, service, return_code, plugin_output):
now = time.time()
cls = service.__class__
# If globally disabled OR service disabled, do not launch..
if not cls.accept_passive_checks or not service.passive_checks_enabled:
return
try:
plugin_output = plugin_output.decode('utf8', 'ignore')
logger.debug('%s > Passive service check plugin output: %s',
service.get_full_name(), plugin_output)
except AttributeError:
# Python 3 will raise an exception
pass
except UnicodeError:
pass
# Maybe the check is just too old, if so, bail out!
if self.current_timestamp < service.last_chk:
logger.debug('%s > Passive service check is too old (%d seconds). '
'Ignoring, check output: %s',
service.get_full_name(), self.current_timestamp < service.last_chk,
plugin_output)
return
# Create a check object from the external command
chk = service.launch_check(now, self.hosts, self.services, self.timeperiods,
self.daemon.macromodulations, self.daemon.checkmodulations,
self.daemon.checks, force=True)
# Should not be possible to not find the check, but if so, don't crash
if not chk:
logger.error('%s > Passive service check failed. None check launched !?',
service.get_full_name())
return
# Now we 'transform the check into a result'
# So exit_status, output and status is eaten by the service
chk.exit_status = return_code
chk.get_outputs(plugin_output, service.max_plugins_output_length)
logger.debug('%s > Passive service check output: %s',
service.get_full_name(), chk.output)
chk.status = ACT_STATUS_WAIT_CONSUME
chk.check_time = self.current_timestamp # we are using the external command timestamps
# Set the corresponding service's check type to passive
chk.set_type_passive()
# self.daemon.nb_check_received += 1
self.send_an_element(chk)
# Ok now this result will be read by the scheduler the next loop
# raise a passive check log only if needed
if self.my_conf.log_passive_checks:
log_level = 'info'
if return_code == 1: # WARNING
log_level = 'warning'
if return_code == 2: # CRITICAL
log_level = 'error'
self.send_an_element(make_monitoring_log(
log_level, 'PASSIVE SERVICE CHECK: %s;%s;%d;%s;%s;%s' % (
self.hosts[service.host].get_name(), service.get_name(),
return_code, chk.output, chk.long_output, chk.perf_data))) | [
"Process service check result\n Format of the line that triggers function call::\n\n PROCESS_SERVICE_CHECK_RESULT;<host_name>;<service_description>;<return_code>;<plugin_output>\n\n :param service: service to process check to\n :type service: alignak.objects.service.Service\n :param return_code: exit code of plugin\n :type return_code: int\n :param plugin_output: plugin output\n :type plugin_output: str\n :return: None\n "
] |
Please provide a description of the function:def process_service_output(self, service, plugin_output):
self.process_service_check_result(service, service.state_id, plugin_output) | [
"Process service output\n Format of the line that triggers function call::\n\n PROCESS_SERVICE_OUTPUT;<host_name>;<service_description>;<plugin_output>\n\n :param service: service to process check to\n :type service: alignak.objects.service.Service\n :param plugin_output: plugin output\n :type plugin_output: str\n :return: None\n "
] |
Please provide a description of the function:def restart_program(self):
restart_cmd = self.commands.find_by_name('restart-alignak')
if not restart_cmd:
logger.error("Cannot restart Alignak : missing command named"
" 'restart-alignak'. Please add one")
return
restart_cmd_line = restart_cmd.command_line
logger.warning("RESTART command : %s", restart_cmd_line)
# Ok get an event handler command that will run in 15min max
e_handler = EventHandler({'command': restart_cmd_line, 'timeout': 900})
# Ok now run it
e_handler.execute()
# And wait for the command to finish
while e_handler.status not in [ACT_STATUS_DONE, ACT_STATUS_TIMEOUT]:
e_handler.check_finished(64000)
log_level = 'info'
if e_handler.status == ACT_STATUS_TIMEOUT or e_handler.exit_status != 0:
logger.error("Cannot restart Alignak : the 'restart-alignak' command failed with"
" the error code '%d' and the text '%s'.",
e_handler.exit_status, e_handler.output)
log_level = 'error'
# Ok here the command succeed, we can now wait our death
self.send_an_element(make_monitoring_log(log_level, "RESTART: %s" % (e_handler.output))) | [
"Restart Alignak\n Format of the line that triggers function call::\n\n RESTART_PROGRAM\n\n :return: None\n "
] |
Please provide a description of the function:def reload_config(self):
reload_cmd = self.commands.find_by_name('reload-alignak')
if not reload_cmd:
logger.error("Cannot restart Alignak : missing command"
" named 'reload-alignak'. Please add one")
return
logger.warning("RELOAD command : %s", reload_cmd)
reload_cmd_line = reload_cmd.command_line
logger.warning("RELOAD command : %s", reload_cmd_line)
# Ok get an event handler command that will run in 15min max
e_handler = EventHandler({'command': reload_cmd_line, 'timeout': 900})
# Ok now run it
e_handler.execute()
# And wait for the command to finish
while e_handler.status not in [ACT_STATUS_DONE, ACT_STATUS_TIMEOUT]:
e_handler.check_finished(64000)
log_level = 'info'
if e_handler.status == ACT_STATUS_TIMEOUT or e_handler.exit_status != 0:
logger.error("Cannot reload Alignak configuration: the 'reload-alignak' command failed"
" with the error code '%d' and the text '%s'.",
e_handler.exit_status, e_handler.output)
log_level = 'error'
# Ok here the command succeed, we can now wait our death
self.send_an_element(make_monitoring_log(log_level, "RELOAD: %s" % (e_handler.output))) | [
"Reload Alignak configuration\n Format of the line that triggers function call::\n\n RELOAD_CONFIG\n\n :return: None\n "
] |
Please provide a description of the function:def schedule_and_propagate_host_downtime(self, host, start_time, end_time,
fixed, trigger_id, duration, author, comment):
logger.warning("The external command 'SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME' "
"is not currently implemented in Alignak. If you really need it, "
"request for its implementation in the project repository: "
"https://github.com/Alignak-monitoring/alignak")
self.send_an_element(make_monitoring_log(
'warning', 'SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME: this command is not implemented!')) | [
"DOES NOTHING (Should create host downtime and start it?)\n Format of the line that triggers function call::\n\n SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;\n <fixed>;<trigger_id>;<duration>;<author>;<comment>\n\n :return: None\n "
] |
Please provide a description of the function:def schedule_contact_downtime(self, contact, start_time, end_time, author, comment):
data = {'ref': contact.uuid, 'start_time': start_time,
'end_time': end_time, 'author': author, 'comment': comment}
cdt = ContactDowntime(data)
contact.add_downtime(cdt)
self.send_an_element(contact.get_update_status_brok()) | [
"Schedule contact downtime\n Format of the line that triggers function call::\n\n SCHEDULE_CONTACT_DOWNTIME;<contact_name>;<start_time>;<end_time>;<author>;<comment>\n\n :param contact: contact to put in downtime\n :type contact: alignak.objects.contact.Contact\n :param start_time: downtime start time\n :type start_time: int\n :param end_time: downtime end time\n :type end_time: int\n :param author: downtime author\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 schedule_forced_host_check(self, host, check_time):
host.schedule(self.daemon.hosts, self.daemon.services,
self.daemon.timeperiods, self.daemon.macromodulations,
self.daemon.checkmodulations, self.daemon.checks,
force=True, force_time=check_time)
self.send_an_element(host.get_update_status_brok()) | [
"Schedule a forced check on a host\n Format of the line that triggers function call::\n\n SCHEDULE_FORCED_HOST_CHECK;<host_name>;<check_time>\n\n :param host: host to check\n :type host: alignak.object.host.Host\n :param check_time: time to check\n :type check_time: int\n :return: None\n "
] |
Please provide a description of the function:def schedule_forced_host_svc_checks(self, host, check_time):
for service_id in host.services:
service = self.daemon.services[service_id]
self.schedule_forced_svc_check(service, check_time)
self.send_an_element(service.get_update_status_brok()) | [
"Schedule a forced check on all services of a host\n Format of the line that triggers function call::\n\n SCHEDULE_FORCED_HOST_SVC_CHECKS;<host_name>;<check_time>\n\n :param host: host to check\n :type host: alignak.object.host.Host\n :param check_time: time to check\n :type check_time: int\n :return: None\n "
] |
Please provide a description of the function:def schedule_forced_svc_check(self, service, check_time):
service.schedule(self.daemon.hosts, self.daemon.services,
self.daemon.timeperiods, self.daemon.macromodulations,
self.daemon.checkmodulations, self.daemon.checks,
force=True, force_time=check_time)
self.send_an_element(service.get_update_status_brok()) | [
"Schedule a forced check on a service\n Format of the line that triggers function call::\n\n SCHEDULE_FORCED_SVC_CHECK;<host_name>;<service_description>;<check_time>\n\n :param service: service to check\n :type service: alignak.object.service.Service\n :param check_time: time to check\n :type check_time: int\n :return: None\n "
] |
Please provide a description of the function:def schedule_hostgroup_host_downtime(self, hostgroup, start_time, end_time, fixed,
trigger_id, duration, author, comment):
for host_id in hostgroup.get_hosts():
if host_id in self.daemon.hosts:
host = self.daemon.hosts[host_id]
self.schedule_host_downtime(host, start_time, end_time, fixed,
trigger_id, duration, author, comment) | [
"Schedule a downtime for each host of a hostgroup\n Format of the line that triggers function call::\n\n SCHEDULE_HOSTGROUP_HOST_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>;\n <fixed>;<trigger_id>;<duration>;<author>;<comment>\n\n :param hostgroup: hostgroup to schedule\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :param start_time: downtime start time\n :type start_time:\n :param end_time: downtime end time\n :type end_time:\n :param fixed: is downtime fixed\n :type fixed:\n :param trigger_id: downtime id that triggered this one\n :type trigger_id: str\n :param duration: downtime duration\n :type duration: int\n :param author: downtime author\n :type author: str\n :param comment: downtime comment\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def schedule_hostgroup_svc_downtime(self, hostgroup, start_time, end_time, fixed,
trigger_id, duration, author, comment):
for host_id in hostgroup.get_hosts():
if host_id in self.daemon.hosts:
host = self.daemon.hosts[host_id]
for service_id in host.services:
service = self.daemon.services[service_id]
self.schedule_svc_downtime(service, start_time, end_time, fixed,
trigger_id, duration, author, comment) | [
"Schedule a downtime for each service of each host of a hostgroup\n Format of the line that triggers function call::\n\n SCHEDULE_HOSTGROUP_SVC_DOWNTIME;;<hostgroup_name>;<start_time>;<end_time>;<fixed>;\n <trigger_id>;<duration>;<author>;<comment>\n\n :param hostgroup: hostgroup to schedule\n :type hostgroup: alignak.objects.hostgroup.Hostgroup\n :param start_time: downtime start time\n :type start_time:\n :param end_time: downtime end time\n :type end_time:\n :param fixed: is downtime fixed\n :type fixed:\n :param trigger_id: downtime id that triggered this one\n :type trigger_id: str\n :param duration: downtime duration\n :type duration: int\n :param author: downtime author\n :type author: str\n :param comment: downtime comment\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def schedule_host_check(self, host, check_time):
host.schedule(self.daemon.hosts, self.daemon.services,
self.daemon.timeperiods, self.daemon.macromodulations,
self.daemon.checkmodulations, self.daemon.checks,
force=False, force_time=check_time)
self.send_an_element(host.get_update_status_brok()) | [
"Schedule a check on a host\n Format of the line that triggers function call::\n\n SCHEDULE_HOST_CHECK;<host_name>;<check_time>\n\n :param host: host to check\n :type host: alignak.object.host.Host\n :param check_time: time to check\n :type check_time:\n :return: None\n "
] |
Please provide a description of the function:def schedule_host_downtime(self, host, start_time, end_time, fixed,
trigger_id, duration, author, comment):
data = {'ref': host.uuid, 'ref_type': host.my_type, 'start_time': start_time,
'end_time': end_time, 'fixed': fixed, 'trigger_id': trigger_id,
'duration': duration, 'author': author, 'comment': comment}
downtime = Downtime(data)
downtime.add_automatic_comment(host)
host.add_downtime(downtime)
self.send_an_element(host.get_update_status_brok())
if trigger_id not in ('', 0):
for item in self.daemon.hosts:
if trigger_id in item.downtimes:
host.downtimes[trigger_id].trigger_me(downtime.uuid) | [
"Schedule a host downtime\n Format of the line that triggers function call::\n\n SCHEDULE_HOST_DOWNTIME;<host_name>;<start_time>;<end_time>;<fixed>;\n <trigger_id>;<duration>;<author>;<comment>\n\n :param host: host to schedule downtime\n :type host: alignak.object.host.Host\n :param start_time: downtime start time\n :type start_time:\n :param end_time: downtime end time\n :type end_time:\n :param fixed: is downtime fixed\n :type fixed: bool\n :param trigger_id: downtime id that triggered this one\n :type trigger_id: str\n :param duration: downtime duration\n :type duration: int\n :param author: downtime author\n :type author: str\n :param comment: downtime comment\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def schedule_host_svc_checks(self, host, check_time):
for service_id in host.services:
service = self.daemon.services[service_id]
self.schedule_svc_check(service, check_time)
self.send_an_element(service.get_update_status_brok()) | [
"Schedule a check on all services of a host\n Format of the line that triggers function call::\n\n SCHEDULE_HOST_SVC_CHECKS;<host_name>;<check_time>\n\n :param host: host to check\n :type host: alignak.object.host.Host\n :param check_time: time to check\n :type check_time:\n :return: None\n "
] |
Please provide a description of the function:def schedule_host_svc_downtime(self, host, start_time, end_time, fixed,
trigger_id, duration, author, comment):
for serv in host.services:
self.schedule_svc_downtime(serv, start_time, end_time, fixed,
trigger_id, duration, author, comment) | [
"Schedule a service downtime for each service of an host\n Format of the line that triggers function call::\n\n SCHEDULE_HOST_SVC_DOWNTIME;<host_name>;<start_time>;<end_time>;\n <fixed>;<trigger_id>;<duration>;<author>;<comment>\n\n :param host: host to schedule downtime\n :type host: alignak.object.host.Host\n :param start_time: downtime start time\n :type start_time:\n :param end_time: downtime end time\n :type end_time:\n :param fixed: is downtime fixed\n :type fixed: bool\n :param trigger_id: downtime id that triggered this one\n :type trigger_id: str\n :param duration: downtime duration\n :type duration: int\n :param author: downtime author\n :type author: str\n :param comment: downtime comment\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def schedule_servicegroup_host_downtime(self, servicegroup, start_time, end_time,
fixed, trigger_id, duration, author, comment):
for host in [s.host for s in servicegroup.get_services()]:
self.schedule_host_downtime(host, start_time, end_time, fixed,
trigger_id, duration, author, comment) | [
"Schedule a host downtime for each host of services in a servicegroup\n Format of the line that triggers function call::\n\n SCHEDULE_SERVICEGROUP_HOST_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;<fixed>;\n <trigger_id>;<duration>;<author>;<comment>\n\n :param servicegroup: servicegroup to schedule downtime\n :type servicegroup: alignak.object.servicegroup.Servicegroup\n :param start_time: downtime start time\n :type start_time:\n :param end_time: downtime end time\n :type end_time:\n :param fixed: is downtime fixed\n :type fixed: bool\n :param trigger_id: downtime id that triggered this one\n :type trigger_id: str\n :param duration: downtime duration\n :type duration: int\n :param author: downtime author\n :type author: str\n :param comment: downtime comment\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def schedule_servicegroup_svc_downtime(self, servicegroup, start_time, end_time,
fixed, trigger_id, duration, author, comment):
for serv in servicegroup.get_services():
self.schedule_svc_downtime(serv, start_time, end_time, fixed,
trigger_id, duration, author, comment) | [
"Schedule a service downtime for each service of a servicegroup\n Format of the line that triggers function call::\n\n SCHEDULE_SERVICEGROUP_SVC_DOWNTIME;<servicegroup_name>;<start_time>;<end_time>;\n <fixed>;<trigger_id>;<duration>;<author>;<comment>\n\n :param servicegroup: servicegroup to schedule downtime\n :type servicegroup: alignak.object.servicegroup.Servicegroup\n :param start_time: downtime start time\n :type start_time:\n :param end_time: downtime end time\n :type end_time:\n :param fixed: is downtime fixed\n :type fixed: bool\n :param trigger_id: downtime id that triggered this one\n :type trigger_id: str\n :param duration: downtime duration\n :type duration: int\n :param author: downtime author\n :type author: str\n :param comment: downtime comment\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def schedule_svc_check(self, service, check_time):
service.schedule(self.daemon.hosts, self.daemon.services,
self.daemon.timeperiods, self.daemon.macromodulations,
self.daemon.checkmodulations, self.daemon.checks,
force=False, force_time=check_time)
self.send_an_element(service.get_update_status_brok()) | [
"Schedule a check on a service\n Format of the line that triggers function call::\n\n SCHEDULE_SVC_CHECK;<host_name>;<service_description>;<check_time>\n\n :param service: service to check\n :type service: alignak.object.service.Service\n :param check_time: time to check\n :type check_time:\n :return: None\n "
] |
Please provide a description of the function:def schedule_svc_downtime(self, service, start_time, end_time, fixed,
trigger_id, duration, author, comment):
data = {'ref': service.uuid, 'ref_type': service.my_type, 'start_time': start_time,
'end_time': end_time, 'fixed': fixed, 'trigger_id': trigger_id,
'duration': duration, 'author': author, 'comment': comment}
downtime = Downtime(data)
downtime.add_automatic_comment(service)
service.add_downtime(downtime)
self.send_an_element(service.get_update_status_brok())
if trigger_id not in ('', 0):
for item in self.daemon.services:
if trigger_id in item.downtimes:
service.downtimes[trigger_id].trigger_me(downtime.uuid) | [
"Schedule a service downtime\n Format of the line that triggers function call::\n\n SCHEDULE_SVC_DOWNTIME;<host_name>;<service_description><start_time>;<end_time>;\n <fixed>;<trigger_id>;<duration>;<author>;<comment>\n\n :param service: service to check\n :type service: alignak.object.service.Service\n :param start_time: downtime start time\n :type start_time:\n :param end_time: downtime end time\n :type end_time:\n :param fixed: is downtime fixed\n :type fixed: bool\n :param trigger_id: downtime id that triggered this one\n :type trigger_id: int\n :param duration: downtime duration\n :type duration: int\n :param author: downtime author\n :type author: str\n :param comment: downtime comment\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def send_custom_host_notification(self, host, options, author, comment):
logger.warning("The external command 'SEND_CUSTOM_HOST_NOTIFICATION' "
"is not currently implemented in Alignak. If you really need it, "
"request for its implementation in the project repository: "
"https://github.com/Alignak-monitoring/alignak")
self.send_an_element(make_monitoring_log(
'warning', 'SEND_CUSTOM_HOST_NOTIFICATION: this command is not implemented!')) | [
"DOES NOTHING (Should send a custom notification)\n Format of the line that triggers function call::\n\n SEND_CUSTOM_HOST_NOTIFICATION;<host_name>;<options>;<author>;<comment>\n\n :param host: host to send notif for\n :type host: alignak.object.host.Host\n :param options: notification options\n :type options:\n :param author: notification author\n :type author: str\n :param comment: notification text\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def send_custom_svc_notification(self, service, options, author, comment):
logger.warning("The external command 'SEND_CUSTOM_SVC_NOTIFICATION' "
"is not currently implemented in Alignak. If you really need it, "
"request for its implementation in the project repository: "
"https://github.com/Alignak-monitoring/alignak")
self.send_an_element(make_monitoring_log(
'warning', 'SEND_CUSTOM_SVC_NOTIFICATION: this command is not implemented!')) | [
"DOES NOTHING (Should send a custom notification)\n Format of the line that triggers function call::\n\n SEND_CUSTOM_SVC_NOTIFICATION;<host_name>;<service_description>;<options>;<author>;<comment>>\n\n :param service: service to send notif for\n :type service: alignak.object.service.Service\n :param options: notification options\n :type options:\n :param author: notification author\n :type author: str\n :param comment: notification text\n :type comment: str\n :return: None\n "
] |
Please provide a description of the function:def start_accepting_passive_host_checks(self):
# todo: #783 create a dedicated brok for global parameters
if not self.my_conf.accept_passive_host_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
self.my_conf.accept_passive_host_checks = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable passive host check submission (globally)\n Format of the line that triggers function call::\n\n START_ACCEPTING_PASSIVE_HOST_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def start_accepting_passive_svc_checks(self):
# todo: #783 create a dedicated brok for global parameters
if not self.my_conf.accept_passive_service_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
self.my_conf.accept_passive_service_checks = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable passive service check submission (globally)\n Format of the line that triggers function call::\n\n START_ACCEPTING_PASSIVE_SVC_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def start_executing_host_checks(self):
# todo: #783 create a dedicated brok for global parameters
if not self.my_conf.execute_host_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
self.my_conf.execute_host_checks = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable host check execution (globally)\n Format of the line that triggers function call::\n\n START_EXECUTING_HOST_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def start_executing_svc_checks(self):
# todo: #783 create a dedicated brok for global parameters
if not self.my_conf.execute_service_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
self.my_conf.execute_service_checks = True
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Enable service check execution (globally)\n Format of the line that triggers function call::\n\n START_EXECUTING_SVC_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def stop_accepting_passive_host_checks(self):
if self.my_conf.accept_passive_host_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
self.my_conf.accept_passive_host_checks = False
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Disable passive host check submission (globally)\n Format of the line that triggers function call::\n\n STOP_ACCEPTING_PASSIVE_HOST_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def stop_accepting_passive_svc_checks(self):
if self.my_conf.accept_passive_service_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_PASSIVE_CHECKS_ENABLED"].value
self.my_conf.accept_passive_service_checks = False
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Disable passive service check submission (globally)\n Format of the line that triggers function call::\n\n STOP_ACCEPTING_PASSIVE_SVC_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def stop_executing_host_checks(self):
if self.my_conf.execute_host_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
self.my_conf.execute_host_checks = False
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Disable host check execution (globally)\n Format of the line that triggers function call::\n\n STOP_EXECUTING_HOST_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def stop_executing_svc_checks(self):
if self.my_conf.execute_service_checks:
self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
self.my_conf.execute_service_checks = False
self.my_conf.explode_global_conf()
self.daemon.update_program_status() | [
"Disable service check execution (globally)\n Format of the line that triggers function call::\n\n STOP_EXECUTING_SVC_CHECKS\n\n :return: None\n "
] |
Please provide a description of the function:def launch_svc_event_handler(self, service):
service.get_event_handlers(self.hosts, self.daemon.macromodulations,
self.daemon.timeperiods, ext_cmd=True) | [
"Launch event handler for a service\n Format of the line that triggers function call::\n\n LAUNCH_SVC_EVENT_HANDLER;<host_name>;<service_description>\n\n :param service: service to execute the event handler\n :type service: alignak.objects.service.Service\n :return: None\n "
] |
Please provide a description of the function:def launch_host_event_handler(self, host):
host.get_event_handlers(self.hosts, self.daemon.macromodulations, self.daemon.timeperiods,
ext_cmd=True) | [
"Launch event handler for a service\n Format of the line that triggers function call::\n\n LAUNCH_HOST_EVENT_HANDLER;<host_name>\n\n :param host: host to execute the event handler\n :type host: alignak.objects.host.Host\n :return: None\n "
] |
Please provide a description of the function:def get_name(self):
dependent_host_name = 'unknown'
if getattr(self, 'dependent_host_name', None):
dependent_host_name = getattr(
getattr(self, 'dependent_host_name'), 'host_name', 'unknown'
)
host_name = 'unknown'
if getattr(self, 'host_name', None):
host_name = getattr(getattr(self, 'host_name'), 'host_name', 'unknown')
return dependent_host_name + '/' + host_name | [
"Get name based on dependent_host_name and host_name attributes\n Each attribute is substituted by 'unknown' if attribute does not exist\n\n :return: dependent_host_name/host_name\n :rtype: str\n "
] |
Please provide a description of the function:def explode(self, hostgroups):
# pylint: disable=too-many-locals
# The "old" dependencies will be removed. All dependencies with
# more than one host or a host group will be in it
hstdep_to_remove = []
# Then for every host create a copy of the dependency with just the host
# because we are adding services, we can't just loop in it
hostdeps = list(self.items.keys())
for h_id in hostdeps:
hostdep = self.items[h_id]
# We explode first the dependent (son) part
dephnames = []
if hasattr(hostdep, 'dependent_hostgroup_name'):
dephg_names = [n.strip() for n in hostdep.dependent_hostgroup_name.split(',')]
for dephg_name in dephg_names:
dephg = hostgroups.find_by_name(dephg_name)
if dephg is None:
err = "ERROR: the hostdependency got " \
"an unknown dependent_hostgroup_name '%s'" % dephg_name
hostdep.add_error(err)
continue
dephnames.extend([m.strip() for m in dephg.get_hosts()])
if hasattr(hostdep, 'dependent_host_name'):
dephnames.extend([n.strip() for n in hostdep.dependent_host_name.split(',')])
# Ok, and now the father part :)
hnames = []
if hasattr(hostdep, 'hostgroup_name'):
hg_names = [n.strip() for n in hostdep.hostgroup_name.split(',')]
for hg_name in hg_names:
hostgroup = hostgroups.find_by_name(hg_name)
if hostgroup is None:
err = "ERROR: the hostdependency got" \
" an unknown hostgroup_name '%s'" % hg_name
hostdep.add_error(err)
continue
hnames.extend([m.strip() for m in hostgroup.get_hosts()])
if hasattr(hostdep, 'host_name'):
hnames.extend([n.strip() for n in hostdep.host_name.split(',')])
# Loop over all sons and fathers to get S*F host deps
for dephname in dephnames:
dephname = dephname.strip()
for hname in hnames:
new_hd = hostdep.copy()
new_hd.dependent_host_name = dephname
new_hd.host_name = hname
self.add_item(new_hd)
hstdep_to_remove.append(h_id)
self.delete_hostsdep_by_id(hstdep_to_remove) | [
"Explode all host dependency for each member of hostgroups\n Each member of dependent hostgroup or hostgroup in dependency have to get a copy of\n host dependencies (quite complex to parse)\n\n\n :param hostgroups: used to look for hostgroup\n :type hostgroups: alignak.objects.hostgroup.Hostgroups\n :return: None\n "
] |
Please provide a description of the function:def linkify(self, hosts, timeperiods):
self.linkify_hd_by_h(hosts)
self.linkify_hd_by_tp(timeperiods)
self.linkify_h_by_hd(hosts) | [
"Create link between objects::\n\n * hostdependency -> host\n * hostdependency -> timeperiods\n\n :param hosts: hosts to link\n :type hosts: alignak.objects.host.Hosts\n :param timeperiods: timeperiods to link\n :type timeperiods: alignak.objects.timeperiod.Timeperiods\n :return: None\n "
] |
Please provide a description of the function:def linkify_hd_by_h(self, hosts):
for hostdep in self:
try:
h_name = hostdep.host_name
dh_name = hostdep.dependent_host_name
host = hosts.find_by_name(h_name)
if host is None:
err = "Error: the host dependency got a bad host_name definition '%s'" % h_name
hostdep.add_error(err)
dephost = hosts.find_by_name(dh_name)
if dephost is None:
err = "Error: the host dependency got " \
"a bad dependent_host_name definition '%s'" % dh_name
hostdep.add_error(err)
if host:
hostdep.host_name = host.uuid
if dephost:
hostdep.dependent_host_name = dephost.uuid
except AttributeError as exp:
err = "Error: the host dependency miss a property '%s'" % exp
hostdep.add_error(err) | [
"Replace dependent_host_name and host_name\n in host dependency by the real object\n\n :param hosts: host list, used to look for a specific one\n :type hosts: alignak.objects.host.Hosts\n :return: None\n "
] |
Please provide a description of the function:def linkify_hd_by_tp(self, timeperiods):
for hostdep in self:
try:
tp_name = hostdep.dependency_period
timeperiod = timeperiods.find_by_name(tp_name)
if timeperiod:
hostdep.dependency_period = timeperiod.uuid
else:
hostdep.dependency_period = ''
except AttributeError as exp: # pragma: no cover, simple protectionn
logger.error("[hostdependency] fail to linkify by timeperiod: %s", exp) | [
"Replace dependency_period by a real object in host dependency\n\n :param timeperiods: list of timeperiod, used to look for a specific one\n :type timeperiods: alignak.objects.timeperiod.Timeperiods\n :return: None\n "
] |
Please provide a description of the function:def linkify_h_by_hd(self, hosts):
for hostdep in self:
# Only used for debugging purpose when loops are detected
setattr(hostdep, "host_name_string", "undefined")
setattr(hostdep, "dependent_host_name_string", "undefined")
# if the host dep conf is bad, pass this one
if getattr(hostdep, 'host_name', None) is None or\
getattr(hostdep, 'dependent_host_name', None) is None:
continue
if hostdep.host_name not in hosts or hostdep.dependent_host_name not in hosts:
continue
hosts.add_act_dependency(hostdep.dependent_host_name, hostdep.host_name,
hostdep.notification_failure_criteria,
getattr(hostdep, 'dependency_period', ''),
hostdep.inherits_parent)
hosts.add_chk_dependency(hostdep.dependent_host_name, hostdep.host_name,
hostdep.execution_failure_criteria,
getattr(hostdep, 'dependency_period', ''),
hostdep.inherits_parent)
# Only used for debugging purpose when loops are detected
setattr(hostdep, "host_name_string", hosts[hostdep.host_name].get_name())
setattr(hostdep, "dependent_host_name_string",
hosts[hostdep.dependent_host_name].get_name()) | [
"Add dependency in host objects\n :param hosts: hosts list\n :type hosts: alignak.objects.host.Hosts\n\n :return: None\n "
] |
Please provide a description of the function:def is_correct(self):
state = True
# Internal checks before executing inherited function...
loop = self.no_loop_in_parents("host_name", "dependent_host_name")
if loop:
msg = "Loop detected while checking host dependencies"
self.add_error(msg)
state = False
for item in self:
for elem in loop:
if elem == item.host_name:
msg = "Host %s is parent host_name in dependency defined in %s" % (
item.host_name_string, item.imported_from
)
self.add_error(msg)
elif elem == item.dependent_host_name:
msg = "Host %s is child host_name in dependency defined in %s" % (
item.dependent_host_name_string, item.imported_from
)
self.add_error(msg)
return super(Hostdependencies, self).is_correct() and state | [
"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 merge(self, hosts):
for extinfo in self:
host_name = extinfo.get_name()
host = hosts.find_by_name(host_name)
if host is not None:
# Fusion
self.merge_extinfo(host, extinfo) | [
"Merge extended host information into services\n\n :param hosts: hosts list, to look for a specific one\n :type hosts: alignak.objects.host.Hosts\n :return: None\n "
] |
Please provide a description of the function:def merge_extinfo(host, extinfo):
# Note that 2d_coords and 3d_coords are never merged, so not usable !
properties = ['notes', 'notes_url', 'icon_image', 'icon_image_alt',
'vrml_image', 'statusmap_image']
# host properties have precedence over hostextinfo properties
for prop in properties:
if getattr(host, prop) == '' and getattr(extinfo, prop) != '':
setattr(host, prop, getattr(extinfo, prop)) | [
"Merge extended host information into a host\n\n :param host: the host to edit\n :type host: alignak.objects.host.Host\n :param extinfo: the external info we get data from\n :type extinfo: alignak.objects.hostextinfo.HostExtInfo\n :return: None\n "
] |
Please provide a description of the function:def set_proxy(self, proxy): # pragma: no cover, not with unit tests
if proxy:
logger.debug('PROXY SETTING PROXY %s', proxy)
self._requests_con.proxies = {
'http': proxy,
'https': proxy,
} | [
"Set HTTP proxy\n\n :param proxy: proxy url\n :type proxy: str\n :return: None\n "
] |
Please provide a description of the function:def post(self, path, args, wait=False):
uri = self.make_uri(path)
timeout = self.make_timeout(wait)
for (key, value) in list(args.items()):
args[key] = serialize(value, True)
try:
logger.debug("post: %s, timeout: %s, params: %s", uri, timeout, args)
rsp = self._requests_con.post(uri, json=args, timeout=timeout, verify=self.strong_ssl)
logger.debug("got: %d - %s", rsp.status_code, rsp.text)
if rsp.status_code != 200:
raise HTTPClientDataException(rsp.status_code, rsp.text, uri)
return rsp.content
except (requests.Timeout, requests.ConnectTimeout):
raise HTTPClientTimeoutException(timeout, uri)
except requests.ConnectionError as exp:
raise HTTPClientConnectionException(uri, exp.args[0])
except Exception as exp:
raise HTTPClientException('Request error to %s: %s' % (uri, exp)) | [
"POST an HTTP request to a daemon\n\n :param path: path to do the request\n :type path: str\n :param args: args to add in the request\n :type args: dict\n :param wait: True for a long timeout\n :type wait: bool\n :return: Content of the HTTP response if server returned 200\n :rtype: str\n "
] |
Please provide a description of the function:def put(self, path, args, wait=False): # pragma: no cover, looks never used!
# todo: remove this because it looks never used anywhere...
uri = self.make_uri(path)
timeout = self.make_timeout(wait)
try:
logger.debug("put: %s, timeout: %s, params: %s", uri, timeout, args)
rsp = self._requests_con.put(uri, args, timeout=timeout, verify=self.strong_ssl)
logger.debug("got: %d - %s", rsp.status_code, rsp.text)
if rsp.status_code != 200:
raise HTTPClientDataException(rsp.status_code, rsp.text, uri)
return rsp.content
except (requests.Timeout, requests.ConnectTimeout):
raise HTTPClientTimeoutException(timeout, uri)
except requests.ConnectionError as exp:
raise HTTPClientConnectionException(uri, exp.args[0])
except Exception as exp:
raise HTTPClientException('Request error to %s: %s' % (uri, exp)) | [
"PUT and HTTP request to a daemon\n\n :param path: path to do the request\n :type path: str\n :param args: data to send in the request\n :type args:\n :return: Content of the HTTP response if server returned 200\n :rtype: str\n "
] |
Please provide a description of the function:def explode(self, escalations):
# Now we explode all escalations (host_name, hostgroup_name) to escalations
for escalation in self:
properties = escalation.__class__.properties
name = getattr(escalation, 'host_name', getattr(escalation, 'hostgroup_name', ''))
creation_dict = {
'escalation_name':
'Generated-HE-%s-%s' % (name, escalation.uuid)
}
for prop in properties:
if hasattr(escalation, prop):
creation_dict[prop] = getattr(escalation, prop)
escalations.add_escalation(Escalation(creation_dict)) | [
"Create instance of Escalation for each HostEscalation object\n\n :param escalations: list of escalation, used to add new ones\n :type escalations: alignak.objects.escalation.Escalations\n :return: None\n "
] |
Please provide a description of the function:def serialize(self):
return {'uuid': self.uuid, 'ref': self.ref, 'sticky': self.sticky, 'notify': self.notify,
'end_time': self.end_time, 'author': self.author, 'comment': self.comment} | [
"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 Acknowledge\n :rtype: dict\n "
] |
Please provide a description of the function:def register(self, name, _type, statsd_host='localhost', statsd_port=8125,
statsd_prefix='alignak', statsd_enabled=False, broks_enabled=False):
self.name = name
# This attribute is not used, but I keep ascending compatibility with former interface!
self._type = _type
# local statsd part
self.statsd_host = statsd_host
self.statsd_port = int(statsd_port)
self.statsd_prefix = statsd_prefix
self.statsd_enabled = statsd_enabled
# local broks part
self.broks_enabled = broks_enabled
logger.debug("StatsD configuration for %s - %s:%s, prefix: %s, "
"enabled: %s, broks: %s, file: %s",
self.name, self.statsd_host, self.statsd_port,
self.statsd_prefix, self.statsd_enabled, self.broks_enabled,
self.stats_file)
if self.statsd_enabled and self.statsd_host is not None and self.statsd_host != 'None':
logger.info("Sending %s statistics to: %s:%s, prefix: %s",
self.name, self.statsd_host, self.statsd_port, self.statsd_prefix)
if self.load_statsd():
logger.info('Alignak internal statistics are sent to StatsD.')
else:
logger.info('StatsD server is not available.')
if self.stats_file:
try:
self.file_d = open(self.stats_file, 'a')
logger.info("Alignak internal statistics are written in the file %s",
self.stats_file)
except OSError as exp: # pragma: no cover, should never happen...
logger.exception("Error when opening the file '%s' : %s", self.stats_file, exp)
self.file_d = None
return self.statsd_enabled | [
"Init instance with real values\n\n :param name: daemon name\n :type name: str\n :param _type: daemon type\n :type _type:\n :param statsd_host: host to post data\n :type statsd_host: str\n :param statsd_port: port to post data\n :type statsd_port: int\n :param statsd_prefix: prefix to add to metric\n :type statsd_prefix: str\n :param statsd_enabled: bool to enable statsd\n :type statsd_enabled: bool\n :param broks_enabled: bool to enable broks sending\n :type broks_enabled: bool\n :return: None\n "
] |
Please provide a description of the function:def load_statsd(self):
if not self.statsd_enabled:
logger.info('Stats reporting is not enabled, connection is not allowed')
return False
if self.statsd_enabled and self.carbon:
self.my_metrics.append(('.'.join([self.statsd_prefix, self.name, 'connection-test']),
(int(time.time()), int(time.time()))))
self.carbon.add_data_list(self.my_metrics)
self.flush(log=True)
else:
try:
logger.info('Trying to contact StatsD server...')
self.statsd_addr = (socket.gethostbyname(self.statsd_host.encode('utf-8')),
self.statsd_port)
self.statsd_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
except (socket.error, socket.gaierror) as exp:
logger.warning('Cannot create StatsD socket: %s', exp)
return False
except Exception as exp: # pylint: disable=broad-except
logger.exception('Cannot create StatsD socket (other): %s', exp)
return False
logger.info('StatsD server contacted')
return True | [
"Create socket connection to statsd host\n\n Note that because of the UDP protocol used by StatsD, if no server is listening the\n socket connection will be accepted anyway :)\n\n :return: True if socket got created else False and an exception log is raised\n "
] |
Please provide a description of the function:def connect(self, name, _type, host='localhost', port=2004,
prefix='alignak', enabled=False, broks_enabled=False):
self.name = name
# This attribute is not used, but I keep ascending compatibility with former interface!
self._type = _type
# local graphite/carbon part
self.statsd_host = host
try:
self.statsd_port = int(port)
except ValueError:
self.statsd_port = 2004
self.statsd_prefix = prefix
self.statsd_enabled = enabled
# local broks part
self.broks_enabled = broks_enabled
logger.debug("Graphite/carbon configuration for %s - %s:%s, prefix: %s, "
"enabled: %s, broks: %s, file: %s",
self.name, self.statsd_host, self.statsd_port,
self.statsd_prefix, self.statsd_enabled, self.broks_enabled,
self.stats_file)
if self.statsd_enabled and self.statsd_host is not None and self.statsd_host != 'None':
logger.info("Sending %s statistics to: %s:%s, prefix: %s",
self.name, self.statsd_host, self.statsd_port, self.statsd_prefix)
self.carbon = CarbonIface(self.statsd_host, self.statsd_port)
logger.info('Alignak internal statistics will be sent to Graphite.')
return self.statsd_enabled | [
"Init instance with real values for a graphite/carbon connection\n\n :param name: daemon name\n :type name: str\n :param _type: daemon type\n :type _type:\n :param host: host to post data\n :type host: str\n :param port: port to post data\n :type port: int\n :param prefix: prefix to add to metric\n :type prefix: str\n :param enabled: bool to enable statsd\n :type enabled: bool\n :param broks_enabled: bool to enable broks sending\n :type broks_enabled: bool\n :return: None\n "
] |
Please provide a description of the function:def flush(self, log=False):
if not self.my_metrics:
logger.debug("Flushing - no metrics to send")
return True
now = int(time.time())
if self.last_failure and self.last_failure + self.metrics_flush_pause > now:
if not self.log_metrics_flush_pause:
date = datetime.datetime.fromtimestamp(
self.last_failure).strftime(self.date_fmt)
logger.warning("Metrics flush paused on connection error "
"(last failed: %s). "
"Inner stored metric: %d. Trying to send...",
date, self.metrics_count)
self.log_metrics_flush_pause = True
return True
try:
logger.debug("Flushing %d metrics to Graphite/carbon", self.metrics_count)
if self.carbon.send_data():
self.my_metrics = []
else:
logger.warning("Failed sending metrics to Graphite/carbon. "
"Inner stored metric: %d", self.metrics_count)
if log:
logger.warning("Failed sending metrics to Graphite/carbon. "
"Inner stored metric: %d", self.metrics_count)
return False
if self.log_metrics_flush_pause:
logger.warning("Metrics flush restored. "
"Remaining stored metric: %d", self.metrics_count)
self.last_failure = 0
self.log_metrics_flush_pause = False
except Exception as exp: # pylint: disable=broad-except
if not self.log_metrics_flush_pause:
logger.warning("Failed sending metrics to Graphite/carbon. "
"Inner stored metric: %d", self.metrics_count)
else:
date = datetime.datetime.fromtimestamp(
self.last_failure).strftime(self.date_fmt)
logger.warning("Metrics flush paused on connection error "
"(last failed: %s). "
"Inner stored metric: %d. Trying to send...",
date, self.metrics_count)
logger.warning("Exception: %s", str(exp))
self.last_failure = now
return False
return True | [
"Send inner stored metrics to the defined Graphite\n\n Returns False if the sending failed with a warning log if log parameter is set\n\n :return: bool\n "
] |
Please provide a description of the function:def send_to_graphite(self, metric, value, timestamp=None):
# Manage Graphite part
if not self.statsd_enabled or not self.carbon:
return
if timestamp is None:
timestamp = int(time.time())
self.my_metrics.append(('.'.join([self.statsd_prefix, self.name, metric]),
(timestamp, value)))
if self.metrics_count >= self.metrics_flush_count:
self.carbon.add_data_list(self.my_metrics)
self.flush() | [
"\n Inner store a new metric and flush to Graphite if the flush threshold is reached.\n\n If no timestamp is provided, get the current time for the metric timestam.\n\n :param metric: metric name in dotted format\n :type metric: str\n :param value:\n :type value: float\n :param timestamp: metric timestamp\n :type timestamp: int\n "
] |
Please provide a description of the function:def counter(self, key, value, timestamp=None):
_min, _max, count, _sum = self.stats.get(key, (None, None, 0, 0))
count += 1
_sum += value
if _min is None or value < _min:
_min = value
if _max is None or value > _max:
_max = value
self.stats[key] = (_min, _max, count, _sum)
# Manage local statsd part
if self.statsd_enabled and self.statsd_sock:
# beware, we are sending ms here, timer is in seconds
packet = '%s.%s.%s:%d|c' % (self.statsd_prefix, self.name, key, value)
packet = packet.encode('utf-8')
try:
self.statsd_sock.sendto(packet, self.statsd_addr)
except (socket.error, socket.gaierror):
pass
# cannot send? ok not a huge problem here and we cannot
# log because it will be far too verbose :p
# Manage Graphite part
if self.statsd_enabled and self.carbon:
self.send_to_graphite(key, value, timestamp=timestamp)
# Manage file part
if self.statsd_enabled and self.file_d:
if timestamp is None:
timestamp = int(time.time())
packet = self.line_fmt
if not self.date_fmt:
date = "%s" % timestamp
else:
date = datetime.datetime.fromtimestamp(timestamp).strftime(self.date_fmt)
packet = packet.replace("#date#", date)
packet = packet.replace("#counter#", '%s.%s.%s' % (self.statsd_prefix, self.name, key))
packet = packet.replace("#value#", '%d' % value)
packet = packet.replace("#uom#", 'c')
try:
self.file_d.write(packet)
except IOError:
logger.warning("Could not write to the file: %s", packet)
if self.broks_enabled:
logger.debug("alignak stat brok: %s = %s", key, value)
if timestamp is None:
timestamp = int(time.time())
return Brok({'type': 'alignak_stat',
'data': {
'ts': timestamp,
'type': 'counter',
'metric': '%s.%s.%s' % (self.statsd_prefix, self.name, key),
'value': value,
'uom': 'c'
}})
return None | [
"Set a counter value\n\n If the inner key does not exist is is created\n\n :param key: counter to update\n :type key: str\n :param value: counter value\n :type value: float\n :return: An alignak_stat brok if broks are enabled else None\n "
] |
Please provide a description of the function:def get_managed_configurations(self):
res = {}
for scheduler_link in list(self.schedulers.values()):
res[scheduler_link.instance_id] = {
'hash': scheduler_link.hash,
'push_flavor': scheduler_link.push_flavor,
'managed_conf_id': scheduler_link.managed_conf_id
}
logger.debug("Get managed configuration: %s", res)
return res | [
"Get the configurations managed by this satellite\n\n The configurations managed by a satellite is a list of the configuration attached to\n the schedulers related to the satellites. A broker linked to several schedulers\n will return the list of the configuration parts of its scheduler links.\n\n :return: a dict of scheduler links with instance_id as key and\n hash, push_flavor and configuration identifier as values\n :rtype: dict\n "
] |
Please provide a description of the function:def get_scheduler_from_hostname(self, host_name):
scheduler_uuid = self.hosts_schedulers.get(host_name, None)
return self.schedulers.get(scheduler_uuid, None) | [
"Get scheduler linked to the given host_name\n\n :param host_name: host_name we want the scheduler from\n :type host_name: str\n :return: scheduler with id corresponding to the mapping table\n :rtype: dict\n "
] |
Please provide a description of the function:def get_external_commands(self):
res = self.external_commands
logger.debug("Get and clear external commands list: %s", res)
self.external_commands = []
return res | [
"Get the external commands\n\n :return: External commands list\n :rtype: list\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.