Skip to content

Commit

Permalink
Add possibilty to include stacked resources
Browse files Browse the repository at this point in the history
If option -s is specified then we include stacked resources in resources list. See alaskacommunications#4
  • Loading branch information
mayasd authored Feb 3, 2022
1 parent 08a8c16 commit b65c8d6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion check_drbd9.pl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ ()
printf STDERR (" -t display terse details\n");
printf STDERR (" -V display program version\n");
printf STDERR (" -v display OKAY resources\n");
printf STDERR (" -s include stacked resources\n");
printf STDERR (" -w state change specified state to 'WARN' (example: SyncTarget)\n");
printf STDERR (" -x pattern exclude resource name or resource minor\n");
printf STDERR ("\n");
Expand Down Expand Up @@ -383,7 +384,7 @@ ($)
$Getopt::Std::STANDARD_HELP_VERSION=1;

$opt = {};
if (!(getopts("0d:c:hi:lo:qtvVw:x:", $opt)))
if (!(getopts("0d:c:hi:lo:qtvVw:x:s", $opt)))
{
HELP_MESSAGE();
return(3);
Expand All @@ -402,6 +403,7 @@ ($)
$cnf->{'verbose'} = defined($opt->{'v'}) ? $opt->{'v'} : 0;
$cnf->{'list_all'} = defined($opt->{'l'}) ? $opt->{'l'} : 0;
$cnf->{'zero'} = defined($opt->{'0'}) ? $opt->{'0'} : 0;
$cnf->{'stacked'} = defined($opt->{'s'}) ? $opt->{'s'} : 0;

# override errors for okay
$list = defined($opt->{'o'}) ? $opt->{'o'} : '';
Expand Down Expand Up @@ -596,6 +598,7 @@ ($)
my $resource;
my $resources;
my $sh_resources;
my $stacked_resources;
my $line;
my $rec;
my @lines;
Expand Down Expand Up @@ -632,6 +635,12 @@ ($)

# builds resources
$sh_resources = `/usr/sbin/drbdadm sh-resources 2> /dev/null`;
if ($cnf->{'stacked'} != 0)
{
$stacked_resources = `/usr/sbin/drbdadm sh-resources --stacked 2> /dev/null`;
$sh_resources = $sh_resources . '' . $stacked_resources;
};

if ($? != 0)
{
printf("DRBD UNKNOWN: error running drbdadm\n");
Expand Down

0 comments on commit b65c8d6

Please sign in to comment.