HP-UX Directory Server Administrator Guide HP-UX Directory Server Version 8.1 (5900-3098, May 2013)

kill "$errpid" > /dev/null 2>&1
fi
fi
# only keep the last 1000 lines of the error log
python /opt/dirsrv/bin/ds-logpipe.py /var/opt/dirsrv/slapd-instance_name/log/errors.pipe -m 1000 -u nobody \
-s $RUN_DIR/slapd-instance_namev.pid \
-i $errpidfile >> /var/opt/dirsrv/slapd-instance_name/log/errors 2>&1 &
# sleep gives the script a chance to create the pipe, if necessary
sleep 1
accpidfile=$RUN_DIR/dslogpipe-srv-acc.pid
# see if there is already a logpipe running - doing a stop or
# restart (which first calls stop) should have made the old
# one exit, but let's make sure we kill it first
if [ -f $accpidfile ] ; then
accpid=`cat $accpidfile`
if [ -n "$accpid" ] ; then
kill "$accpid" > /dev/null 2>&1
fi
fi
# only log failed binds
python /opt/dirsrv/bin/ds-logpipe.py /var/opt/dirsrv/slapd-instance_name/log/access.pipe -u nobody \
-s $RUN_DIR/slapd-srv.pid \
-i $accpidfile --plugin=/opt/dirsrv/share/data/failedbinds.py \
failedbinds.logfile=/var/opt/dirsrv/slapd-instance_name/log/access.failedbinds &
# sleep gives the script a chance to create the pipe, if necessary
sleep 1
If -s $RUN_DIR/slapd-srv.pid argument is used, the script will exit when the server exits.
The server will write its PID to the file$RUN_DIR/slapd-srv.pid when it starts up. If the server
fails to start, the script will by default exit in 60 seconds. Use the -t parameter to specify a timeout
other than 60 seconds. The script has a PID file, specified with the -i argument. This prevents
two scripts from running at the same time.
Writing Plug-ins
Two default plug-ins are provided with the directory server. Custom plug-ins also can be used. The
plug-in must define a function called plugin, and may optionally define functions called pre and
post.
plugin function
The plugin function is called with each line of the log.
def plugin(line):
retval = True
# do something with line
if something_is_bogus:
retval = False
return retval
Here line is single line from the log and will have the newline (\n) character at the end of the line.
The plugin should normally return the value true. If the plugin detects some bad condition and
wants to abort the pipe script, it should return the value false.
pre function
The pre function is called when the plug-in is loaded and is passed the command line arguments
for the plug-in as a dict.
def pre(myargs):
retval = True
myarg = myargs['argname']
if isinstance(myarg, list): # handle list of values
else: # handle single value
if bad_problem:
retval = False
return retval
The command line arguments specified by pluginname.arg are passed into the pre function in
the dict argument. The argument name with the pluginname.arg is the dict key, and the dict
516 Monitoring Server and Database Activity