Skip to content
Snippets Groups Projects
Commit daf8e327 authored by Mathieu Alorent's avatar Mathieu Alorent
Browse files

Initial release

parents
No related branches found
No related tags found
No related merge requests found
Revision history for Parse-Arcconf
0.01 Date/time
First version, released on an unsuspecting world.
Changes
MANIFEST
Makefile.PL
README
lib/Parse/Arcconf.pm
t/00-load.t
t/manifest.t
t/pod-coverage.t
t/pod.t
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Parse::Arcconf',
AUTHOR => q{Mathieu Alorent <kumy@cpan.org>},
VERSION_FROM => 'lib/Parse/Arcconf.pm',
ABSTRACT_FROM => 'lib/Parse/Arcconf.pm',
($ExtUtils::MakeMaker::VERSION >= 6.3002
? ('LICENSE'=> 'perl')
: ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Parse-Arcconf-*' },
);
README 0 → 100644
Parse-Arcconf
DESCRIPTION
Parse::Arcconf parses the output of "arcconf" utility to allow programmatic
access to the RAID configuration information provided by the arcconf utility
on Adaptec RAID cards.
INSTALLATION
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the
perldoc command.
perldoc Parse::Arcconf
You can also look for information at:
RT, CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Parse-Arcconf
AnnoCPAN, Annotated CPAN documentation
http://annocpan.org/dist/Parse-Arcconf
CPAN Ratings
http://cpanratings.perl.org/d/Parse-Arcconf
Search CPAN
http://search.cpan.org/dist/Parse-Arcconf/
LICENSE AND COPYRIGHT
Copyright (C) 2012 Mathieu Alorent
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
blib*
Makefile
Makefile.old
Build
Build.bat
_build*
pm_to_blib*
*.tar.gz
.lwpcookies
cover_db
pod2htm*.tmp
Parse-Arcconf-*
#!/usr/bin/perl -w
# Copyright 2012 Mathieu Alorent.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of either: the GNU General Public License as published
# by the Free Software Foundation; or the Artistic License.
#
# See http://dev.perl.org/licenses/ for more information.
package Parse::Arcconf;
use warnings;
use strict;
=head1 NAME
Parse::Arcconf - Parse the output of arcconf utility.
=head1 VERSION
Version 0.01
=cut
our $VERSION = '0.01';
=head1 SYNOPSIS
Parse::Arcconf parses the output of C<arcconf> utility to allow
programmatic access to the RAID configuration information provided by the
arcconf utility on Adaptec RAID cards.
use Parse::Arcconf;
my $arcconf = Parse::Arcconf->new();
Run the C<arcconf> tool directly to query the hardware (requires root):
my $controllers = $arcconf->parse_config();
Parse a text file created already by running C<arcconf> tool:
my $controllers = $arcconf->parse_config_file("foo.txt");
Read from a file descriptor already opened by the program:
my $controllers = $arcconf->parse_config_fh(\*STDIN);
=head1 SUBROUTINES/METHODS
=head2 new
Return an instance of the Parse::Arcconf class that can be used to parse
input in one of several ways.
=cut
sub new
{
my ($class, $config, $plugin) = @_;
my $self = {};
bless($self, $class);
return $self;
}
=head2 parse_config
Attempt to run the arcconf utility, and parse the output. This command
actually uses parse_config_fh() after opening a pipe to the relevant command.
The command that is actually run is approximately:
=over 4
arcconf GETCONFIG 1
=back
This command requires root access, and Parse::Arcconf makes no attempt to
use sudo or any other method to gain root access. It is recommended to call
your script which uses this module as root.
The parse_config_fh() and parse_config_file() will expect output equivalent
to that from the above command.
=cut
sub parse_config
{
my ($self) = @_;
my $arcconf = "/usr/sbin/arcconf";
my $argument = "GETCONFIG 1";
my $command = sprintf("%s %s|", $arcconf, $argument);
my $fh;
if(open $fh, $command)
{
my $c = $self->parse_config_fh($fh);
close $fh;
return $c;
}
return undef;
}
=head2 parse_config_file
Open and parse a file containing the output from arcconf.
=cut
sub parse_config_file
{
my ($self, $file) = @_;
my $fh;
if(open $fh, "<".$file)
{
my $c = $self->parse_config_fh($fh);
close $fh;
return $c;
}
return undef;
}
=head2 parse_config_fh
Read from the file handle and parse it, returning a hash-of-hashes.
=cut
sub parse_config_fh
{
my ($self, $fh) = @_;
my $controller = {};
my $total_controller = 0;
my $current_controller = 0;
my $current_logical_drive = undef;
my $current_physical_drive = undef;
my $ctrl = undef;
my $line = undef;
LEVEL1: while($line = <$fh>)
{
chomp $line;
next if($line =~ /^$/);
next if($line =~ /^-+$/);
if($line =~ /^Controllers found: (\d+)$/) {
$total_controller = $1;
}
if($line =~ /^Controller information/) {
$current_controller = $current_controller + 1;
$current_logical_drive = undef;
$current_physical_drive = undef;
$controller->{$current_controller} = {};
$ctrl = $controller->{$current_controller};
while($line = <$fh>) {
chomp $line;
if ($line =~ /^\s+(.*\w)\s+:\s+(.*)$/) {
$ctrl->{$1} = $2;
} elsif ($line =~ /^\s+-+$/) {
last;
}
}
LEVEL2: while($line = <$fh>) {
if ($line =~ /^\s+-+$/) {
$line = <$fh>;
chomp $line;
}
if($line =~ /^\s+(.*\w)\s*/) {
my $cat = $1;
$line = <$fh>;
LEVEL3: while($line = <$fh>) {
chomp $line;
if ($line =~ /^\s+(.*\w)\s+:\s+(.*)$/) {
$ctrl->{$cat}{$1} = $2;
} elsif ($line =~ /^\s+-+$/) {
last LEVEL3;
} elsif ($line =~ /^$/) {
last LEVEL2;
}
}
}
}
}
next if(!defined($current_controller));
if($line =~ /^Logical drive information/) {
LEVEL4: while($line = <$fh>) {
chomp $line;
if ($line =~ /^\S+.*\w\s+(\d+)$/) {
$current_logical_drive = $1;
} elsif ($line =~ /^\s+(\S.*\S+)\s+:\s+(.*)$/) {
$ctrl->{'logical drive'}{$current_logical_drive}{$1} = $2;
} elsif ($line =~ /^\s+-+$/) {
my $cat = <$fh>;
$cat =~ s/^\s+(\S.*\S+)\s+/\1/;
chomp $cat;
LEVEL5: while($line = <$fh>) {
chomp $line;
if ($line =~ /^\s+(\S.*\S+)\s+:\s+(.*)$/) {
$ctrl->{'logical drive'}{$current_logical_drive}{$cat}{$1} = $2;
} elsif ($line =~ /^\S+.*\w\s+(\d+)$/) {
$current_logical_drive = $1;
last LEVEL5;
} elsif ($line =~ /^$/) {
last LEVEL4;
} elsif ($line =~ /^\s+-+$/) {
next;
}
}
}
}
}
if($line =~ /^Physical Device information/) {
LEVEL2: while($line = <$fh>) {
if ($line =~ /^\s+-+$/) {
$line = <$fh>;
chomp $line;
}
if ($line =~ /^\s+Device\s+#(\d+)$/) {
$current_physical_drive = $1;
} elsif ($line =~ /^\s+Device is (.*\w)/) {
$ctrl->{'physical drive'}{$current_physical_drive}{'Device is'} = $1;
} elsif ($line =~ /^\s+(.*\w)\s+:\s+(.*)$/) {
$ctrl->{'physical drive'}{$current_physical_drive}{$1} = $2;
} elsif ($line =~ /^\s+-+$/) {
last LEVEL3;
} elsif ($line =~ /^$/) {
last LEVEL2;
}
}
}
}
return $controller;
}
=head1 AUTHOR
Mathieu Alorent, C<< <kumy at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-parse-arcconf at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Parse-Arcconf>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Parse::Arcconf
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Parse-Arcconf>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Parse-Arcconf>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/Parse-Arcconf>
=item * Search CPAN
L<http://search.cpan.org/dist/Parse-Arcconf/>
=back
=head1 ACKNOWLEDGEMENTS
=head1 LICENSE AND COPYRIGHT
Copyright 2012 Mathieu Alorent.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
This program is based on Parse::HP::ACU a work of Jeremy Cole.
=cut
1; # End of Parse::Arcconf
#!perl -T
use Test::More tests => 1;
BEGIN {
use_ok( 'Parse::Arcconf' ) || print "Bail out!
";
}
diag( "Testing Parse::Arcconf $Parse::Arcconf::VERSION, Perl $], $^X" );
#!perl -T
use Parse::Arcconf;
use strict;
my $arcconf = Parse::Arcconf->new();
$arcconf->parse_config_file("output.txt");
ok($arcconf, "Created new Reprepro::Uploaders object");
#!perl -T
use strict;
use warnings;
use Test::More tests => 3;
sub not_in_file_ok {
my ($filename, %regex) = @_;
open( my $fh, '<', $filename )
or die "couldn't open $filename for reading: $!";
my %violated;
while (my $line = <$fh>) {
while (my ($desc, $regex) = each %regex) {
if ($line =~ $regex) {
push @{$violated{$desc}||=[]}, $.;
}
}
}
if (%violated) {
fail("$filename contains boilerplate text");
diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
} else {
pass("$filename contains no boilerplate text");
}
}
sub module_boilerplate_ok {
my ($module) = @_;
not_in_file_ok($module =>
'the great new $MODULENAME' => qr/ - The great new /,
'boilerplate description' => qr/Quick summary of what the module/,
'stub function definition' => qr/function[12]/,
);
}
TODO: {
local $TODO = "Need to replace the boilerplate text";
not_in_file_ok(README =>
"The README is used..." => qr/The README is used/,
"'version information here'" => qr/to provide version information/,
);
not_in_file_ok(Changes =>
"placeholder date/time" => qr(Date/time)
);
module_boilerplate_ok('lib/Parse/Arcconf.pm');
}
#!perl -T
use strict;
use warnings;
use Test::More;
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
eval "use Test::CheckManifest 0.9";
plan skip_all => "Test::CheckManifest 0.9 required" if $@;
ok_manifest();
Controllers found: 1
----------------------------------------------------------------------
Controller information
----------------------------------------------------------------------
Controller Status : Okay
Channel description : SAS/SATA
Controller Model : IBM ServeRAID 8i
Controller Serial Number : 143FCA
Physical Slot : 0
Installed memory : 256 MB
Copyback : Disabled
Data scrubbing : Enabled
Automatic Failover : Enabled
Defunct disk drive count : 0
Logical drives/Offline/Critical : 1/0/0
--------------------------------------------------------
Controller Version Information
--------------------------------------------------------
BIOS : 5.2-0 (17002)
Firmware : 5.2-0 (17002)
Driver : 1.1-5 (2461)
Boot Flash : 5.2-0 (17002)
--------------------------------------------------------
Controller Battery Information
--------------------------------------------------------
Status : Okay
Over temperature : No
Capacity remaining : 100 percent
Time remaining (at current draw) : 3 days, 5 hours, 20 minutes
--------------------------------------------------------
Controller Vital Product Data
--------------------------------------------------------
VPD Assigned# : 13N2230
EC Version# : H19036
Controller FRU# : 13N2233
Battery FRU# : 13N2256
----------------------------------------------------------------------
Logical drive information
----------------------------------------------------------------------
Logical drive number 0
Logical drive name : A
RAID level : 5
Status of logical drive : Okay
Size : 349500 MB
Stripe-unit size : 256 KB
Read-cache mode : Enabled
Write-cache mode : Enabled (write-back)
Write-cache setting : Enabled (write-back) when protected by battery
Partitioned : Yes
Protected by Hot-Spare : No
Bootable : Yes
Defunct stripes : No
--------------------------------------------------------
Logical drive segment information
--------------------------------------------------------
Segment 0 : Present (0,0) 3NP264SH
Segment 1 : Present (0,1) BSF000ME
Segment 2 : Present (0,2) 3NP27QHY
Segment 3 : Present (0,4) 3NP264L8
Segment 4 : Present (0,5) 3NP27R6E
Segment 5 : Present (0,6) P2X7BP5A
Logical drive number 1
Logical drive name : B
RAID level : 5
Status of logical drive : Okay
Size : 349500 MB
Stripe-unit size : 256 KB
Read-cache mode : Enabled
Write-cache mode : Enabled (write-back)
Write-cache setting : Enabled (write-back) when protected by battery
Partitioned : Yes
Protected by Hot-Spare : No
Bootable : Yes
Defunct stripes : No
--------------------------------------------------------
Logical drive segment information
--------------------------------------------------------
Segment 0 : Present (1,0) 3NP264SH
Segment 1 : Present (1,1) BSF000ME
Segment 2 : Present (1,2) 3NP27QHY
Segment 3 : Present (1,4) 3NP264L8
Segment 4 : Present (1,5) 3NP27R6E
Segment 5 : Present (1,6) P2X7BP5A
----------------------------------------------------------------------
Physical Device information
----------------------------------------------------------------------
Device #0
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,0
Reported Location : Enclosure 0, Slot 0
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP264SH
World-wide name : 5000C5000776E700
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #1
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,1
Reported Location : Enclosure 0, Slot 1
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : MBB2073RC
Firmware : SB01
Serial number : BSF000ME
World-wide name : 500000E018743C11
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #2
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,2
Reported Location : Enclosure 0, Slot 2
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP27QHY
World-wide name : 5000C500077A2EB8
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #3
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,4
Reported Location : Enclosure 0, Slot 3
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP264L8
World-wide name : 5000C5000776E418
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #4
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,5
Reported Location : Enclosure 0, Slot 4
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP27R6E
World-wide name : 5000C500077A2F08
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #5
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,6
Reported Location : Enclosure 0, Slot 5
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : CBRBA073C3ETS0 N
Firmware : C49B
Serial number : P2X7BP5A
World-wide name : 5000CCA0007E25DB
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 39R7366
PFA : No
Device #6
Device is an Enclosure services device
Reported Channel,Device : 2,0
Enclosure ID : 0
Type : SES2
Vendor : IBM
Model : SAS SES-2 DEVICE
Firmware : 0.09
Status of Enclosure services device
Temperature : Normal
Device #7
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,0
Reported Location : Enclosure 0, Slot 0
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP264SH
World-wide name : 5000C5000776E700
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #8
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,1
Reported Location : Enclosure 0, Slot 1
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : MBB2073RC
Firmware : SB01
Serial number : BSF000ME
World-wide name : 500000E018743C11
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #9
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,2
Reported Location : Enclosure 0, Slot 2
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP27QHY
World-wide name : 5000C500077A2EB8
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #10
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,4
Reported Location : Enclosure 0, Slot 3
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP264L8
World-wide name : 5000C5000776E418
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #11
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,5
Reported Location : Enclosure 0, Slot 4
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : ST973402SS
Firmware : B522
Serial number : 3NP27R6E
World-wide name : 5000C500077A2F08
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 26K5779
PFA : No
Device #12
Device is a Hard drive
State : Online
Supported : Yes
Transfer Speed : SAS 3.0 Gb/s
Reported Channel,Device : 0,6
Reported Location : Enclosure 0, Slot 5
Reported ESD : 2,0
Vendor : IBM-ESXS
Model : CBRBA073C3ETS0 N
Firmware : C49B
Serial number : P2X7BP5A
World-wide name : 5000CCA0007E25DB
Size : 70006 MB
Write Cache : Disabled (write-through)
FRU : 39R7366
PFA : No
Device #13
Device is an Enclosure services device
Reported Channel,Device : 2,0
Enclosure ID : 0
Type : SES2
Vendor : IBM
Model : SAS SES-2 DEVICE
Firmware : 0.09
Status of Enclosure services device
Temperature : Normal
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;
all_pod_coverage_ok();
t/pod.t 0 → 100644
#!perl -T
use strict;
use warnings;
use Test::More;
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
all_pod_files_ok();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment