File: Storages.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 (86 lines) | stat: -rw-r--r-- 2,857 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
package Ocsinventory::Agent::Backend::OS::HPUX::Storages;

sub check  { $^O =~ /hpux/ }

sub run {
    my $params = shift;
    my $common = $params->{common};
 
    my @all_type = ("tape","disk") ;
    my $type;
 
    my $description;
    my $path;
    my $vendor;
    my $ref;
    my $size;
 
    my $devdsk;
    my $devrdsk;
    my $revlvl;
    my $alternate;
 
    for ( @all_type ) {
        $type = "$_";
        for ( `ioscan -kFnC $type | cut -d ':' -f 1,11,18` ) {
            if ( /(\S+)\:(\S+)\:(\S+)\s+(\S+)/ ) {
                $description = $1;
                $path = $2;
                $vendor = $3;
                $ref = $4;
            };
            $alternate = 0 ;
            if (  $type eq "disk" ) {
                if ( /\s+(\/dev\/dsk\/\S+)\s+(\/dev\/rdsk\/\S+)/ ) {
                    #print "1 $1 2 $2 \n";
                    $devdsk=$1;
                    $devrdsk=$2;
                    # We look if we are on an alternate link
                    for ( `pvdisplay $devdsk 2> /dev/null` ) {
                         if ( /$devdsk\.+lternate/ ) {
                             $alternate=1;
                         };
                    };
                    # We are not on an alternate link
                    if ( $alternate eq 0 ) {
                        #$size = `diskinfo -b $devrdsk`; 
                        for ( `diskinfo -v $devrdsk`) {
                             if ( /^\s+size:\s+(\S+)/ ) {
                                 $size=$1;
                                 $size = int ( $size/1024 ) if $size;
                             };
                             if ( /^\s+rev level:\s+(\S+)/ ) {
                                 $revlvl=$1;
                             };
                        };
                        #print "vendor $vendor ref $ref type $type description $description path $path size $size\n";
                        $common->addStorages({
                            MANUFACTURER => $vendor,
                            MODEL => $ref,
                            NAME => $devdsk,
                            DESCRIPTION => $description,
                            TYPE => $type,
                            DISKSIZE => $size,
                            FIRMWARE => $revlvl,
                        });
                    };
                };
            } else {
                # We look for tapes
                if ( /^\s+(\/dev\/rmt\/\Sm)\s+/ ) {
                    $devdsk=$1;
                    $common->addStorages({
                        MANUFACTURER => $vendor,
                        MODEL => $ref,
                        NAME => $devdsk,
                        DESCRIPTION => $description,
                        TYPE => $type,
                        DISKSIZE => ''
                    });
                };
            };
        };
    };
}

1;