[ClusterLabs] Antw: [EXT] Coming in Pacemaker 2.0.4: crm_mon --include/--exclude

Ulrich Windl Ulrich.Windl at rz.uni-regensburg.de
Wed Mar 18 03:00:23 EDT 2020


>>> Ken Gaillot <kgaillot at redhat.com> schrieb am 17.03.2020 um 20:19 in
Nachricht
<31623_1584472757_5E7122B5_31623_654_1_77d5d0b6b2a46001f57b1739763373209183bec6.
amel at redhat.com>:
> Hi everybody,
> 
> I hope this message finds you well.
> 
> A feature discussed at the ClusterLabs Summit (mere weeks and a
> lifetime ago in Brno ...) is in the master branch and will be part of
> the Pacemaker 2.0.4 release. The first release candidate is expected in
> about a month.
> 
> The crm_mon tool for showing cluster status will have ‑‑include and ‑‑
> exclude options to pick and choose which types of information you want
> it to display.
> 
> ###
> 
>     ‑I, ‑‑include=SECTION(s)
>         A list of sections to include in the output.  See `Output
> Control` help for more information.
> 
>     ‑U, ‑‑exclude=SECTION(s)
>         A list of sections to exclude from the output.  See `Output
> Control` help for more information.
> 
> ...
> 
> OUTPUT CONTROL
> 
> By default, a certain list of sections are written to the output
> destination. The default varies based on the output format ‑ XML
> includes everything, while other output formats will display less. This
> list can be modified with the ‑‑include and ‑‑exclude command line
> options.  Each option may be given multiple times on the command line, 
> and each can give  a  comma‑separated  list  of  sections. The options 
> are applied to the default set, from left to right as seen on the
> command line. For a list of valid sections, pass ‑‑include=list or ‑‑
> exclude=list.
> 
> % crm_mon ‑‑include=list
> ...
> crm_mon: ‑‑include options: all, attributes, bans[:PREFIX], counts, dc,
> default, failcounts, failures, fencing, fencing‑failed, fencing‑
> pending, fencing‑succeeded, nodes, none, operations, options,
> resources, stack, summary, tickets, times
> 
> ###
> 
> For example if you say
> 
>    crm_mon ‑‑include=tickets
> 
> you will get all the usual information shown, plus booth ticket
> constraints. If you say
> 
>    crm_mon ‑‑include=none,tickets
> 
> then only tickets will be shown. If you say
> 
>    crm_mon ‑‑exclude=resources

Accidentially I had recently written a program that allows changing parameters
that are of "array type" dynamically, and I had wondered for quite some time
how to do it.
Eventually I came upwith this syntax (let"<SEP>" be any separator your like):
=<SEP>item[<SEP>item]...	# replace the previous contents with the new
one
+<SEP>item[<SEP>item]...	# append the new contents to the existing one
(duplicated possible)
-<SEP>item[<SEP>item]...	# remove all of the given items from the
existing values if present; warn about values that weren't present

Thus I avoided to have multiple operations to update the list value, while I
think the expression syntax is powerful enough to get the configuratioins one
wants.

The Per(i)l-ish code looks like this:

    $update_mode = shift(@newvals);
    if ($update_mode eq '=') {  # replace
        return ($setter->(\@newvals));
    } elsif ($update_mode eq '+') {     # append
        unshift(@newvals, @{$getter->()});
        return ($setter->(\@newvals));
    } elsif ($update_mode eq '-') {     # remove
        my %agenda = map { $_ => undef } @newvals;

        @newvals = ();
        foreach (@{$getter->()}) {
            unless (exists($agenda{$_})) {
                $lc->verbose(3, "$me: keeping " . _string($_));
                push(@newvals, $_);
            } else {
                $lc->verbose(3, "$me: removing " . _string($_));
                delete $agenda{$_};
            }
        }
        if (scalar(my @not_found = keys %agenda) > 0) {
            @not_found = map { $_->as_string() } @not_found
                if ($not_found[0]->can('as_string'));
            $lc->notice("$me: failed to remove ". join(' ', @not_found));
        }
        return ($setter->(\@newvals));
    } else {
        $lc->error("$me: invalid array update mode ${update_mode}");
        return ($getter->());
    }

(And my program can also print the current values ;-))

Regards,
Ulrich

> 
> then the top summary, nodes, failures, etc. will still be shown but
> active resources will not.
> 
> This is expected to be especially helpful for clusters with a lot of
> nodes or resources, and for scripts and tools parsing the output (the
> options apply to XML output as well as human‑friendly).
> ‑‑ 
> Ken Gaillot <kgaillot at redhat.com>
> 
> _______________________________________________
> Manage your subscription:
> https://lists.clusterlabs.org/mailman/listinfo/users 
> 
> ClusterLabs home: https://www.clusterlabs.org/ 





More information about the Users mailing list