Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 37e222326095a93978d54b1564dd9954 > files > 107

apcupsd-3.10.5-1mdk.ppc.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
        <TITLE>Apcupsd System Logging</TITLE>
  <meta name="Author" content="Kern Sibbald">
                <link rel=stylesheet href="apcupsd-styles.css" type="text/css">
</HEAD>
<BODY>
<H2>Apcupsd System Logging</H2>
<P>The <B>apcupsd</B> philosophy is that all logging should be done
through the <B>syslog</B> facility (see: <B>man syslog</B>). This is
now implemented with the exceptions that <B>STATUS</B> logging, for
compatibility, with prior versions is still done to a file, and
<B>EVENTS</B> logging can be directed to a &quot;temporary&quot; file
so that it can be reported by the network information server. 
</P>
<P><B>Apcupsd</B> logging into four separate types called: 
</P>
<P>1. DEBUG 
<BR>2. DATA 
<BR>3. STATUS 
<BR>4. EVENTS 
</P>
<H3>DEBUG Logging</H3>
<P>Debug logging consists of debug messages. Normally these are
turned on only by developers, and currently there exist very few of
these debug messages. 
</P>
<H3>DATA Logging</H3>
<P>Data logging consists of periodically logging important data
concerning the operation of the UPS. See the 
<a href="data.html">DATA Format</a> section of this manual for
more details.
</P>
<h3>STATUS Logging</h3>
Status logging consists of logging all available information
known about your UPS as a series of ASCII records. This
information is also made available by the <b>apcupsd</b>
<a href="cgiprogs.html">network information server</a>.
<p>For more details on STATUS logging, see the
<a href="status.html">STATUS Format</a> section of this manual.
<H3>EVENTS Logging</H3>
<P>Events logging consists of logging events as they happen. For
example, successful startup, power fail, battery failure, system
shutdown, ... 
<p> See the <a href="events.html">EVENTS Format</a> section of
this manual for more details.
</P>
<h3>Implementation Details</h3>
 In order to ensure that the data logged to
syslog() can be directed to different files, I have assigned syslog()
levels to each of our four types of data as follows: 
</P>
<P>1. DEBUG logging has level LOG_DEBUG 3. STATUS logging has level
LOG_NOTICE <BR>4. EVENTS logging has levels LOG_WARNING, LOG_ERR,
LOG_CRIT, and LOG_ALERT 
</P>
<P>It should be noted that more work needs to be done on the precise
definitions of each of the levels for EVENTS logging. Currently, it
is roughly broken down as follows: 
</P>
<P>LOG_WARNING general information such as startup, etc. <BR>LOG_ERR
an error condition detected, e.g. communications problem with the
UPS. <BR>LOG_CRIT a serious problem has occurred such as power
failure, running on UPS batteries, ... <BR>LOG_ALERT a condition that
needs immediate attention such as pending system shutdown, ... 
</P>
<P>More work needs to be done to the code to ensure that it
corresponds to the above levels. 
</P>
<P>As a practical example of how to setup your syslog() to use the
new logging feature, suppose you wish to direct all DATA logging to a
file named /var/log/apcupsd.data, all EVENTS to the standard
/var/log/messages file (to be mixed with other system messages), and
at the same time send all EVENTS to /var/log/apcupsd.events, and
finally, you want to send all STATUS logging to the named pipe
/var/log/apcupsd.status 
</P>
<P>First as root, you create the named pipe: 
</P>
<P>mkfifo /var/log/apcupsd.status 
</P>
<P>change its permissions as necessary or use the -m option to set
them when creating the pipe. 
</P>
<P>Then you modify your /etc/syslog.conf file to direct the
appropriate levels of messages where you want them. To accomplish the
above, my syslog.conf file looks like: 
</P>
<PRE># exclude all apcupsd info by default
*.info;local0.none                    /var/log/messages

# Everything for apcupsd goes here
local0.info;local0.!notice             /var/log/apcupsd.data
local0.notice;local0.!warn            |/var/log/apcupsd.status
local0.warn                            /var/log/apcupsd.events
local0.warn                            /var/log/messages</PRE><H2>
Developer's Notes</H2>
<P>All logging functions and all error reporting are now done through
the log_event() subroutine call. Exceptions to this are:
initialization code where printf's are done, and writing to the
status file. Once the initialization code has completed and the
fork() to become a daemon is done, no printf's are used. log_event()
has exactly the same format as syslog(). In fact, the subroutine
consists of only a syslog() call. If anyone really wishes to log to a
file, the code to do so can easily be done by adding code to
log_event() in apclog.c. 
</P>
<hr>

<a href="faq.html" target="_self"><img src="back.gif" border=0 alt="Back"></a>
<a href="master-slave.html" target="_self"><img src="next.gif" border=0 alt="Next"></a>
<a href="index.html"><img src="home.gif" border=0 alt="Home"></a>
</BODY>
</HTML>