syslog

A critical part of the system administrator’s job is monitoring the system. Solaris uses the syslog message facility to do this. syslogd is the daemon responsible for capturing system messages. The messages can be warnings, alerts, or simply informational messages. As the system administrator, you customize syslog to specify where and how system messages are to be saved.

The syslogd daemon receives messages from applications on the local host or from remote hosts and then directs messages to a specified log file. To each message that syslog captures, it adds a timestamp, the message type keyword at the beginning of the message, and a newline at the end of the message. For example, the following message was logged in the /var/adm/messages file:

May 12 06:50:36 ultra5 unix: NOTICE: alloc: /opt: file system full 

syslog enables you to capture messages by facility (the part of the system that generated the message) and by level of importance. Facility is considered to be the service area generating the message or error (such as printing, email, or network), whereas the level can be considered the level of severity (such as notice, warning, error, or emergency). syslog also enables you to forward messages to another machine so that all your messages can be logged in one location.The syslogd daemon reads and logs messages into a set of files described by the configuration file /etc/syslog.conf. An entry in the /etc/ syslog.conf file is composed of two fields:

selector     action 

The selector field contains a semicolon-separated list of priority specifications of this form:

facility.level [ ; facility.level ] 

The action field indicates where to forward the message.

Many defined facilities exist; they are described in Table 15.17.

Table 15.17. Recognized Values for Facility
Value Description
user Messages generated by user processes. This is the default priority for messages from programs or facilities not listed in this file.
kern Messages generated by the kernel.
mail The mail system.
daemon System daemons, such as in.ftpd.
auth The authorization system, such as login, su, getty, and others.
lpr The line printer spooling system, such as lpr, lpc, and others.
news Reserved for the Usenet network news system.
uucp Reserved for the UUCP system. It does not currently use the syslog mechanism.
cron The cron/at facility, such as crontab, at, cron, and others.
local0-7 Reserved for local use.
mark For timestamp messages produced internally by syslogd.
* Indicates all facilities except the mark facility.

Table 15.18 lists recognized values for the syslog level field. They are listed in descending order of severity.

Table 15.18. Recognized Values for level
Value Description
emerg Panic conditions that would normally be broadcast to all users.
alert Conditions that should be corrected immediately, such as a corrupted system database.
crit Warnings about critical conditions, such as hard device errors.
err Other errors.
warning Warning messages.
notice Conditions that are not error conditions but that might require special handling.
info Informational messages.
debug Messages that are normally used only when debugging a program.
none Does not send messages from the indicated facility to the selected file. For example, the entry *.debug;mail.none in /etc/syslog.conf sends all messages except mail messages to the selected file.

Values for the action field can have one of four forms:

  • A filename, beginning with a leading slash. This indicates that messages specified by the selector are to be written to the specified file. The file is opened in append mode.

  • The name of a remote host, prefixed with a @. An example is @server, which indicates that messages specified by the selector are to be forwarded to syslogd on the named host. The hostname loghost is the hostname given to the machine that will log syslogd messages. Every machine is loghost by default. This is specified in the local /etc/hosts file. It is also possible to specify one machine on a network to be loghost by making the appropriate host table entries. If the local machine is designated as loghost syslogd messages are written to the appropriate files. Otherwise, they are sent to the machine loghost on the network.

  • A comma-separated list of usernames, which indicates that messages specified by the selector are to be written to the named users if they are logged in.

  • An asterisk, which indicates that messages specified by the selector are to be written to all logged-in users.

Blank lines are ignored. Lines in which the first nonwhitespace character is a # are treated as comments.

All of this becomes much clearer when you look at sample entries from an /etc/syslog.conf file:

*.err    /dev/console 
*.err;daemon,auth.notice;mail.crit    /var/adm/messages 
mail.debug    /var/spool/mqueue/syslog 
*.alert    root 
*.emerg    * 
kern.err    @server 
*.alert;auth.warning    /var/log/auth 

In this example, the first line prints all errors on the console.

The second line sends all errors, daemon and authentication system notices, and critical errors from the mail system to the file /var/adm/messages.

The third line sends mail system debug messages to /var/spool/mqueue/ syslog.

The fourth line sends all alert messages to user root.

The fifth line sends all emergency messages to all users.

The sixth line forwards kernel messages of err (error) severity or higher to the machine named server.

The last line logs all messages from the authorization system of alert level or higher in the file /var/log/auth.

The level none may be used to disable a facility. This is usually done in the context of eliminating messages. For example:

*.debug;mail.none /var/adm/messages 

This selects debug messages from all facilities except those from mail. In other words, mail messages are disabled. The mail system, sendmail, logs a number of messages. This information can be extremely large, so some system administrators disable mail messages or send them to another file that they clean out frequently. Before disabling mail messages, however, remember that sendmail messages come in very handy when you’re diagnosing mail problems or tracking mail forgeries.

syslogd is started in the early stages of multiuser bootup from the /etc/ rc2.d directory with a script called S74syslog. To restart the syslog facility, issue this:

/etc/rc2.d/S74syslog stop 
/etc/rc2.d/S74syslog start 

The syslog facility reads its configuration information from /etc/syslog.conf whenever it receives the HUP signal (such as kill -HUP). The first message is always logged by the syslog daemon itself when it places a timestamp on when the daemon was started.

Syslog logs are automatically rotated on a regular basis. In previous Solaris releases, this was achieved by the program newsyslog. As of Solaris 9, log rotation is carried out by logadm, a program normally run as a root-owned cron job. A configuration file /etc/logadm.conf is now used to manage log rotation and allows a number of criteria to be specified. See the logadm and logadm.conf manual pages for further details.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset