Module lama_alarm_h

This module implements a replacement for SASL's alarm_handler.

Version: $Rev: 265 $

Behaviours: gen_event.

Authors: Serge Aleynikov (serge@hq.idt.net).

Description

This module implements a replacement for SASL's alarm_handler. It offers two features: This handler is fault tolegant as it is guarded by the lama_guard process. In case of a handler crash the process will receive a notification sent by gen_event exit, and will be restarted by the parent lama_sup_safe supervisor defined in the lama module.

Data Types

alarm()

alarm() = {AlarmId::alarm_id(), Description::term()}

alarm_id()

alarm_id() = atom() | {atom(), Data::term()}

varbinds()

varbinds() = list() | Fun

Function Index

add_alarm_trap/3Add an alarm to trap mapping to the internal #state.alarm_map list.
clear_alarm/1Clear alarm that was previously set by set_alarm/1.
delete_alarm_trap/1Delete an alarm to trap mapping.
get_alarm_map/0Get currently active alarms.
get_alarms/0Get currently active alarms.
get_def_options/0Gets default module's options.
set_alarm/1Set alarm.
start_link/1Installs the new alarm handler.
stop/0Remore alarm handler.

Function Details

add_alarm_trap/3

add_alarm_trap(AlarmID::atom(), Trap::atom(), Varbinds::varbinds()) -> ok

Add an alarm to trap mapping to the internal #state.alarm_map list. Note: when Alarm key is a tuple of ::alarm_id() type, use the first element of the tuple as the AlarmID parameter to this function.
Example: {{AlarmID, _}, _} = {{disk_almost_full, "/usr"}, "Low disk space"} add_alarm_trap(AlarmID, diskAlmostFullAlarm, []).

clear_alarm/1

clear_alarm(AlarmId::alarm_id()) -> ok | {error, Reason}

Clear alarm that was previously set by set_alarm/1. Error is returned if the alarm is mapped to an SNMP trap, and notification couldn't be sent (in this case the alarm will still be added to the internal alarm list).

See also: check_alarm/2, set_alarm/1.

delete_alarm_trap/1

delete_alarm_trap(AlarmID::atom()) -> ok

Delete an alarm to trap mapping.

get_alarm_map/0

get_alarm_map() -> AlarmMap

Get currently active alarms.

get_alarms/0

get_alarms() -> Alarms

Get currently active alarms.

get_def_options/0

get_def_options() -> TypedOptions::typed_options()

Gets default module's options.

set_alarm/1

set_alarm(Alarm::alarm()) -> ok | {error, Reason}

Set alarm. Multiple invocations of this function with the same AlarmId will not cause duplicate alarms to to be set. Error is returned if the alarm is mapped to an SNMP trap, and notification couldn't be sent (in this case the alarm will still be added to the internal alarm list).

See also: check_alarm/2, clear_alarm/1.

start_link/1

start_link(Options) -> ok | already_started | throw({error, Reason})

Installs the new alarm handler. It should be called from the lama_guard's process.
Options:

Note: Internal store of alarms is a list, and this implementation is not efficient for handling a large number of distinct alarms.

stop/0

stop() -> ok | {error, Reason}

Remore alarm handler.