DS-LOGPIPE.PY(1)

πŸ’– DS-LOGPIPE.PY πŸ’–

okay bestie, welcome to the manual page for ds-logpipe.py, a General Commands Manual situation (section 1, obviously) πŸ’…


✨ NAME ✨

ds-logpipe.py β€” create and read from a named pipe instead of a log file πŸŽ€


🌸 SYNOPSIS 🌸

ds-logpipe.py /full/path/to/namedpipe
       [-m maxlinestobuffer] [-u userid] [-s serverpidfile] [-t
servertimeout] [--plugin=/path/to/pluginfile.py] [pluginfile.arg=value]

πŸ¦‹ DESCRIPTION πŸ¦‹

so the Named Pipe Log Script lets you swap a log file out for a named pipe that's attached to a script. the server then sends its log output to the script instead of to a log file. and like… why would you want that? because it unlocks SO many things, no cap:

  • log only certain events, e.g. failed binds, connections from certain ip addresses, etc.
  • log only lines that match a certain pattern
  • log only the last N lines β€” genuinely so useful for enabling full error log debug levels in production environments πŸ‘‘
  • send an email or other notification when a certain event is detected

the script is written in python, and it's plugin girlie πŸ’…. by default it logs the last N lines (default 1000). there are two plugins provided β€” one that logs only failed bind attempts, and one that logs only lines matching given regular expressions. iconic behavior fr fr.


πŸ’… OPTIONS πŸ’…

a summary of options is included below, bestie, read them all:

  • /full/path/to/namedpipe β€” Required. the full path and file name of the named pipe. if it doesn't exist, it will be created πŸŽ€. if it exists and it's a named pipe, the script will use it. if it exists and it is not a pipe, the script will abort πŸ’€. the ownership will be the same as the user running the script (or peep the -u option below).
  • -m|--maxlines=N β€” number of lines to buffer. default is 1000.
  • -u|--userid=user β€” the pipe and any other files created by the script will be chown()'d to this userid. this may be a string userid name or a numeric userid value.
  • -s|--serverpidfile=/path/to/servername.pid β€” if you want the script to exit when a particular directory server exists, specify the full path to the file containing the server pid. the default is usually something like /var/run/dirsrv/slapd-<instancename>.pid where <instancename> is usually the hostname.
  • -t|--servertimeout=N β€” since the serverpidfile may not exist yet when the script is run, the script will wait by default 60 seconds for the pid file to exist and the server to be started. use this option to specify a different timeout. the -t option only applies when using -s or --serverpid β€” otherwise it does nothing 🫠.
  • --serverpid=P β€” IF the server you want to track is already running, you can specify it using this argument. if the specified pid is not valid, the script will abort πŸ’€.
  • -p|--plugin=/full/path/to/pluginname.py β€” specify a plugin to use. the plugin must be a python file and must end in .py. it must specify a function called plugin and may specify functions called pre and post.
  • pluginname.arg1=value ... pluginname.argN=value β€” you can specify arguments to plugins on the command line. if there is a plugin specified as --plugin=/full/path/to/pluginname.py, the arguments for that plugin are specified as pluginname.argname=value. the script parses these arguments and passes them to the plugin pre function as a python dict. IF there is more than one argument named pluginname.argname the values are passed as a python list.

🧚 DIRECTORY SERVER NOTES 🧚

the directory server will usually need to be configured to log to the named pipe instead of the usual log file. for example, use the following LDIF to tell the server to use the file access.pipe for the access log:

dn: cn=config
changetype: modify
replace: nsslapd-accesslog-maxlogsperdir
nsslapd-accesslog-maxlogsperdir: 1
-
replace: nsslapd-accesslog-logexpirationtime
nsslapd-accesslog-logexpirationtime: -1
-
replace: nsslapd-accesslog-logrotationtime
nsslapd-accesslog-logrotationtime: -1
-
replace: nsslapd-accesslog
nsslapd-accesslog: /var/log/dirsrv/slapd-localhost/access.pipe
-
replace: nsslapd-accesslog-logbuffering
nsslapd-accesslog-logbuffering: off
NOTE: before doing this, you should save your current configuration so you can restore it later πŸ™ˆ
ldapsearch ... -s base -b "cn=config" nsslapd-accesslog-maxlogsperdir
nsslapd-accesslog-logexpirationtime   nsslapd-accesslog-logrotationtime
nsslapd-accesslog > savedaccesslog.ldif

the error log and audit log have similarly named configuration attributes e.g. nsslapd-errorlog, nsslapd-auditlog. note that the audit log is disabled by default β€” use nsslapd-auditlog-logging-enabled: on to enable it.


πŸ‘‘ AUTHOR πŸ‘‘

ds-logpipe.py was written by the 389 Project. slay.


πŸ› REPORTING BUGS πŸ›

report bugs to https://github.com/389ds/389-ds-base/issues/new β€” they wanna hear from you bestie πŸ’–


Copyright Β© 2018 Red Hat, Inc.

this is free software. you may redistribute copies of it under the terms of the Directory Server license found in the LICENSE file of this software distribution. this license is essentially the GNU General Public License version 2 with an exception for plug-in distribution.


and that's the whole thing, bestie β€” this page is dated March 31, 2017 and lives under the name DS-LOGPIPE.PY(1). go forth and pipe those logs πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from