<chapter id="eekee"><title>Managing System Messages</title><highlights><para>This chapter describes system messaging features in the Solaris Operating
System.</para>
</highlights><sect1 id="eekec"><title>Viewing System Messages</title><para>System messages display on the console device. The text of most system
messages look like this:</para><para>[ID  <replaceable>msgid</replaceable> <replaceable>facility</replaceable>.<replaceable>priority</replaceable>]</para><para>For example: </para><screen>[ID 672855 kern.notice] syncing file systems...</screen><para>If the message originated in the kernel, the kernel module name is displayed.
For example:</para><screen>Oct 1 14:07:24 mars ufs: [ID 845546 kern.notice] alloc: /: file system full </screen><para>When a system crashes, it might display a message on the system
console like this:</para><screen>panic: <replaceable>error message</replaceable></screen><para>Less frequently, this message might be displayed instead of the
panic message: </para><screen>Watchdog reset !</screen><para>The error logging daemon, <literal>syslogd</literal>,
automatically records various system warnings and errors in message files.
By default, many of these system messages are displayed on the system console
and are stored in the <filename>/var/adm</filename> directory. You can direct
where these messages are stored by setting up system message logging. For
more information, see <olink targetptr="eekis" remap="internal">Customizing System Message
Logging</olink>. These messages can alert you to system problems, such as
a device that is about to fail. </para><para>The <filename>/var/adm</filename> directory contains
several message files. The most recent messages are in <filename>/var/adm/messages</filename> file (and in <filename>messages.*</filename>), and the oldest
are in the <filename>messages.3</filename> file. After a period of time (usually
every ten days), a new <filename>messages</filename> file is created. The <filename>messages.0</filename> file is renamed <filename>messages.1</filename>, <filename>messages.1</filename> is renamed <filename>messages.2</filename>, and <filename>messages.2</filename> is renamed <filename>messages.3</filename>. The current <filename>/var/adm/messages.3</filename> file is deleted.  </para><para>Because the <filename>/var/adm</filename> directory stores large
files containing messages, crash dumps, and other data, this directory can
consume lots of disk space. To keep the <filename>/var/adm</filename> directory
from growing too large, and to ensure that future crash dumps can be saved,
you should remove unneeded files periodically. You can automate this task
by using the <command>crontab</command> file. For more information on automating
this task, see <olink targetptr="sysresdiskuse-45392" remap="internal">How to Delete Crash
Dump Files</olink> and <olink targetptr="sysrescron-18108" remap="internal">Chapter&nbsp;8,
Scheduling System Tasks (Tasks)</olink>.  </para><task id="eeklc"><title>How to View System Messages</title><procedure remap="single-step"><step><para>Display recent messages generated by a system crash or reboot
by using the <command>dmesg</command> command.  </para><screen>$ <userinput>dmesg</userinput></screen><para>Or, use the <command>more</command> command to display one screen of
messages at a time.</para><screen>$ <userinput>more /var/adm/messages</userinput></screen>
</step>
</procedure><example id="eekfo"><title>Viewing System Messages</title><para>The following example shows output from the <command>dmesg</command> command.
  </para><screen width="100">$ <userinput>dmesg</userinput>
