2

In a shell script, we currently call /usr/sbin/pcs status cluster and then grep -qE for 'Current DC:.*partition with quorum' to find out if the cluster is fine.

I would like to know if there is a quicker way, because pcs status cluster makes it query all nodes for their PCSD status, which takes time, about a second and a half, and I want to do this check before doing certain operations which are to be done quite often.

Would pcs status nodes both and counting the number of online nodes be equally good for deciding if the cluster is functioning without issues?

This takes ~2 seconds: pcs status cluster 2>&1 | grep -qE 'Current DC:.*partition with quorum'

This takes ~0.2 seconds: pcs status nodes both | grep -cE 'Online: [a-z]+ [a-z]+ [a-z]+'

(The cluster has 5 nodes, hence the three node names in the regular expression).

EDIT:

This takes ~0.02 seconds: corosync-quorumtool 2>&1 | grep -q -E '^Quorate:.*Yes$'

Thank you Matt Kereczman!

MattBianco
  • 587
  • 1
  • 6
  • 23

1 Answers1

2

Assuming you're using Corosync, you can use corosync-quorumtool:

# corosync-quorumtool -s
  Quorum information
  ------------------
  Date:             Wed Sep 27 07:16:18 2017
  Quorum provider:  corosync_votequorum
  Nodes:            2
  Node ID:          1
  Ring ID:          76
  Quorate:          Yes

  Votequorum information
  ----------------------
  Expected votes:   2
  Highest expected: 2
  Total votes:      2
  Quorum:           1  
  Flags:            2Node Quorate WaitForAll 

  Membership information
  ----------------------
      Nodeid      Votes Name
           1          1 172.16.7.100 (local)
           2          1 172.16.7.101

EDIT: And then just check that Quorate reports Yes.

Matt Kereczman
  • 1,887
  • 8
  • 12