Re: [ClusterLabs] Antw: [EXT] Re: Parsing the output of crm_mon

2022-03-24 Thread Strahil Nikolov via Users
Also xmllint has '--xpath' (unless you are running something as old as RHEL6) 
and is available on every linux distro.
Best Regards,Strahil Nikolov
 
 
  On Mon, Mar 21, 2022 at 15:41, Ken Gaillot wrote:   On 
Mon, 2022-03-21 at 08:27 +0100, Ulrich Windl wrote:
> > > > Ken Gaillot  schrieb am 18.03.2022 um
> > > > 13:39 in
> Nachricht
> :
> > On Fri, 2022‑03‑18 at 08:46 +0100, Ulrich Windl wrote:
> > > Hi!
> > > 
> > > Parsing the output of crm_mon I wonder:
> > > Is there a collection of sample outputs for pacemaker 1 and 2
> > > formats
> > > showing all types of resources?
> > 
> > Ideally, any parsing should be done of the XML output generated by
> > ‑‑
> > output‑as=xml since 2.0.3 and ‑‑as‑xml before then (the output is
> > identical other than the outermost tag).
> 
> Agreed, but it's much trickier to parse XML with awk ;-)
> Maybe it' even less efficient (unless crm_mon itself is much more
> efficient
> when out putting XML)
> With XPath support, I might be able to create the output I need using
> xrm_mon
> only, but that's not implemented.
> 
> Regards,
> Ulrich

xmlstarlet can search xpaths, e.g.

crm_mon -1 --output-as=xml | xmlstarlet sel -t -v "//element/@attribute"

> 
> 
> > The XML output is stable and only gets backward‑compatible
> > additions
> > once in a long while, but the text output changes more frequently
> > and
> > significantly.
> > 
> > There's an RNG schema for it, api‑result.rng (where it's installed
> > depends on your build; in the source repository, make generates it
> > under xml/api).
> > 
> > > Also I realized that the coutput for clone sets in unfortunate:
> > > Consider a normal primitive like this:
> > >  * primitive_name    (ocf::heartbeat:agent_name):  Started
> > > host‑name
> > > And a clone set:
> > >  * Clone Set: clone_name [primitive_name]:
> > > 
> > > If you want to filter clone sets by resource agent you're lost
> > > there.
> > > It would have been nicht if the format of clone sets were:
> > >  * Clone Set: clone_name [primitive_name]
> > > (ocf::heartbeat:agent_name):
> > > 
> > > I see that there's the "‑R" option that "expands" the clones
> > > similar
> > > as resource groups like this:
> > >    * primitive_name    (ocf::heartbeat:agent):    Started
> > > host‑name
> > > 
> > > Regards,
> > > Ulrich
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > ___
> > > Manage your subscription:
> > > https://lists.clusterlabs.org/mailman/listinfo/users 
> > > 
> > > ClusterLabs home: https://www.clusterlabs.org/ 
> > > 
> > ‑‑ 
> > Ken Gaillot 
> > 
> > ___
> > Manage your subscription:
> > https://lists.clusterlabs.org/mailman/listinfo/users 
> > 
> > ClusterLabs home: https://www.clusterlabs.org/ 
> 
> 
> ___
> Manage your subscription:
> https://lists.clusterlabs.org/mailman/listinfo/users
> 
> ClusterLabs home: https://www.clusterlabs.org/
-- 
Ken Gaillot 

___
Manage your subscription:
https://lists.clusterlabs.org/mailman/listinfo/users

ClusterLabs home: https://www.clusterlabs.org/
  
___
Manage your subscription:
https://lists.clusterlabs.org/mailman/listinfo/users

ClusterLabs home: https://www.clusterlabs.org/


Re: [ClusterLabs] Antw: [EXT] Re: Parsing the output of crm_mon

2022-03-21 Thread Ken Gaillot
On Mon, 2022-03-21 at 08:27 +0100, Ulrich Windl wrote:
> > > > Ken Gaillot  schrieb am 18.03.2022 um
> > > > 13:39 in
> Nachricht
> :
> > On Fri, 2022‑03‑18 at 08:46 +0100, Ulrich Windl wrote:
> > > Hi!
> > > 
> > > Parsing the output of crm_mon I wonder:
> > > Is there a collection of sample outputs for pacemaker 1 and 2
> > > formats
> > > showing all types of resources?
> > 
> > Ideally, any parsing should be done of the XML output generated by
> > ‑‑
> > output‑as=xml since 2.0.3 and ‑‑as‑xml before then (the output is
> > identical other than the outermost tag).
> 
> Agreed, but it's much trickier to parse XML with awk ;-)
> Maybe it' even less efficient (unless crm_mon itself is much more
> efficient
> when out putting XML)
> With XPath support, I might be able to create the output I need using
> xrm_mon
> only, but that's not implemented.
> 
> Regards,
> Ulrich

xmlstarlet can search xpaths, e.g.

crm_mon -1 --output-as=xml | xmlstarlet sel -t -v "//element/@attribute"

> 
> 
> > The XML output is stable and only gets backward‑compatible
> > additions
> > once in a long while, but the text output changes more frequently
> > and
> > significantly.
> > 
> > There's an RNG schema for it, api‑result.rng (where it's installed
> > depends on your build; in the source repository, make generates it
> > under xml/api).
> > 
> > > Also I realized that the coutput for clone sets in unfortunate:
> > > Consider a normal primitive like this:
> > >   * primitive_name(ocf::heartbeat:agent_name):  Started
> > > host‑name
> > > And a clone set:
> > >   * Clone Set: clone_name [primitive_name]:
> > > 
> > > If you want to filter clone sets by resource agent you're lost
> > > there.
> > > It would have been nicht if the format of clone sets were:
> > >   * Clone Set: clone_name [primitive_name]
> > > (ocf::heartbeat:agent_name):
> > > 
> > > I see that there's the "‑R" option that "expands" the clones
> > > similar
> > > as resource groups like this:
> > > * primitive_name (ocf::heartbeat:agent):Started
> > > host‑name
> > > 
> > > Regards,
> > > Ulrich
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > ___
> > > Manage your subscription:
> > > https://lists.clusterlabs.org/mailman/listinfo/users 
> > > 
> > > ClusterLabs home: https://www.clusterlabs.org/ 
> > > 
> > ‑‑ 
> > Ken Gaillot 
> > 
> > ___
> > Manage your subscription:
> > https://lists.clusterlabs.org/mailman/listinfo/users 
> > 
> > ClusterLabs home: https://www.clusterlabs.org/ 
> 
> 
> ___
> Manage your subscription:
> https://lists.clusterlabs.org/mailman/listinfo/users
> 
> ClusterLabs home: https://www.clusterlabs.org/
-- 
Ken Gaillot 

___
Manage your subscription:
https://lists.clusterlabs.org/mailman/listinfo/users

ClusterLabs home: https://www.clusterlabs.org/


[ClusterLabs] Antw: [EXT] Re: Parsing the output of crm_mon

2022-03-21 Thread Ulrich Windl
>>> Ken Gaillot  schrieb am 18.03.2022 um 13:39 in
Nachricht
:
> On Fri, 2022‑03‑18 at 08:46 +0100, Ulrich Windl wrote:
>> Hi!
>> 
>> Parsing the output of crm_mon I wonder:
>> Is there a collection of sample outputs for pacemaker 1 and 2 formats
>> showing all types of resources?
> 
> Ideally, any parsing should be done of the XML output generated by ‑‑
> output‑as=xml since 2.0.3 and ‑‑as‑xml before then (the output is
> identical other than the outermost tag).

Agreed, but it's much trickier to parse XML with awk ;-)
Maybe it' even less efficient (unless crm_mon itself is much more efficient
when out putting XML)
With XPath support, I might be able to create the output I need using xrm_mon
only, but that's not implemented.