Jan  3 08:44:41 starbug genunix: [ID 540533 kern.notice] SunOS Release 5.10 ...
Jan  3 08:44:41 starbug genunix: [ID 913631 kern.notice] Copyright 1983-2003 ...
Jan  3 08:44:41 starbug genunix: [ID 678236 kern.info] Ethernet address ...
Jan  3 08:44:41 starbug unix: [ID 389951 kern.info] mem = 131072K (0x8000000)
Jan  3 08:44:41 starbug unix: [ID 930857 kern.info] avail mem = 121888768
Jan  3 08:44:41 starbug rootnex: [ID 466748 kern.info] root nexus = Sun Ultra 5/
10 UPA/PCI (UltraSPARC-IIi 333MHz)
Jan  3 08:44:41 starbug rootnex: [ID 349649 kern.info] pcipsy0 at root: UPA 0x1f0x0
Jan  3 08:44:41 starbug genunix: [ID 936769 kern.info] pcipsy0 is /pci@1f,0
Jan  3 08:44:41 starbug pcipsy: [ID 370704 kern.info] PCI-device: pci@1,1, simba0
Jan  3 08:44:41 starbug genunix: [ID 936769 kern.info] simba0 is /pci@1f,0/pci@1,1
Jan  3 08:44:41 starbug pcipsy: [ID 370704 kern.info] PCI-device: pci@1, simba1
Jan  3 08:44:41 starbug genunix: [ID 936769 kern.info] simba1 is /pci@1f,0/pci@1
Jan  3 08:44:57 starbug simba: [ID 370704 kern.info] PCI-device: ide@3, uata0
Jan  3 08:44:57 starbug genunix: [ID 936769 kern.info] uata0 is /pci@1f,0/pci@1,
1/ide@3
Jan  3 08:44:57 starbug uata: [ID 114370 kern.info] dad0 at pci1095,6460
.
.
.</screen>
</example><taskrelated role="see-also"><para>For more information, see the <olink targetdoc="refman" targetptr="dmesg-1m" remap="external"><citerefentry><refentrytitle>dmesg</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page.</para>
</taskrelated>
</task>
</sect1><sect1 id="emcby"><title>System Log Rotation</title><para>System log files are rotated by the <command>logadm</command> command
from an entry in the root <filename>crontab</filename> file. The <filename>/usr/lib/newsyslog</filename> script is no longer used.</para><para>The system log rotation is defined in the <filename>/etc/logadm.conf</filename> file.
This file includes log rotation entries for processes such as <command>syslogd</command>.
For example, one entry in the <filename>/etc/logadm.conf</filename> file specifies
that the <filename>/var/log/syslog</filename> file is rotated weekly unless
the file is empty. The most recent <filename>syslog</filename> file becomes <filename>syslog.0</filename>, the next most recent becomes <filename>syslog.1</filename>,
and so on. Eight previous <filename>syslog</filename> log files are kept.</para><para>The <filename>/etc/logadm.conf</filename> file also contains time stamps
of when the last log rotation occurred.</para><para>You can use the <command>logadm</command> command to customize system
logging and to add additional logging in the <filename>/etc/logadm.conf</filename> file
as needed.</para><para>For example, to rotate the Apache access and error logs, use the following
commands:</para><screen># <userinput>logadm -w /var/apache/logs/access_log -s 100m</userinput>
# <userinput>logadm -w /var/apache/logs/error_log -s 10m</userinput></screen><para>In this example, the Apache <filename>access_log</filename> file is
rotated when it reaches 100 MB in size, with a <filename>.0</filename>, <filename>.1</filename>, (and so on) suffix, keeping 10 copies of the old <filename>access_log</filename> file. The <filename>error_log</filename> is rotated when it reaches
10 MB in size with the same suffixes and number of copies as the <filename>access_log</filename> file.</para><para>The <filename>/etc/logadm.conf</filename> entries for the preceding
Apache log rotation examples look similar to the following:</para><screen># <userinput>cat /etc/logadm.conf</userinput>
.
.
.
/var/apache/logs/error_log -s 10m
/var/apache/logs/access_log -s 100m</screen><para>For more information, see <olink targetdoc="refman" targetptr="logadm-1m" remap="external"><citerefentry><refentrytitle>logadm</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>.</para><para>You can use the <command>logadm</command> command as superuser or by
assuming an equivalent role (with Log Management rights). With role-based
access control (RBAC), you can grant non-root users the privilege of maintaining
log files by providing access to the <command>logadm</command> command. </para><para>For example, add the following entry to the <filename>/etc/user_attr</filename> file
to grant user <literal>andy</literal> the ability to use the <command>logadm</command> command:</para><screen>andy::::profiles=Log Management</screen><para>Or, you can set up a role for log management by using the Solaris Management
Console. For more information about setting up a role, see <olink targetdoc="sysadv6" targetptr="rbac-1" remap="external"><citetitle remap="section">Role-Based Access Control (Overview)</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</sect1><sect1 id="eekis"><title>Customizing System Message Logging</title><para>You
can capture additional error messages that are generated by various system
processes by modifying the <filename>/etc/syslog.conf</filename> file. By
default, the <filename>/etc/syslog.conf</filename> file directs many system
process messages to the <filename>/var/adm/messages</filename> files. Crash
and boot messages are stored here as well. To view <filename>/var/adm</filename> messages,
see <olink targetptr="eeklc" remap="internal">How to View System Messages</olink>.</para><para>The <filename>/etc/syslog.conf</filename> file has two columns separated
by tabs:</para><screen><replaceable>facility.level ...</replaceable> <replaceable>action</replaceable></screen><variablelist><varlistentry><term><replaceable>facility.level</replaceable></term><listitem><para>A <replaceable>facility</replaceable> or system source of
the message or condition. May be a comma-separated listed of facilities. Facility
values are listed in <olink targetptr="eekgi" remap="internal">Table&nbsp;15&ndash;1</olink>.
A <replaceable>level</replaceable>, indicates the severity or priority of
the condition being logged. Priority levels are listed in <olink targetptr="eekgu" remap="internal">Table&nbsp;15&ndash;2</olink>.</para><para>Do not put two entries for the same facility on the same line, if the
entries are for different priorities. Putting a priority in the syslog file
indicates that all messages of that all messages of that priority or higher
are logged, with the last message taking precedence. For a given facility
and level, <command>syslogd</command> matches all messages for that level
and all higher levels.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>action</replaceable></term><listitem><para>The action field indicates where the messages are forwarded.</para>
</listitem>
</varlistentry>
</variablelist><para>The following
example shows sample lines from a default <filename>/etc/syslog.conf</filename> file.
 </para><screen>user.err                                        /dev/sysmsg
