os_sup(3erl)
π os_sup β Interface to OS System Messages
okay so bestie, welcome to os_sup(3erl), the Erlang module where your operating system gets to slide into your error logger's DMs π. Yes, fr fr β this whole page is about that.
β¨ NAME β¨
os_sup β Interface to OS System Messages. That's it, that's the vibe.
π¦ DESCRIPTION π¦
So os_sup is a process that provides 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, see os_mon(7). Available for Solaris and Windows β no cap, those two only.
Messages received from the operating system result in a user defined callback function being called. That function can do literally whatever filtering and formatting is necessary, and then deploy any type of logging suitable for the user's application. You're the main character here, you decide π.
βοΈ SOLARIS OPERATION βοΈ
The Solaris (SunOS 5.x) messages are retrieved from the syslog daemon, syslogd.
Enabling the service includes actions which require root privileges β like change of ownership and file privileges of an executable binary file, and creating a modified copy of the configuration file for syslogd. When os_sup is terminated, the service must be disabled, meaning the original configuration must be restored. Enabling/disabling can be done either outside or inside os_sup. See Configuration below, iykyk.
β οΈ Warning: This process cannot run in multiple instances on the same hardware.OS_Monmust be configured to startos_supon one node only if two or more Erlang nodes execute on the same machine. Like, do not run two of these, it's giving chaos π.
Also, heads up: the format of received events is not defined. Not me being vague, that's just literally what the docs say π.
πͺ WINDOWS OPERATION πͺ
The Windows messages are retrieved from the eventlog file.
The nteventlog module is used to implement os_sup. See nteventlog(3erl). Note that the start functions of nteventlog does not need to be used, as in this case the process is started automatically as part of the OS_Mon supervision tree. She's independent, she starts herself π
.
OS messages are formatted as a tuple {Time, Category, Facility, Severity, Message}:
Time = {MegaSecs, Secs, MicroSecs}β a time stamp as returned by the BIFnow().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 is 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 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". (Yes,"Audit_Faulure"β that spelling is exactly what's in the docs, I'm not touching it, it's iconic now π«Ά.)Message = string()β formatted exactly as it would be in the NT eventlog viewer. Binary data is not imported into Erlang.
π 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 using error_logger:error_report(Tag, Msg). Tag is the value of os_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. Lowkey listen to the recommendation, bestie π₯.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".
π EXPORTS π
β enable() -> ok | {error, Res} / enable(Dir, Conf) -> ok | {error, Error}
Types:
Dir = Conf = 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.
β disable() -> ok | {error, Res} / disable(Dir, Conf) -> ok | {error, Error}
Types:
Dir = Conf = 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. (And yes, nootp β that's the actual command, not a typo I made up, I promise π)
π SEE ALSO π
error_logger(3erl), os_mon(3erl)
syslogd(1M), syslog.conf(5) in the Solaris documentation.
β¨ And that's the whole page, bestie β brought to you by Ericsson AB, version os_mon 2.8.2, in all her os_sup(3erl) glory. Periodt. πππ¦
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms