- The error log level can be set very high for diagnosing an issue to create a log of only the last few hundred or thousand log messages, without a performance hit.
- Messages can be filtered to keep only certain events of interest. For example, the named pipe script can record only failed BIND attempts in the access log, and other events are discarded.
- The script can be used to send notifications when events happen, like adding or deleting a user entry or when a specific error occurs.
] | [
Several of the options that can be used with
ds-logpipe.py have abbreviated arguments.
Table 9.6. ds-logpipe.py Options
|/path/to/named_pipe|| Required. The fully path and name of the pipe to which the server will send the logging data. If SELinux is in enforcing mode, then the named pipe must be in the instance's default log directory (|
|--user||-u||The user ID to which the named pipe will be chowned. Any files created by plug-ins will also be owned by that user.|
|--maxlines||-m||The number of lines to keep in the buffer. The default is 1000.|
|--serverpidfile||-s|| The name of the file which contains the PID of the server. By default, this is |
|--serverpid||The process ID for the server. The server must already be running to use this argument.|
|--servertimeout||-t||The amount of time, in seconds, to wait for the PID file to be created and for the process to be running. The default is 60 (seconds).|
|--plugin|| Gives the name of a plug-in to call which defines a function to call with each line read from the pipe. An optional pre-function can be given to call when the plug-in is loaded, and an optional post-function can be given to run when the script exits. This file must be a Python script and must end in |
|pluginfile.arg|| Defines a plug-in argument. pluginfile is the name of the plug-in and each arg is the name of the argument for that plug-in. For example, to pass an argument name ldifinput to a plug-in named exampleplug, the argument would be |
The procedures for configuring the server for named pipe logging are covered in Section 7.5, “Replacing Log Files with a Named Pipe”.
Example 9.12. Basic Named Pipe Log Script
# ds-logpipe.py /var/log/dirsrc/slapd-example/errors.pipe
kill -1 %1can be used to tell the script to dump the last 1000 lines of the buffer to stdout, and continue running in the background.
Example 9.13. Running the Named Pipe Log Script in the Background
# ds-logpipe.py /var/log/dirsrc/slapd-example/errors.pipe &
Example 9.14. Saving the Output from the Named Pipe Log Script
# ds-logpipe.py /var/log/dirsrc/slapd-example/errors.pipe > /etc/dirsrv/myerrors.log 2>&1
-sargument. The PID for the server can be reference either by pointing to the server PID file or by giving the actual process ID number (if the server process is already running).
Example 9.15. Specifying the Serve PID
# ds-logpipe.py /var/log/dirsrc/slapd-example/errors.pipe --serverpidfile /var/run/dirsrv/slapd-example.pid
Example 9.16. Named Pipe Log Script with a Related Plug-in
# ds-logpipe.py /var/log/dirsrc/slapd-example/errors.pipe --plugin=/usr/share/dirsrv/data/logregex.py logregex.regex="warning"
warningare stored in the internal buffer and printed when the script exits.
logregex.pykeeps only log lines that match the given regular expression. The plug-in argument has the format
logregex.regex=pattern to specify the string or regular expression to use. There can be multiple
logregex.regexarguments which are all treated as AND statements. The error log line must match all given arguments. To allow any matching log lines to be records (OR), use a single
logregex.regexargument with a pipe (|) between the strings or expressions. See the pcre or Python regular expression documentation for more information about regular expressions and their syntax.
failedbinds.pylogs only failed BIND attempts, so this plug-in is only used for the access log. This takes the option
access.log, which is the file that the actual log messages are written to. This plug-in is an example of a complex plug-in that does quite a bit of processing and is a good place to reference to do other types of access log processing.