os_sup(3)
β¨ os_sup β bestie's guide to the Erlang os_sup module β¨
okay so welcome to the os_sup page from the Erlang docs, manual section 3, and yes it's the interface to OS System Messages π (that's literally what NAME says). grab a strawberry π and let's go.
π NAME π
os_sup β Interface to OS System Messages. that's it, that's the name, no notes π
πΈ DESCRIPTION πΈ
so os_sup is a process, right? and what it does is provide a message passing service from the operating system over to the error logger in the Erlang runtime system π«Ά. it's part of the OS_Mon application, go look at os_mon for the whole picture. available for Solaris and Windows, and no, not everywhere else, sorry bestie π.
when messages come in from the OS, that results in a user defined callback function getting called π. that function is yours, so it can do literally whatever filtering and formatting is necessary, and then deploy any type of logging that's suitable for your application. main character energy for your callback fr fr π
βοΈ Solaris Operation βοΈ
the Solaris (SunOS 5.x) messages get retrieved from the syslog daemon, syslogd π¦.
enabling the service includes actions that require root privileges, like changing ownership and file privileges of an executable binary file, and creating a modified copy of the configuration file for syslogd π. and when os_sup is terminated, the service must be disabled, which means the original configuration must be restored, no skipping that step. enabling/disabling can be done either outside or inside os_sup β see Configuration down below π.
β οΈ WARNING: this process cannot run in multiple instances on the same hardware. like, at all. OS_Mon must be configured to start os_sup on one node only if two or more Erlang nodes execute on the same machine. periodt π
ββοΈ
the format of received events is not defined. yep. that's the whole sentence. iconic honestly β¨
πͺ Windows Operation πͺ
the Windows messages get retrieved from the eventlog file π.
the nteventlog module is what's used to implement os_sup. go see nteventlog. but important: the start functions of nteventlog do not need to be used, because in this case the process is started automatically as part of the OS_Mon supervision tree π. so don't you dare call them, they're not needed.
OS messages are formatted as a tuple {Time, Category, Facility, Severity, Message} β let's break that down one by one:
Time = {MegaSecs, Secs, MicroSecs}β a time stamp as returned by the BIFnow/0β°Category = string()β usually one of"System","Application"or"Security". note that the NT eventlog viewer has another notion of category, which in most cases is totally meaningless and therefore not imported into Erlang π. what's called a category here is one of the main three types of events occurring in a normal NT system.Facility = string()β the source of the message, usually the name of the application that generated it. this could be almost any string. when you're matching messages from certain applications, the version number of the application may have to be accounted for π. this is what the NT event viewer calls"source".Severity = string()β one of"Error","Warning","Informational","Audit_Success","Audit_Faulure"or, in case of a currently unknown Windows NT version,"Severity_Unknown"πMessage = string()β formatted exactly as it would be in the NT eventlog viewer. binary data is not imported into Erlang, so don't come looking for it π§
βοΈ Configuration βοΈ
os_sup_mfa = {Module, Function, Args}β the callback function to use.ModuleandFunctionare atoms andArgsis a list of terms. when an OS messageMsgis received, this function is called asapply(Module, Function, [Msg | Args])π. default is{os_sup, error_report, [Tag]}which will send the event to the error logger usingerror_logger:error_report(Tag, Msg). andTagis the value ofos_sup_errortag, see below πos_sup_errortag = atom()β this parameter defines the error report type used when messages are sent to error logger using the default callback function. default isstd_error, which means the events are handled by the standard event handler πΈos_sup_enable = bool()β Solaris only. defines if the service should be enabled (and disabled) inside (true) or outside (false)os_sup. for backwards compatibility reasons, the default istrueπ¬. the recommended value isfalse, as the Erlang emulator should normally not be run with root privileges, as is required for enabling the service. so like... change it, bestie, we're begging πos_sup_own = string()β Solaris only. defines the directory which contains the backup copy and the Erlang specific configuration files forsyslogd, and a named pipe to receive the messages fromsyslogdπ. default is"/etc".os_sup_syslogconf = string()β Solaris only. defines the full name of the configuration file forsyslogd. default is"/etc/syslog.conf"π
π See also π
error_logger, os_mon
syslogd(1M), syslog.conf(4) in the Solaris documentation π¦
π₯ FUNCTIONS π₯
disable/2
disable(Dir, Conf) -> ok | {error, Res}
when Dir :: string(), Conf :: string(), Res :: string().
disables the os_sup service. needed on Solaris only π«Ά
if the configuration parameter os_sup_enable is false, this function is called automatically by os_sup, using the same arguments as when enable/2 was called β¨
if os_sup_enable is true, this function must be called after OS_Mon/os_sup is stopped π. Dir defines the directory which contains the backup copy and the Erlang specific configuration files for syslogd, and a named pipe to receive the messages from syslogd. defaults to "/etc". Conf defines the full name of the configuration file for syslogd. default is "/etc/syslog.conf" π
results in a OS call to:
<PRIVDIR>/bin/mod_syslog nootp Dir Conf
where <PRIVDIR> is the priv directory of OS_Mon, code:priv_dir(os_mon) π
returns ok if this yields the expected result "0", and {error, Res} if it yields anything else π€
NOTE: this function requires root privileges to succeed. like, actually requires it. no cap π
enable/2
enable(Dir, Conf) -> ok | {error, Res}
when Dir :: string(), Conf :: string(), Res :: string().
enables the os_sup service. needed on Solaris only π«Ά
if the configuration parameter os_sup_enable is false, this function is called automatically by os_sup, using the values of os_sup_own and os_sup_syslogconf as arguments β¨
if os_sup_enable is true, this function must be called before OS_Mon/os_sup is started π. Dir defines the directory which contains the backup copy and the Erlang specific configuration files for syslogd, and a named pipe to receive the messages from syslogd. defaults to "/etc". Conf defines the full name of the configuration file for syslogd. default is "/etc/syslog.conf" π
results in a OS call to:
<PRIVDIR>/bin/mod_syslog otp Dir Conf
where <PRIVDIR> is the priv directory of OS_Mon, code:priv_dir(os_mon) π
returns ok if this yields the expected result "0", and {error, Res} if it yields anything else π€
NOTE: this function requires root privileges to succeed. yes, again. still true. still root. π
and that's the whole page bestie, you ate that π½οΈπ this came to you from Ericsson AB, and it's the os_mon version 2.12 release of os_sup(3) β go forth and read your system messages, you got this π¦β¨π
π¦ where this page comes from
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms