def _send_child_down(site: Site, log: WatchLog) -> None: # - Set child down, expect DOWN notification site.send_host_check_result("notify-test-child", STATE_DOWN, "DOWN") log.check_logged("HOST ALERT: notify-test-child;DOWN;HARD;1;DOWN") if site.core_name() == "cmc": # CMC: Send a new check result for the parent to make the CMC create the host notification # for the child site.send_host_check_result("notify-test-parent", STATE_UP, "UP") log.check_logged("HOST NOTIFICATION: check-mk-notify;notify-test-child;DOWN;check-mk-notify;")
def _send_child_down_expect_unreachable(unreachable_enabled: bool, site: Site, log: WatchLog) -> None: assert site.get_host_state("notify-test-child") == STATE_UP site.send_host_check_result("notify-test-child", STATE_DOWN, "DOWN", expected_state=STATE_UNREACHABLE) log.check_logged("HOST ALERT: notify-test-child;UNREACHABLE;HARD;1;") if unreachable_enabled: log.check_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" ) else: log.check_not_logged( "HOST NOTIFICATION: check-mk-notify;notify-test-child;UNREACHABLE;check-mk-notify;" )
def test_simple_rbn_service_notification(test_log: WatchLog, site: Site) -> None: site.send_service_check_result("notify-test", "PING", 2, "FAKE CRIT") # NOTE: "] " is necessary to get the actual log line and not the external command execution test_log.check_logged( "] SERVICE NOTIFICATION: check-mk-notify;notify-test;PING;CRITICAL;check-mk-notify;FAKE CRIT" ) test_log.check_logged( "] SERVICE NOTIFICATION: hh;notify-test;PING;CRITICAL;mail;FAKE CRIT") test_log.check_logged( "] SERVICE NOTIFICATION RESULT: hh;notify-test;PING;OK;mail;Spooled mail to local mail transmission agent;" )
def test_simple_rbn_host_notification(test_log: WatchLog, site: Site) -> None: site.send_host_check_result("notify-test", 1, "FAKE DOWN", expected_state=1) # NOTE: "] " is necessary to get the actual log line and not the external command execution test_log.check_logged( "] HOST NOTIFICATION: check-mk-notify;notify-test;DOWN;check-mk-notify;FAKE DOWN" ) test_log.check_logged( "] HOST NOTIFICATION: hh;notify-test;DOWN;mail;FAKE DOWN") test_log.check_logged( "] HOST NOTIFICATION RESULT: hh;notify-test;OK;mail;Spooled mail to local mail transmission agent;" )
def _send_child_recovery(site: Site, log: WatchLog) -> None: site.send_host_check_result("notify-test-child", STATE_UP, "UP") log.check_logged("HOST ALERT: notify-test-child;UP;HARD;1;") log.check_logged("HOST NOTIFICATION: check-mk-notify;notify-test-child;UP")
def _send_parent_down(site: Site, log: WatchLog) -> None: site.send_host_check_result("notify-test-parent", STATE_DOWN, "DOWN") log.check_logged("HOST ALERT: notify-test-parent;DOWN;HARD;1;DOWN")