Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chk_drbd_walk fails if backing_dev contains : characters #9

Open
xorpaul opened this issue Aug 27, 2021 · 0 comments
Open

chk_drbd_walk fails if backing_dev contains : characters #9

xorpaul opened this issue Aug 27, 2021 · 0 comments

Comments

@xorpaul
Copy link

xorpaul commented Aug 27, 2021

I have a backing_dev containing : characters, which then causes chk_drbd_walk to fail here at the split:
https://github.com/alaskacommunications/nagios_check_drbd9/blob/master/check_drbd9.pl#L687

   # parse device lines
   for $line (grep(/^exists[\s]+device/i, @lines))
   {
      $rec = {};
      %{$rec} = split(/[ :]/, $line);
      $resource = $resources->{$rec->{'name'}};
      $resource->{'devs'}->{$rec->{'volume'}} = $rec;
   };

Output of check:

# ~/check_drbd9.pl
Odd number of elements in hash assignment at /home/xorpaul/check_drbd9.pl line 689.
DRBD: 1 crit, 0 okay|
-
version:    9.0.29-1 (api:2/proto:86-120)
transports: (api:17): tcp (9.0.29-1)
resources:  1
-
r0 role:Secondary (CRIT)
Use of uninitialized value in division (/) at /home/xorpaul/check_drbd9.pl line 483.
Use of uninitialized value in printf at /home/xorpaul/check_drbd9.pl line 483.
vol:0 disk: minor:0 size:0MB
server.domain.tld role:Primary conn:Connected
Use of uninitialized value in division (/) at /home/xorpaul/check_drbd9.pl line 497.
Illegal division by zero at /home/xorpaul/check_drbd9.pl line 497.

Output of drbdsetup events2:

# /usr/sbin/drbdsetup events2 --now --statistics all 2> /dev/null
exists resource name:r0 role:Secondary suspended:no write-ordering:flush may_promote:no promotion_score:10102
exists connection name:r0 peer-node-id:1 conn-name:server.domain.tld connection:Connected role:Primary congested:no ap-in-flight:0 rs-in-flight:0
exists device name:r0 volume:0 minor:0 backing_dev:/dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:1:0 disk:UpToDate client:no quorum:yes size:5858739564 read:0 written:7958103 al-writes:9133 bm-writes:78 upper-pending:0 lower-pending:0 al-suspended:no blocked:no
exists peer-device name:r0 peer-node-id:1 conn-name:server.domain.tld volume:0 replication:Established peer-disk:UpToDate peer-client:no resync-suspended:no received:7958103 sent:0 out-of-sync:0 pending:0 unacked:0
exists path name:r0 peer-node-id:1 conn-name:server.domain.tld local:ipv4:127.0.0.1:7789 peer:ipv4:127.0.0.2:7789 established:yes
exists -

I currently have a frickelaround inplace, because my perl knowledge is limited and this was the fastest solution for me:

--- a/check_drbd9.pl
+++ b/check_drbd9.pl
@@ -684,6 +684,8 @@ sub chk_drbd_walk($)
    for $line (grep(/^exists[\s]+device/i, @lines))
    {
       $rec = {};
+      # frickelaround for backing_dev containing : characters
+      $line =~ s#/dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:1:0#none#ig;
       %{$rec} = split(/[ :]/, $line);
       $resource = $resources->{$rec->{'name'}};
       $resource->{'devs'}->{$rec->{'volume'}} = $rec;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant