[Linux-cluster] logging from the resource agent script

Ofer Inbar cos at aaaaa.org
Tue Aug 24 00:38:16 UTC 2010


I'm setting up a custom service under RHCS on 5.3, for which I'm using
custom resource agent script developed by me and a coworker.  Neither
of us were able to find any real documentation on how to do this, so
we've just worked by using the supplied scripts in /usr/share/cluster
as templates, guessing, trial and error, and reading the shared functions.

It works, but I still have a lot of questions about how to do things.

Right now, the question that's vexing me is how to log custom messages
from this resource agent script, to give the operator more information
about what the cluster is doing (such as, for example, the exact
commands that are run when starting and stopping the service, or what
the real return code from the health check is, rather than just "did
it fail?").

Instead of adding some code to log completely independently of RHCS,
it seems like I could just call ocf_log, which the other cluster
shell functions use to log.  However, this turns out not to work well:

1. ocf_log statements I put at the top level of the script do log,
but any that I put inside functions such as start() and stop() don't.
Why don't my custom log messages appear in /var/log/messages when
other messages at the same level (such as info or notice) from
rgmanager do, and when the start() or stop() function is clearly being
called?

2. ocf_log seems to sometimes, or always, output to stdout, which
means I have to take care *not* to let it run when meta-data is the
argument, because it'd pollute the metadata XML.  But then how do I
log anything from the times the script is run for metadata, if I want?

Should this work?  Is there another, better way of making resource
agent scripts log custom messages?

And what happens to the resource agent script's stdout, anyway?
  -- Cos




More information about the Linux-cluster mailing list