<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package GLPI::Agent::Task::Inventory::AIX::Softwares;

use strict;
use warnings;

use parent 'GLPI::Agent::Task::Inventory::Module';

use GLPI::Agent::Tools;

use constant    category    =&gt; "software";

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

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

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

    my $softwares = _getSoftwaresList(
        command =&gt; 'lslpp -c -l',
        logger  =&gt; $logger
    );
    return unless $softwares;

    foreach my $software (@$softwares) {
        $inventory-&gt;addEntry(
            section =&gt; 'SOFTWARES',
            entry   =&gt; $software
        );
    }

}

sub _getSoftwaresList {
    my $handle = getFileHandle(@_);
    next unless $handle;

    # skip headers
    my $line = &lt;$handle&gt;;

    my @softwares;
    while (my $line = &lt;$handle&gt;) {
        my @entry = split(/:/, $line);
        next if $entry[1] =~ /^device/;

        $entry[6] =~ s/\s+$//;

        push @softwares, {
            COMMENTS =&gt; $entry[6],
            FOLDER   =&gt; $entry[0],
            NAME     =&gt; $entry[1],
            VERSION  =&gt; $entry[2],
        };
    }
    close $handle;

    return \@softwares;
}

1;
</pre></body></html>