[Pacemaker] Querying resource status programatically
Andrew Beekhof
andrew at beekhof.net
Mon Feb 23 00:39:22 UTC 2015
> On 7 Feb 2015, at 3:01 pm, Brian Campbell <brian.campbell at editshare.com> wrote:
>
> Hi all!
>
> I'm writing a domain-specific frontend for Pacemaker, which can set up
> a few different pre-configured "stacks" of resources, and provide
> simplified monitoring and administration of those stacks.
>
> One thing I'm wondering about is the correct way to query for the
> current status of a particular resource. It appears that using
> "crm_mon --as-xml" should give me the information I need in the
> <resources> section:
>
> <resources>
> <resource
> id="editshare.stack.d11f9ebd-9f1b-4547-a7f2-ab92caab1450.ip"
> resource_agent="ocf::heartbeat:IPaddr2" role="Started" active="true"
> orphaned="false" managed="true" failed="false" failure_ignored="false"
> nodes_running_on="1" >
> <node name="lambda-es7-cluster1" id="1" cached="false"/>
> </resource>
> </resources>
>
> However, I could not find any specification for the schema supported
> by crm_mon, so I'm wondering if this format can be considered stable.
I've made a node to add documentation (and probably a .rng schema) for this output format.
You can consider it stable in the normal XML sense of the word.
Fields might get added or the order altered, but once you've parsed it into a tree those changes shouldn't matter.
>
> It looks like it may be possible to parse this information out of the
> CIB, but that involves the "Here be dragons" status section, and would
> involve walking through the history to track the state of the resource
> up to the present time. It seems like that would be possible by
> walking through the history, checking that the last operations on a
> node were a "start" or "promote" with the appropriate exit code,
> followed by "monitor" operations with the appropriate exit code. But
> that seems like a bit of a roundabout way of determining the status.
>
> There is also the crm_resource command, but that seems to provide
> human-readable output, even if I use the XML output options, not
> parseable output. I could do custom parsing of the output of that, but
> that seems fragile.
>
> Taking a look at what crm_resource and crm_mon actually do to query
> the state, they seem to be connecting via a libqb RPC connection,
> which is not a terribly convenient thing or safe thing to do from my
> code.
>
> Taking a look at pcs, it looks like that does query both crm_mon for
> status, and cibadmin for the configuration state, so that seems to
> heavily imply that's the right way to query this information.
>
> So is querying crm_mon the most authoritative way to query a resource
> state? Tracking the state in the status section of the CIB as
> retrieved from cibadmin? Parsing crm_resource? Or some other way that
> I'm missing?
>
> -- Brian
>
> _______________________________________________
> Pacemaker mailing list: Pacemaker at oss.clusterlabs.org
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
>
> Project Home: http://www.clusterlabs.org
> Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://bugs.clusterlabs.org
More information about the Pacemaker
mailing list