alarm_handler(3)

πŸ“¦
version 29.0.6 Β· 2 versions
, in nixos 26.05, nixpkgs unstable, ubuntu stonking

🌸 NAME 🌸

alarm_handler β€” bestie, it's literally an alarm handling process ✨


πŸ’– DESCRIPTION πŸ’–

okay so picture this: the alarm handler process is a gen_event event manager process, and its whole thing is receiving alarms in the system. No cap. But here's the tea β€” it's not trying to be a complete alarm handler, it's just, like, a place where alarms can be sent. A vibe. A destination πŸŽ€

At startup, one simple event handler is installed in the alarm handler. But users are encouraged (read: gently peer pressured, bestie 🫢) to write and install their own handlers.

So what does that simple event handler do? It sends all alarms as info reports to the error logger, and it saves all of them in a list. That list can be passed to a user-defined event handler that gets installed later. But ngl, that list can grow large if many alarms are generated β€” which is a very good reason to install a better user-defined handler. It's giving hoarding πŸ’€

Functions are provided to set and clear alarms, and the alarm format is defined by the user. For example, an event handler for SNMP can be defined, together with an alarm Management Information Base (MIB). Iconic, honestly πŸ¦‹

The alarm handler is part of the SASL application.

When you're writing new event handlers for the alarm handler, the following events must be handled:

  • {set_alarm, {AlarmId, AlarmDescr}} β€” this event is generated by alarm_handler:set_alarm({AlarmId, AlarmDecsr}).
  • {clear_alarm, AlarmId} β€” this event is generated by alarm_handler:clear_alarm(AlarmId).

The default simple handler is called alarm_handler, and it can be exchanged by calling gen_event:swap_handler/3 like this:

gen_event:swap_handler(alarm_handler, {alarm_handler, swap},
                       {NewHandler, Args})

Then NewHandler:init({Args, {alarm_handler, Alarms}}) is called. For more details, see gen_event in STDLIB. slay πŸ’…

πŸ‘€ See Also

error_logger, gen_event


✨ DATA TYPES ✨

  • alarm() :: {alarm_id(), AlarmDescription :: term()}.
  • alarm_id() :: term().

πŸ”₯ FUNCTIONS πŸ”₯

  • clear_alarm(alarm_id()) -> term().

Sends event clear_alarm to all event handlers.

When receiving this event, the default simple handler clears the latest received alarm with id AlarmId. bye bye alarm πŸ‘‹

  • get_alarms() -> [alarm()].

Returns a list of all active alarms. Heads up bestie: this function can only be used when the simple handler is installed. no simple handler, no list, fr fr 🌸

  • set_alarm(alarm()) -> term().

Sends event set_alarm to all event handlers.

When receiving this event, the default simple handler stores the alarm. AlarmId identifies the alarm and is used when the alarm is cleared.


and that's the whole page, bestie β€” go forth and handle those alarms πŸ’– This lil manual moment was brought to you by Ericsson AB, from the sasl 4.4 era, and yes, it's straight out of the alarm_handler(3) page. periodt πŸŽ€βœ¨

πŸ“¦ where this page comes from