Regards,
Ulrich


> 
> The XML output is stable and only gets backward‑compatible additions
> once in a long while, but the text output changes more frequently and
> significantly.
> 
> There's an RNG schema for it, api‑result.rng (where it's installed
> depends on your build; in the source repository, make generates it
> under xml/api).
> 
>> 
>> Also I realized that the coutput for clone sets in unfortunate:
>> Consider a normal primitive like this:
>>   * primitive_name(ocf::heartbeat:agent_name):  Started host‑name
>> And a clone set:
>>   * Clone Set: clone_name [primitive_name]:
>> 
>> If you want to filter clone sets by resource agent you're lost there.
>> It would have been nicht if the format of clone sets were:
>>   * Clone Set: clone_name [primitive_name]
>> (ocf::heartbeat:agent_name):
>> 
>> I see that there's the "‑R" option that "expands" the clones similar
>> as resource groups like this:
>> * primitive_name (ocf::heartbeat:agent):Started host‑name
>> 
>> Regards,
>> Ulrich
>> 
>> 
>> 
>> 
>> 
>> 
>> ___
>> Manage your subscription:
>> https://lists.clusterlabs.org/mailman/listinfo/users 
>> 
>> ClusterLabs home: https://www.clusterlabs.org/ 
>> 
> ‑‑ 
> Ken Gaillot 
> 
> ___
> Manage your subscription:
> https://lists.clusterlabs.org/mailman/listinfo/users 
> 
> ClusterLabs home: https://www.clusterlabs.org/ 



___
Manage your subscription:
https://lists.clusterlabs.org/mailman/listinfo/users

ClusterLabs home: https://www.clusterlabs.org/


[ClusterLabs] Antw: [EXT] Re: Parsing the output of crm_mon

2022-03-18 Thread Ulrich Windl
>>> Reid Wahl  schrieb am 18.03.2022 um 10:02 in Nachricht
:
> On Fri, Mar 18, 2022 at 12:47 AM Ulrich Windl
>  wrote:
>>
>> Hi!
>>
>> Parsing the output of crm_mon I wonder:
>> Is there a collection of sample outputs for pacemaker 1 and 2 formats 
> showing all types of resources?
>>
>> Also I realized that the coutput for clone sets in unfortunate:
>> Consider a normal primitive like this:
>>   * primitive_name(ocf::heartbeat:agent_name):  Started host‑name
>> And a clone set:
>>   * Clone Set: clone_name [primitive_name]:
>>
>> If you want to filter clone sets by resource agent you're lost there.
>> It would have been nicht if the format of clone sets were:
>>   * Clone Set: clone_name [primitive_name] (ocf::heartbeat:agent_name):
>>
>> I see that there's the "‑R" option that "expands" the clones similar as 
> resource groups like this:
>> * primitive_name (ocf::heartbeat:agent):Started host‑name
> 
> What exactly are you asking for that "‑R" ("‑‑show‑detail") doesn't
provide?

Actually I found it out, but still it's a bit tricky to parse as clone
instance.
(The only difference from plain resources is the indent)

Regards,
Ulrich


> 
>> Regards,
>> Ulrich
>>
>>
>>
>>
>>
>>
>> ___
>> Manage your subscription:
>> https://lists.clusterlabs.org/mailman/listinfo/users 
>>
>> ClusterLabs home: https://www.clusterlabs.org/ 
>>
> 
> 
> ‑‑ 
> Regards,
> 
> Reid Wahl (He/Him), RHCA
> Senior Software Maintenance Engineer, Red Hat
> CEE ‑ Platform Support Delivery ‑ ClusterHA
> 
> ___
> Manage your subscription:
> https://lists.clusterlabs.org/mailman/listinfo/users 
> 
> ClusterLabs home: https://www.clusterlabs.org/ 



___
Manage your subscription:
https://lists.clusterlabs.org/mailman/listinfo/users

ClusterLabs home: https://www.clusterlabs.org/