IS_DRBDTWOPRIMARIES Wrong check when using drbdadm status #151

Closed
opened 2023-11-28 17:42:24 +01:00 by abenmiloud · 1 comment
Owner

Hi,

It looks like the check is wrong check when using drbdadm status.

Here is the problematic line¹:

            if drbdadm status | grep Primary -A2 | grep peer | grep -q Primary; then

The script should seek this specific pattern:

<resource> role: Primary
  peer role: Primary

The following, longer, command should do the trick:

            if drbdadm status | awk '/^[[:graph:]]+ role:Primary$/ { r = $1 } /^ +peer role:Primary$/ { if (r) rc = 1 } END { exit rc }'

Another simpler solution:

            if drbdadm role all | grep 'Primary/Primary'

¹

if drbdadm status | grep Primary -A2 | grep peer | grep -q Primary; then

Hi, It looks like the check is wrong check when using `drbdadm status`. Here is the problematic line¹: ```bash if drbdadm status | grep Primary -A2 | grep peer | grep -q Primary; then ``` The script should seek this specific pattern: ``` <resource> role: Primary peer role: Primary ``` The following, longer, command should do the trick: ```bash if drbdadm status | awk '/^[[:graph:]]+ role:Primary$/ { r = $1 } /^ +peer role:Primary$/ { if (r) rc = 1 } END { exit rc }' ``` Another simpler solution: ```bash if drbdadm role all | grep 'Primary/Primary' ``` ¹ https://gitea.evolix.org/evolix/evocheck/src/commit/7041505446da4ab48cf295a229f7deb7a392be08/linux/evocheck.sh#L885
Owner

The simpler solution seems to be more robust than you awk one-liner. It also seems to works in all supported versions of Debian and should therefor be the only solution used so as to simplify the logic of this check.

The simpler solution seems to be more robust than you awk one-liner. It also seems to works in all supported versions of Debian and should therefor be the only solution used so as to simplify the logic of this check.
mtrossevin added the
bug
label 2023-11-28 17:47:54 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: evolix/evocheck#151
No description provided.