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!
Assuming you're using Corosync, you can use
corosync-quorumtool
:EDIT: And then just check that
Quorate
reportsYes
.