let check ec param now =
    if ec.assertion param then
      (* assertion succeeded *)
      match ec.last_fail_alert_time with
      | None ->
          (* and it succeeded last time too -- no change *)
          None
      | Some _ ->
          (* it did not succeed last time -- change to success *)
          begin
            ec.last_fail_alert_time <- None;
            Some (ec.success_alert param)
          end
    else
      (* assertion failed *)
      let fail_alert () =
        ec.last_fail_alert_time <- Some now;
        Some (ec.fail_alert param)
      in
      match ec.last_fail_alert_time with
      | None -> fail_alert ()
      | Some t ->
          if Time.abs_diff now t > ec.min_alert_interval then
            (* enough time has passed since last failure, so alert *)
            fail_alert ()
          else
            None