Skip to content

Commit

Permalink
Checking Output of arcconf with backticks
Browse files Browse the repository at this point in the history
  • Loading branch information
fnemeth committed Mar 15, 2013
1 parent 38254d8 commit f9f9268
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .includepath
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<includepath />

17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>check_adaptec_raid</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.epic.perleditor.perlbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.epic.perleditor.perlnature</nature>
</natures>
</projectDescription>
42 changes: 26 additions & 16 deletions check_adaptec_raid
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use IPC::Run3;
use Data::Dumper;

our $verbosity = 0;
our $version = "0.0";

our $VERBOSITY = 0;
our $VERSION = '0.0';

use constant {
STATE_OK => 0,
Expand All @@ -26,12 +28,18 @@ sub displayHelp {
}

sub displayVersion {
# Get arcconf version, controller name, + version of plugin
# Get arcconf VERSION, controller name, + VERSION of plugin
}


sub getAdapCfg {

my $sudo = $_[0];
my $arcconf = $_[1];
my $controller = $_[2];
my @output = `$sudo $arcconf GETCONFIG $controller AD`; #seems to parse every line in its own variable
print Dumper(@output) if $VERBOSITY == 3;

}

sub getPhysCfg {
Expand All @@ -43,30 +51,32 @@ sub getLogCfg {
}


sub exit {

sub myExit {
print $_[1];
exit ($_[2]);
}

MAIN: {
my $controller = 1;
my @logDevices;
my @physDevices;
my $sudo = "/usr/bin/sudo"; #check_arc all nopasswd: /usr/bin/arcconf GETCONFIG *
my $arcconf = "/usr/bin/arcconf";
my $sudo = '/usr/bin/sudo'; #check_arc all nopasswd: /usr/bin/arcconf GETCONFIG *
my $arcconf = '/usr/bin/arcconf';

unless ( -e $arcconf or -x $sudo ) { print "Perm. denied!"; die; }
unless ( -e $arcconf or -x $sudo ) { print 'Perm. denied!'; die; }

if ( !(GetOptions(
"v|verbose" => sub {$verbosity = 1 },
"vv" => sub {$verbosity = 2},
"vvv" => sub {$verbosity = 3},
"h|help" => sub {displayHelp();},
"V|version" => sub {displayVersion();},
"C|controller=i" => \$controller,
"LD|logicaldevice=i@" => \@logDevices,
"PD|physicaldevice=i@" => \@physDevices,
'v|verbose' => sub {$VERBOSITY = 1 },
'vv' => sub {$VERBOSITY = 2},
'vvv' => sub {$VERBOSITY = 3},
'h|help' => sub {displayHelp();},
'V|version' => sub {displayVersion();},
'C|controller=i' => \$controller,
'LD|logicaldevice=i@' => \@logDevices,
'PD|physicaldevice=i@' => \@physDevices,

))) {
displayUsage();
}
getAdapCfg($sudo, $arcconf, $controller);
}

0 comments on commit f9f9268

Please sign in to comment.