%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2021-2025. All Rights Reserved.
%%
%% %CopyrightEnd%

[;1m  system_monitor(MonitorPid, Options)[0m

  Sets the system event monitoring options. [;;4mMonitorPid[0m is a local
  process identifier (pid) receiving system monitor messages.

  [;;4mChange[0m

    This function is superseded by [;;4mtrace:system/3[0m that operate
    on

    dynamic trace sessions.

  The second argument is a list of monitoring options to enable:

   • [;;4m{long_gc, Time}[0m

   • [;;4m{long_message_queue, {Disable, Enable}}[0m

   • [;;4m{long_schedule, Time}[0m

   • [;;4m{large_heap, Size}[0m

   • [;;4mbusy_port[0m

   • [;;4mbusy_dist_port[0m

  For more detailed descriptions about the monitoring options, see [;;4m[0m
  [;;4mtrace:system/3[0m.

  Unlink [;;4mtrace:system/3[0m, the arguments to [;;4msystem_monitor/2[0m
  specifies how all system monitoring should be set, not how it
  should be changed. This means only one process at a time ([;;4m[0m
  [;;4mMonitorPid[0m) can be the receiver of messages from system
  monitoring set with this function. Also, the way to clear a
  specific monitor option is to not include it in the list [;;4mOptions[0m.
  All system monitoring will, however, be cleared if the process
  identified by [;;4mMonitorPid[0m terminates.

  There are no special option values (like zero) to clear an option.
  Some of the options have a unspecified minimum value. Lower values
  will be adjusted to the minimum value. For example, it is
  currently not possible to monitor all garbage collections with [;;4m[0m
  [;;4m{long_gc, 0}[0m.

  Returns the previous system monitor settings just like [;;4m[0m
  [;;4merlang:system_monitor/0[0m.

  [;;4mNote[0m

    If a monitoring process gets so large that it itself starts to
    cause system monitor messages when garbage collecting, the
    messages enlarge the process message queue and probably make
    the problem worse. Keep the monitoring process neat and do not
    set the system monitor limits too tight.

  Failures:

   • [;;4mbadarg[0m - If [;;4mMonitorPid[0m does not exist.

   • [;;4mbadarg[0m - If [;;4mMonitorPid[0m is not a local process.
