This file is indexed.

/usr/share/fusioninventory/lib/FusionInventory/Agent/Task/Inventory/HPUX/Storages.pm is in fusioninventory-agent 1:2.3.10.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
package FusionInventory::Agent::Task::Inventory::HPUX::Storages;

use strict;
use warnings;

use FusionInventory::Agent::Tools;

sub isEnabled  {
    return
        canRun('ioscan');
}

sub doInventory {
    my (%params) = @_;

    my $inventory = $params{inventory};
    my $logger    = $params{logger};

    foreach my $disk (_getDisks($logger)) {
        $inventory->addEntry(section => 'STORAGES', entry => $disk);
    }

    foreach my $tape (_getTapes($logger)) {
        $inventory->addEntry(section => 'STORAGES', entry => $tape);
    }
}

sub _getDisks {
    my ($logger) = @_;

    my @disks;
    foreach my $device (
        _parseIoscan(command => 'ioscan -kFnC disk', logger => $logger)
    ) {
        # skip alternate links
        next if getFirstMatch(
            command => "pvdisplay $device->{NAME}",
            pattern => qr/$device->{NAME}\.+lternate/
        );

        my $handle = getFileHandle(
            command => "diskinfo -v $device->{NAME}",
            logger  => $logger
        );
        while (my $line = <$handle>) {
            if ($line =~ /^\s+size:\s+(\S+)/) {
                $device->{DISKSIZE} = int($1/1024);
            }
            if ($line =~ /^\s+rev level:\s+(\S+)/) {
                $device->{FIRMWARE} = $1;
            }
        }
        close $handle;

        $device->{TYPE} = 'disk';
        push @disks, $device;
    }

    return @disks;
}

sub _getTapes {
    my ($logger) = @_;

    my @tapes;
    foreach my $device (
        _parseIoscan(command => 'ioscan -kFnC tape', logger => $logger)
    ) {
        $device->{TYPE} = 'tape';
        push @tapes, $device;
    }

    return @tapes;
}

sub _parseIoscan {
    my $handle = getFileHandle(@_);
    return unless $handle;

    my @devices;
    my ($description, $model, $manufacturer);
    while (my $line = <$handle>) {
        if ($line =~ /^\s+(\S+)/ ) {
            my $device = $1;

            push @devices, {
                MANUFACTURER => $manufacturer,
                MODEL        => $model,
                NAME         => $device,
                DESCRIPTION  => $description,
            };
        } else {
            my @infos = split(/:/, $line);
            $description = $infos[0];
            ($manufacturer, $model) = $infos[17] =~ /^(\S+) \s+ (\S.*\S)$/x;
        }
    }
    close $handle;

    return @devices;
}

1;