user.err                                        /var/adm/messages
user.alert                                      `root, operator'
user.emerg                                      *</screen><itemizedlist><para>This means the following user messages are automatically logged:</para><listitem><para>User errors are printed to the console and also are logged
to the  <filename>/var/adm/messages</filename> file.</para>
</listitem><listitem><para>User messages requiring immediate action (<literal>alert</literal>)
are sent to the root and operator users.</para>
</listitem><listitem><para>User emergency messages are sent to individual users.</para>
</listitem>
</itemizedlist><note><para>Placing entries on separate lines might cause messages to be logged
out of order if a log target is specified more than once in the <filename>/etc/syslog.conf</filename> file. Note that you can specify multiple selectors in a single
line entry, each separated by a semi-colon.</para>
</note><para>The most common error condition sources are shown in the following table.
The most common priorities are shown in <olink targetptr="eekgu" remap="internal">Table&nbsp;15&ndash;2</olink> in order of severity.</para><table frame="topbot" id="eekgi"><title>Source Facilities for <filename>syslog.conf</filename> Messages</title><tgroup cols="2" colsep="0" rowsep="0"><colspec colname="column1" colwidth="157*"/><colspec colname="column2" colwidth="202*"/><thead><row rowsep="1"><entry><para>Source</para>
</entry><entry><para>Description</para>
</entry>
</row>
</thead><tbody><row><entry><para><literal>kern</literal> </para>
</entry><entry><para>The kernel</para>
</entry>
</row><row><entry><para><literal>auth</literal> </para>
</entry><entry><para>Authentication</para>
</entry>
</row><row><entry><para><literal>daemon</literal> </para>
</entry><entry><para>All daemons</para>
</entry>
</row><row><entry><para><literal>mail</literal> </para>
</entry><entry><para>Mail system</para>
</entry>
</row><row><entry><para><literal>lp</literal> </para>
</entry><entry><para>Spooling system</para>
</entry>
</row><row><entry><para><literal>user</literal> </para>
</entry><entry><para>User processes</para>
</entry>
</row>
</tbody>
</tgroup>
</table><note><para>The number of <literal>syslog</literal> facilities that can be
activated in the <filename>/etc/syslog.conf</filename> file is unlimited. </para>
</note><table frame="topbot" id="eekgu"><title>Priority Levels for <filename>syslog.conf</filename> Messages</title><tgroup cols="2" colsep="0" rowsep="0"><colspec colname="column1" colwidth="180*"/><colspec colname="column2" colwidth="179*"/><thead><row rowsep="1"><entry><para>Priority</para>
</entry><entry><para>Description</para>
</entry>
</row>
</thead><tbody><row><entry><para><literal>emerg</literal></para>
</entry><entry><para>System emergencies</para>
</entry>
</row><row><entry><para><literal>alert</literal> </para>
</entry><entry><para>Errors requiring immediate correction</para>
</entry>
</row><row><entry><para><literal>crit</literal></para>
</entry><entry><para>Critical errors</para>
</entry>
</row><row><entry><para><literal>err</literal></para>
</entry><entry><para>Other errors</para>
</entry>
</row><row><entry><para><literal>info</literal></para>
</entry><entry><para>Informational messages</para>
</entry>
</row><row><entry><para><literal>debug</literal> </para>
</entry><entry><para>Output used for debugging</para>
</entry>
</row><row><entry><para><literal>none</literal> </para>
</entry><entry><para>This setting doesn't log output </para>
</entry>
</row>
</tbody>
</tgroup>
</table><task id="eekii"><title>How to Customize System Message Logging</title><procedure>&rolestep.sgm;<step id="eekjz"><para>Edit the <filename>/etc/syslog.conf</filename> file,
adding or changing message sources, priorities, and message locations according
to the syntax described in <olink targetdoc="refman" targetptr="syslog.conf-4" remap="external"><citerefentry><refentrytitle>syslog.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink>.</para>
</step><step id="eeklo"><para>Exit the file, saving the changes.</para>
</step>
</procedure><example id="emcca"><title>Customizing System Message Logging</title><para>This sample <filename>/etc/syslog.conf</filename> <literal>user.emerg</literal> facility
sends user emergency messages to root <emphasis>and</emphasis> individual
users.</para><screen>user.emerg                                      `root, *'</screen>
</example>
</task>
</sect1><sect1 id="eekgt"><title>Enabling Remote Console Messaging</title><itemizedlist><para>The following new console features improve your ability to troubleshoot
remote systems:</para><listitem><para>The <command>consadm</command> command enables you to select a
serial device as an <emphasis>auxiliary</emphasis> (or remote) console. Using
the <command>consadm</command> command, a system administrator can configure
one or more serial ports to display redirected console messages and to host <command>sulogin</command> sessions when the system transitions between run levels.
This feature enables you to dial in to a serial port with a modem to monitor
console messages and participate in <literal>init</literal> state transitions.
(For more information, see <olink targetdoc="refman" targetptr="sulogin-1m" remap="external"><citerefentry><refentrytitle>sulogin</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> and
the step-by-step procedures that follow.) </para><para>While you can log in
to a system using a port configured as an auxiliary console, it is primarily
an output device displaying information that is also displayed on the default
console. If boot scripts or other applications read and write to and from
the default console, the write output displays on all the auxiliary consoles,
but the input is only read from the default console. (For more information
on using the <command>consadm</command> command during an interactive login
session, see <olink targetptr="eekjl" remap="internal">Using the consadm Command During an
Interactive Login Session</olink>.)</para>
</listitem><listitem><para>Console output now consists of kernel and <command>syslog</command> messages
written to a new pseudo device, <filename>/dev/sysmsg</filename>. In addition, <literal>rc</literal> script startup messages are written to <filename>/dev/msglog</filename>.
Previously, all of these messages were written to <filename>/dev/console</filename>.
 </para><para>Scripts that direct console output to <filename>/dev/console</filename> need
