source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Backend/OS/AIX/Hardware.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 1.8 KB
Line 
1package Ocsinventory::Agent::Backend::OS::AIX::Hardware;
2use strict;
3sub check { 1 }
4
5# NOTE:
6# Q: SSN can also use `uname -n`? What is the best?
7# A: uname -n since it doesn't need root priv
8
9sub run {
10  my $params = shift;
11  my $common = $params->{common};
12
13  # Using "type 0" section
14  my( $SystemSerial , $SystemModel, $SystemManufacturer, $BiosManufacturer,
15    $BiosVersion, $BiosDate);
16
17  #lsvpd
18  my @lsvpd = `lsvpd`;
19  # Remove * (star) at the beginning of lines
20  s/^\*// for (@lsvpd);
21               
22  #Search Firmware Hard
23  my $flag=0;
24  my $fw;
25  for (@lsvpd){
26    if (/^DS Platform Firmware/) { $flag=1 };
27    if ( ($flag) && /^RM (.+)/) {$fw=$1;chomp($fw);$fw =~ s/(\s+)$//g;last};
28  }
29  $flag=0;
30  for (@lsvpd){
31    if (/^DS System Firmware/) { $flag=1 };
32    if ( ($flag) && /^RM (.+)/) {$BiosVersion=$1;chomp($BiosVersion);$BiosVersion =~ s/(\s+)$//g;last};
33  }
34  $flag=0;
35  for (@lsvpd){
36    if (/^DS System VPD/) { $flag=1 };
37    if ( ($flag) && /^TM (.+)/) {$SystemModel=$1;chomp($SystemModel);$SystemModel =~ s/(\s+)$//g;};
38    if ( ($flag) && /^SE (.+)/) {$SystemSerial=$1;chomp($SystemSerial);$SystemSerial =~ s/(\s+)$//g;};
39    if ( ($flag) && /^FC .+/) {$flag=0;last}
40  }
41
42# Fetch the serial number like prtconf do
43  if (! $SystemSerial) {
44    $flag=0;
45    foreach (`lscfg -vpl sysplana00`) {
46      if ($flag) {
47        if (/\.+(\S*?)$/) {
48          $SystemSerial = $1;
49        }
50        last;
51      } else {
52          $flag = 1 if /\s+System\ VPD/;
53      }
54    }
55  }
56
57  $BiosManufacturer='IBM';
58  $SystemManufacturer='IBM';
59  $BiosVersion .= "(Firmware :".$fw.")";
60
61  # Writing data
62  $common->setBios ({
63      SMANUFACTURER => $SystemManufacturer,
64      SMODEL => $SystemModel,
65      SSN => $SystemSerial,
66      BMANUFACTURER => $BiosManufacturer,
67      BVERSION => $BiosVersion,
68      BDATE => $BiosDate,
69    });
70}
71
721;
Note: See TracBrowser for help on using the repository browser.