[ClusterLabs] Antw: [EXT] Re: Q: effieciently collecting some cluster facts

Ulrich Windl Ulrich.Windl at rz.uni-regensburg.de
Fri Feb 26 07:00:47 EST 2021


>>> Christine Caulfield <ccaulfie at redhat.com> schrieb am 25.02.2021 um 08:22 in
Nachricht <52d91afa-9b89-4e2e-4663-b1ded39a032e at redhat.com>:
> The most efficient way of getting corosync facts about nodes/quorum is 
> to use the votequorum API.
> 
> see /usr/include/corosync/votequorum.h
> and in the corosync sources tarball tests/testvotequorum1.c
> 
> CHrissie
> 
> 
> On 25/02/2021 07:16, Ulrich Windl wrote:
>> Hi!
>> 
>> I'm thinking about some simple cluster status display that is updated 
> periodically.
>> I wonder how to get some "cluster facts" efficiently. Among those are:
>> 
>> * Is corosync running, and how many nodes can be seen?
>> * Is Pacemaker running, how many nodes does it see, and does it have a 
> quorum?
>> * Is the current node DC?

Hi!

It's probably not that efficient (and a bit paranoid), but basically I did this (bash, enjoy the quotes):
readonly CQT=/usr/sbin/corosync-quorumtool
if [ -x $CQT ]; then
    eval $($CQT 2>/dev/null | awk '
function assign(n, v) { print "readonly", n "=" "'\''" v "'\''" }
BEGIN { DID="000" }
NF < 2 { next }
$1 == "Nodes:" { assign("T_nodes", $2); next }
$1 == "Node" && NF == 3 && $2 == "ID:" { NID=$3; next }
$1 == "Ring" && NF == 3 && $2 == "ID:" {
   if (split($3, F, /\//) == 2) DID=F[1]
   next
}
$1 == "Quorate:" { assign("T_quorum", $2 == "Yes" ? "Q" : "_"); next }
$1 == "Total" && NF == 3 && $2 == "votes:" { assign("T_votes", $3); next }
$1 == "Membership" { nextfile }
END { assign("T_DC", NID == DID ? "D" : "_") }
')


>> * How many resources matching some regular expression are running?

I did this:
readonly CM=/usr/sbin/crm_mon
if [ -x $CM ]; then
    eval $($CM -1 --node="$HOSTNAME" 2>/dev/null | awk '
function assign(n, v) { print "readonly", n "=" "'\''" v "'\''" }
BEGIN { P="_"; NV=0 }
NF < 5 { next }
NF > 5 && $0 ~ /partition with quorum/ { P="P"; next }
$1 == "*" && NF == 5 && $4 == "Started" && $3 ~ /VirtualDomain):/ {
   ++NV; next
}
END { assign("Pstatus", P NV) }
')

When all glued together, I get a very cryptic status string like "h16:T[3QD]P7" fitting into the front panel LCD display of some popular server manufacturer ;-)

Regards,
Ulrich

>> 
>> Regards,
>> Ulrich
>> 
>> 
>> 
>> _______________________________________________
>> 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/ 






More information about the Users mailing list