to be changed to <filename>/dev/msglog</filename> if you want to see script
messages displayed on the auxiliary consoles. Programs referencing <filename>/dev/console</filename> should be explicitly modified to use <structname>syslog()</structname> or <structname>strlog()</structname> if you want messages to be redirected to an auxiliary
device.</para>
</listitem><listitem><para>The <command>consadm</command> command runs a daemon to monitor
auxiliary console devices. Any display device designated as an auxiliary console
that disconnects, hangs up or loses carrier, is removed from the auxiliary
console device list and is no longer active. Enabling one or more auxiliary
consoles does not disable message display on the default console; messages
continue to display on <filename>/dev/console</filename>.</para>
</listitem>
</itemizedlist><sect2 id="eekfv"><title>Using Auxiliary Console Messaging During Run Level
Transitions</title><itemizedlist><para>Keep the following in mind when using auxiliary console messaging during
run level transitions:</para><listitem><para>Input cannot come from an auxiliary console if user input
is expected for an <literal>rc</literal> script that is run when a system
is booting. The input must come from the default console. </para>
</listitem><listitem><para>The <command>sulogin</command> program, invoked by <literal>init</literal> to
prompt for the superuser password when transitioning between run levels, has
been modified to send the superuser password prompt to each auxiliary device
in addition to the default console device. </para>
</listitem><listitem><para>When the system is in single-user mode and one or more auxiliary
consoles are enabled using the <command>consadm</command> command, a console
login session runs on the first device to supply the correct superuser password
to the <command>sulogin</command> prompt. When the correct password is received
from a console device, <command>sulogin</command> disables input from all
other console devices.</para>
</listitem><listitem><para>A message is displayed on the default console and the other
auxiliary consoles when one of the consoles assumes single-user privileges.
This message indicates which device has become the console by accepting a
correct superuser password. If there is a loss of carrier on the auxiliary
console running the single-user shell, one of two actions might occur:  </para><itemizedlist><listitem><para>If the auxiliary console represents a system at run level
1, the system proceeds to the default run level.  </para>
</listitem><listitem><para>If the auxiliary console represents a system at run level
S, the system displays the <literal>ENTER RUN LEVEL (0-6, s or S):</literal> message
on the device where the <command>init s</command> or <command>shutdown</command> command
had been entered from the shell.  If there isn't any carrier on that device
either, you will have to reestablish carrier and enter the correct run level.
The <command>init</command> or <command>shutdown</command> command will not
redisplay the run-level prompt.</para>
</listitem>
</itemizedlist>
</listitem><listitem><para>If you are logged in to a system using a serial port, and
an <command>init</command> or <command>shutdown</command> command is issued
to transition to another run level, the login session is lost whether this
device is the auxiliary console or not. This situation is identical to Solaris
releases without auxiliary console capabilities.</para>
</listitem><listitem><para>Once a device is selected as an auxiliary console using the <command>consadm</command> command, it remains the auxiliary console until the system
is rebooted or the auxiliary console is unselected. However, the <command>consadm</command> command includes an option to set a device as the auxiliary console
across system reboots. (See the following procedure for step-by-step instructions.) </para>
</listitem>
</itemizedlist>
</sect2><sect2 id="eekjl"><title>Using the <command>consadm</command> Command During
an Interactive Login Session</title><itemizedlist><para>If you want to run an interactive login session by logging in to a system
using a terminal that is connected to a serial port, and then using the <command>consadm</command> command to see the console messages from the terminal, note
the following behavior:</para><listitem><para>If you use the terminal for an interactive login
session while the auxiliary console is active, the console messages are sent
to the <filename>/dev/sysmsg</filename> or <filename>/dev/msglog</filename> devices.
 </para>
</listitem><listitem><para>While you issue commands on the terminal, input goes to your
interactive session and not to the default console (<filename>/dev/console</filename>).</para>
</listitem><listitem><para>If you run the <command>init</command> command to change run
levels, the remote console software kills your interactive session and runs
the <command>sulogin</command> program. At this point, input is accepted only
from the terminal and is treated like it's coming from a console device. This
allows you to enter your password to the <command>sulogin</command> program
as described in <olink targetptr="eekfv" remap="internal">Using Auxiliary Console Messaging
During Run Level Transitions</olink>.</para><para>Then, if you enter the correct
password on the (auxiliary) terminal, the auxiliary console runs an interactive <command>sulogin</command> session, locks out the default console and any competing
auxiliary console. This means the terminal essentially functions as the system
console.  </para>
</listitem><listitem><para>From here you can change to run level 3 or go to another run
level. If you change run levels, <command>sulogin</command> runs again on
all console devices. If you exit or specify that the system should come up
to run level 3, then all auxiliary consoles lose their ability to provide
input. They revert to being display devices for console messages.</para><para>As
the system is coming up, you must provide information to <literal>rc</literal> scripts
on the default console device. After the system comes back up, the <command>login</command> program runs on the serial ports and you can log back into another
interactive session. If you've designated the device to be an auxiliary console,
you will continue to get console messages on your terminal, but all input
from the terminal goes to your interactive session.  </para>
</listitem>
</itemizedlist>
</sect2><task id="eekdy"><title>How to Enable an Auxiliary (Remote) Console</title><tasksummary><para>The <command>consadm</command> daemon does not start monitoring the
port until after you add the auxiliary console with the <command>consadm</command> command.
As a security feature, console messages are only redirected until carrier
drops, or the auxiliary console device is unselected. This means carrier must
be established on the port before you can successfully use the <command>consadm</command> command.</para><para>For more information on enabling an auxiliary console, see the <olink targetdoc="refman" targetptr="consadm-1m" remap="external"><citerefentry><refentrytitle>consadm</refentrytitle><manvolnum>1m</manvolnum></citerefentry></olink> man page.</para>
</tasksummary><procedure><step id="eekhb"><para>Log in to the system as superuser.  </para>
</step><step id="eekhj"><para>Enable the auxiliary console.  </para><screen># <userinput>consadm -a</userinput> <replaceable>devicename</replaceable></screen>
</step><step id="eekiu"><para>Verify that the current connection is the auxiliary
console.</para><screen># <userinput>consadm</userinput></screen>
</step>
</procedure><example id="emjdw"><title>Enabling an Auxiliary (Remote) Console</title><screen># <userinput>consadm -a /dev/term/a</userinput>
# <userinput>consadm</userinput>
 /dev/term/a</screen>
</example>
</task><task id="eekip"><title>How to Display a List of Auxiliary Consoles</title><procedure><step id="eekgl"><para>Log in to the system as superuser.  </para>
</step><step id="eeklk"><para>Select one of the following steps:</para><substeps><step id="eekig"><para>Display the list of auxiliary consoles. </para><screen># <userinput>consadm</userinput>
/dev/term/a</screen>
</step><step id="eekfr"><para>Display the list of persistent auxiliary consoles.</para><screen># <userinput>consadm -p</userinput>
/dev/term/b</screen>
</step>
</substeps>
</step>
</procedure>
</task><task id="eekjg"><title>How to Enable an Auxiliary (Remote) Console Across
System Reboots</title><procedure><step id="eekko"><para>Log in to the system as superuser.  </para>
</step><step id="eekmz"><para>Enable the auxiliary console across system reboots. </para><screen># <userinput>consadm -a -p</userinput> <replaceable>devicename</replaceable>     </screen><para>This adds the device to the list of persistent auxiliary consoles.</para>
</step><step id="eekfl"><para>Verify that the device has been added to the list of
persistent auxiliary consoles.</para><screen># <userinput>consadm</userinput></screen>
</step>
</procedure><example id="emjdx"><title>Enabling an Auxiliary (Remote) Console Across System Reboots</title><screen># <userinput>consadm -a -p /dev/term/a</userinput> 
# <userinput>consadm</userinput>
/dev/term/a</screen>
</example>
</task><task id="eekep"><title>How to Disable an Auxiliary (Remote) Console</title><procedure><step id="eekky"><para>Log in to the system as superuser.  </para>
</step><step id="eekej"><para>Select one of the following steps:</para><substeps><step id="eekiv"><para>Disable the auxiliary console. </para><screen># <userinput>consadm -d</userinput> <replaceable>devicename</replaceable></screen><para>or</para>
</step><step id="eekgm"><para>Disable the auxiliary console and remove it from the
list of persistent auxiliary consoles.</para><screen># <userinput>consadm -p -d</userinput> <replaceable>devicename</replaceable></screen>
</step>
</substeps>
</step><step id="eekio"><para>Verify that the auxiliary console has been disabled.</para><screen># <userinput>consadm</userinput></screen>
</step>
</procedure><example id="emjdy"><title>Disabling an Auxiliary (Remote) Console</title><screen># <userinput>consadm -d /dev/term/a</userinput>
# <userinput>consadm</userinput></screen>
</example>
</task>
</sect1>
</chapter>