def send_sensu_event(instance, oom_events, args): """ :param instance: InstanceConfig :param oom_events: a list of OOMEvents """ check_name = compose_check_name_for_service_instance( 'oom-killer', instance.service, instance.instance, ) monitoring_overrides = instance.get_monitoring() status = compose_sensu_status( instance=instance, oom_events=oom_events, is_check_enabled=monitoring_overrides.get('check_oom_events', True), ) monitoring_overrides.update({ 'team': 'noop', # TODO: remove after testing 'page': False, 'ticket': False, 'alert_after': '0m', 'realert_every': args.realert_every, 'notification_email': False, # TODO: remove after testing 'irc_channels': ['#oom-test'], # TODO: remove after testing 'runbook': 'http://y/none', # TODO: needs a link 'tip': 'Try bumping the memory limit past %dMB' % instance.get_mem(), }) return monitoring_tools.send_event( service=instance.service, check_name=check_name, overrides=monitoring_overrides, status=status[0], output=status[1], soa_dir=instance.soa_dir, )
def send_sensu_event(instance, oom_events, args): """ :param instance: InstanceConfig :param oom_events: a list of OOMEvents """ check_name = compose_check_name_for_service_instance( 'oom-killer', instance.service, instance.instance, ) monitoring_overrides = instance.get_monitoring() status = compose_sensu_status( instance=instance, oom_events=oom_events, is_check_enabled=monitoring_overrides.get('check_oom_events', True), ) monitoring_overrides.update({ 'page': False, 'ticket': False, 'alert_after': '0m', 'realert_every': args.realert_every, 'runbook': 'y/check-oom-events', 'tip': 'Try bumping the memory limit past %dMB' % instance.get_mem(), }) return monitoring_tools.send_event( service=instance.service, check_name=check_name, overrides=monitoring_overrides, status=status[0], output=status[1], soa_dir=instance.soa_dir, )
def send_sensu_event(instance, oom_events, args): """ :param instance: InstanceConfig :param oom_events: a list of OOMEvents """ check_name = compose_check_name_for_service_instance( "oom-killer", instance.service, instance.instance) monitoring_overrides = instance.get_monitoring() status = compose_sensu_status( instance=instance, oom_events=oom_events, is_check_enabled=monitoring_overrides.get("check_oom_events", True), ) monitoring_overrides.update({ "page": False, "ticket": False, "alert_after": "0m", "realert_every": args.realert_every, "runbook": "y/check-oom-events", "tip": "Try bumping the memory limit past %dMB" % instance.get_mem(), }) return monitoring_tools.send_event( service=instance.service, check_name=check_name, overrides=monitoring_overrides, status=status[0], output=status[1], soa_dir=instance.soa_dir, )
def test_compose_check_name_for_job(): expected_check = 'check-chronos-jobs.myservice.myinstance' assert chronos_tools.compose_check_name_for_service_instance( 'check-chronos-jobs', 'myservice', 'myinstance', ) == expected_check
def send_event(service, instance, monitoring_overrides, soa_dir, status_code, message): check_name = compose_check_name_for_service_instance('check_chronos_jobs', service, instance) monitoring_tools.send_event( service=service, check_name=check_name, overrides=monitoring_overrides, status=status_code, output=message, soa_dir=soa_dir, )
def check_chronos_job_name(service, instance): return compose_check_name_for_service_instance('check_chronos_jobs', service, instance)
def test_compose_check_name_for_job(): expected_check = 'check-chronos-jobs.myservice.myinstance' assert chronos_tools.compose_check_name_for_service_instance('check-chronos-jobs', 'myservice', 'myinstance') == expected_check
def test_compose_check_name_for_job(): expected_check = "check-chronos-jobs.myservice.myinstance" assert (chronos_tools.compose_check_name_for_service_instance( "check-chronos-jobs", "myservice", "myinstance") == expected_check)