ds-logpipe.py.1 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. .\" Hey, EMACS: -*- nroff -*-
  2. .\" First parameter, NAME, should be all caps
  3. .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
  4. .\" other parameters are allowed: see man(7), man(1)
  5. .TH DS-LOGPIPE.PY 1 "November 24, 2009"
  6. .\" Please adjust this date whenever revising the manpage.
  7. .\"
  8. .\" Some roff macros, for reference:
  9. .\" .nh disable hyphenation
  10. .\" .hy enable hyphenation
  11. .\" .ad l left justify
  12. .\" .ad b justify to both left and right margins
  13. .\" .nf disable filling
  14. .\" .fi enable filling
  15. .\" .br insert line break
  16. .\" .sp <n> insert n+1 empty lines
  17. .\" for manpage-specific macros, see man(7)
  18. .SH NAME
  19. ds-logpipe.py \- Create and read from a named pipe instead of a log file
  20. .SH SYNOPSIS
  21. .B ds\-logpipe.py
  22. /full/path/to/namedpipe
  23. [\fI-m maxlinestobuffer\fR] [\fI-u userid\fR] [\fI-s serverpidfile\fR] [\fI-t servertimeout\fR] [\fI--plugin=/path/to/pluginfile.py\fR] [\fIpluginfile.arg=value\fR]
  24. .PP
  25. .SH DESCRIPTION
  26. The Named Pipe Log Script allows you to replace a log file with a named pipe attached to a script. The server can then send the log output to a script instead of to a log file. This allows you to do many different things such as:
  27. * log only certain events e.g. failed binds, connections from certain ip addresses, etc.
  28. * log only lines that match a certain pattern
  29. * log only the last N lines - useful for enabling full error log debug levels in production environments
  30. * send an email or other notification when a certain event is detected
  31. The script is written in python, and allows plugins. By default, the script will log the last N lines (default 1000). There are two plugins provided - one to log only failed bind attempts, and one that will log only lines that match given regular expressions.
  32. .PP
  33. .\" TeX users may be more comfortable with the \fB<whatever>\fP and
  34. .\" \fI<whatever>\fP escape sequences to invode bold face and italics,
  35. .\" respectively.
  36. .SH OPTIONS
  37. A summary of options is included below.
  38. .TP
  39. .B /full/path/to/namedpipe
  40. Required - full path and file name of the named pipe. If this does not exist, it will be created. If it exists and is a named pipe, the script will use it. If it exists and is not a pipe, the script will abort. The ownership will be the same as the user running the script (or see the \-u option below).
  41. .TP
  42. .B \-m|\-\-maxlines=N
  43. Number of lines to buffer - default is 1000
  44. .TP
  45. .B \-u|\-\-userid=user
  46. 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.
  47. .TP
  48. .B \-s|\-\-serverpidfile=/path/to/servername.pid
  49. 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
  50. .TP
  51. .B \-t|\-\-servertimeout=N
  52. 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.
  53. .TP
  54. .B \-\-serverpid=P
  55. 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.
  56. .TP
  57. .B \-p|\-\-plugin=/full/path/to/pluginname.py
  58. Specify a plugin to use. The plugin must be a python file and must end in \fI.py\fR. It must specify a function called \fIplugin\fR and may specify functions called \fIpre\fR and \fIpost\fR.
  59. .TP
  60. .B pluginname.arg1=value ... pluginname.argN=value
  61. 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 \fIpluginname.argname=value\fR. The script parses these arguments and passes them to the plugin \fIpre\fR function as a python dict. IF there is more than one argument named \fIpluginname.argname\fR the values are passed as a python list.
  62. .SH DIRECTORY SERVER NOTES
  63. 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 \fIaccess.pipe\fR for the access log:
  64. dn: cn=config
  65. changetype: modify
  66. replace: nsslapd-accesslog-maxlogsperdir
  67. nsslapd-accesslog-maxlogsperdir: 1
  68. -
  69. replace: nsslapd-accesslog-logexpirationtime
  70. nsslapd-accesslog-logexpirationtime: \-1
  71. -
  72. replace: nsslapd-accesslog-logrotationtime
  73. nsslapd-accesslog-logrotationtime: \-1
  74. -
  75. replace: nsslapd-accesslog
  76. nsslapd-accesslog: /var/log/dirsrv/slapd-localhost/access.pipe
  77. -
  78. replace: nsslapd-accesslog-logbuffering
  79. nsslapd-accesslog-logbuffering: off
  80. NOTE: Before doing this, you should save your current configuration so you can restore it later.
  81. ldapsearch ... \-s base \-b "cn=config" nsslapd-accesslog-maxlogsperdir nsslapd-accesslog-logexpirationtime \
  82. nsslapd-accesslog-logrotationtime nsslapd-accesslog nsslapd-accesslog > savedaccesslog.ldif
  83. 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.
  84. .br
  85. .SH AUTHOR
  86. ds-logpipe.py was written by the 389 Project.
  87. .SH "REPORTING BUGS"
  88. Report bugs to http://bugzilla.redhat.com.
  89. .SH COPYRIGHT
  90. Copyright \(co 2009 Red Hat, Inc.
  91. .br
  92. This is free software. You may redistribute copies of it under the terms of
  93. the Directory Server license found in the LICENSE file of this
  94. software distribution. This license is essentially the GNU General Public
  95. License version 2 with an exception for plug-in distribution.