File: ServeRaid.pm

package info (click to toggle)
ocsinventory-agent 2%3A2.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,424 kB
  • sloc: perl: 26,492; xml: 773; objc: 528; sh: 386; ansic: 333; makefile: 12
file content (104 lines) | stat: -rw-r--r-- 3,788 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package Ocsinventory::Agent::Backend::OS::Linux::Storages::ServeRaid;

use Ocsinventory::Agent::Backend::OS::Linux::Storages;

# Tested on 2.6.* kernels
#
# Cards tested :
#
# IBM ServeRAID-6M 
# IBM ServeRAID-6i

use strict;

sub check {
    my $params = shift;
    my $common = $params->{common};

    my $ret = 0;

    # Do we have ipssend installed ?
      if ($common->can_run("ipssend")) {
            foreach (`ipssend GETVERSION 2>/dev/null`) {
                   if (/.*ServeRAID Controller Number\s(\d*).*/) {
                            $ret = $1;
                            last;
                        } 
        }
      }
    return $ret;
}

sub run {

    my $params = shift;
    my $common = $params->{common};
    my $logger = $params->{logger};
    my $slot;

    $logger->debug("ServeRaid: ipssend GETVERSION");
    foreach (`ipssend GETVERSION 2>/dev/null`) {
        # Example Output :
        # Found 1 IBM ServeRAID controller(s).
        #----------------------------------------------------------------------
        #ServeRAID Controller(s) Version Information
        #----------------------------------------------------------------------
        #   Controlling BIOS version       : 7.00.14
        #
        #ServeRAID Controller Number 1
        #   Controller type                : ServeRAID-6M
        #   Controller slot information    : 2
        #   Actual BIOS version            : 7.00.14
        #   Firmware version               : 7.00.14
        #   Device driver version          : 7.10.18

        $slot = $1 if /.*ServeRAID Controller Number\s(\d*).*/;

        if (/.*Controller type.*:\s(.*)/) {
            my $name = $1;
            my ($serial, $capacity, $scsi, $channel, $state);

            $logger->debug("ServeRaid: ipssend GETCONFIG $slot PD");
            foreach (`ipssend GETCONFIG $slot PD 2>/dev/null`) {
                # Example Output :
                #   Channel #1:
                #      Target on SCSI ID 0
                #         Device is a Hard disk
                #         SCSI IDg: 0
                #         PFA (Yes/No)             : No
                #         Stateg  : Online (ONL)
                #         Size (in MB)/(in sectors): 34715/71096368
                #         Device ID                : IBM-ESXSCBR036C3DFQDB2Q6CDKM
                #         FRU part number          : 32P0729
                $channel     = $1 if /.*Channel #(.*):/;
                $scsi        = $1 if /.*SCSI ID.*:\s(.*)/;
                $state        = $1 if /.*State.*\((.*)\)/;        
                $capacity    = $1 if /.*Size.*:\s(\d*)\/(\d*)/;
                $serial     = $1 if /.*Device ID.*:\s(.*)/;
            
                if (/.*FRU part number.*:\s(.*)/) {
                    my $model = $1;
                    my $manufacturer = Ocsinventory::Agent::Backend::OS::Linux::Storages::getManufacturer($serial);
                    ## my $fullname = "$name $slot/$channel/$scsi $state";

                    $logger->debug("ServeRaid: found $model, $manufacturer, $model, SCSI, disk, $capacity, $serial, ");

                    $common->addStorages({
                        NAME         => "$manufacturer $model",
                        MANUFACTURER     => $manufacturer,
                        MODEL         => $model,
                        DESCRIPTION     => "SCSI",
                        TYPE         => "disk",
                        DISKSIZE     => $capacity,
                        SERIALNUMBER     => $serial,
                        FIRMWARE     => ""
                    }); 
                    # don't undef $channel, appear only once for several drive.
                    $scsi = $state = $capacity = $serial = undef;
                }
            }
        }
    }
}

1;