anchor.diff:  terminate(_, _) ->
       ok.
   
  +code_change(_OldVsn, State, _Extra) ->
  +    {ok, State}.
  +
  +%%%=============================================================================
  +%%% Internal functions
  +%%%=============================================================================
  +
   alarm_msg(Type, AlarmId, Json) ->
       Msg = emqttd_message:make(alarm,
                                 topic(Type, AlarmId),
  
positive.code: topic(clear, AlarmId) ->
      emqttd_topic:systop(<<"alarms/", AlarmId/binary, "/clear">>).
  
  
  
negative.code: 
  -module(emqttd_alarm).
  
  -author("Feng Lee <feng@emqtt.io>").
  
  -include("emqttd.hrl").
  
  -behaviour(gen_event).
  
  -define(ALARM_MGR, ?MODULE).
  
  %% API Function Exports
  -export([start_link/0, alarm_fun/0, get_alarms/0,
           set_alarm/1, clear_alarm/1,
           add_alarm_handler/1, add_alarm_handler/2,
           delete_alarm_handler/1]).
  
  %% gen_event callbacks
  -export([init/1, handle_event/2, handle_call/2, handle_info/2,
           terminate/2, code_change/3]).
  
  %%%=============================================================================
  %%% API
  %%%=============================================================================
  
  start_link() ->
      start_with(fun(Pid) -> gen_event:add_handler(Pid, ?MODULE, []) end).
  
  start_with(Fun) ->
      case gen_event:start_link({local, ?ALARM_MGR}) of
          {ok, Pid} -> Fun(Pid), {ok, Pid};
          Error     -> Error
      end.
  
  alarm_fun() ->
  