File Coverage

blib/lib/System/Info/AIX.pm
Criterion Covered Total %
statement 9 50 18.0
branch 0 14 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 2 2 100.0
total 14 74 18.9


line stmt bran cond sub pod time code
1             package System::Info::AIX;
2              
3 2     2   14 use strict;
  2         4  
  2         60  
4 2     2   11 use warnings;
  2         4  
  2         54  
5              
6 2     2   12 use base "System::Info::Base";
  2         3  
  2         929  
7              
8             our $VERSION = "0.050";
9              
10             =head1 NAME
11              
12             System::Info::AIX - Object for specific AIX info.
13              
14             =head1 DESCRIPTION
15              
16             =head2 $si->prepare_sysinfo
17              
18             Use os-specific tools to find out more about the system.
19              
20             =cut
21              
22             sub prepare_sysinfo {
23 0     0 1   my $self = shift;
24 0           $self->SUPER::prepare_sysinfo;
25              
26 0           local $ENV{PATH} = "$ENV{PATH}:/usr/sbin";
27 0           $self->prepare_os;
28              
29 0           my @lsdev = grep m/Available/ => `lsdev -C -c processor -S Available`;
30 0           $self->{__cpu_count} = scalar @lsdev;
31              
32 0           my ($info) = grep m/^\S+/ => @lsdev;
33 0           ($info) = $info =~ m/^(\S+)/;
34 0           $info .= " -a 'state type'";
35              
36 0           my ($cpu) = grep m/\benable:[^:\s]+/ => `lsattr -E -O -l $info`;
37 0           ($cpu) = $cpu =~ m/\benable:([^:\s]+)/;
38 0           $cpu =~ s/\bPowerPC(?=\b|_)/PPC/i;
39              
40 0           (my $cpu_type = $cpu) =~ s/_.*//;
41 0           $self->{__cpu} = $cpu;
42 0           $self->{__cpu_type} = $cpu_type;
43              
44 0           my $os = $self->_os;
45 0 0         if ( $> == 0 ) {
46 0           chomp (my $k64 = `bootinfo -K 2>/dev/null`);
47 0 0         $k64 and $os .= "/$k64";
48 0           chomp (my $a64 = `bootinfo -y 2>/dev/null`);
49 0 0         $a64 and $cpu_type .= "/$a64";
50             }
51 0           $self->{__os} = $os;
52             } # prepare_sysinfo
53              
54             =head2 $si->prepare_os
55              
56             Use os-specific tools to find out more about the operating system.
57              
58             Abbreviations used in AIX OS version include
59              
60             ML Maintenance Level
61             TL Technology Level
62             SP Service Pack
63             CSP Conclusive/Last SP
64             RD Release Date (YYWW)
65              
66             When the OS version reports as C, the C<05> is
67             the C number. Newer versions of AIX report using C, where older
68             AIX releases report using C. See C.
69              
70             =cut
71              
72             sub prepare_os {
73 0     0 1   my $self = shift;
74              
75 0           my $os = $self->_os;
76             # First try the format used since 5.3ML05
77 0           chomp ($os = `oslevel -s`);
78 0 0 0       if ($os =~ m/^(\d+)-(\d+)-(\d+)-(\d+)$/ && $1 >= 5300) {
79             # 6100-09-03-1415 = AIX 6.1.0.0 TL09 SP03 (release 2014, week 15)
80             # Which will show as AIX 6.1.0.0/TL09-03
81 0           $os = join (".", split m// => $1) . "/TL$2-$3";
82             }
83             else {
84 0           chomp ($os = `oslevel -r`);
85             # 5300-12 = AIX 5.3.0.0/ML12
86 0 0         if ($os =~ m/^(\d+)-(\d+)$/) {
87 0           $os = join (".", split // => $1) . "/ML$2";
88             }
89             else {
90 0           chomp ($os = `oslevel`);
91             # 5.3.0.0 = AIX 5.3.0.0
92              
93             # And try figuring out at what maintainance level we are
94 0           my $ml = "00";
95 0           for (grep m/ML\b/ => `instfix -i`) {
96 0 0         if (m/All filesets for (\S+) were found/) {
97 0           $ml = $1;
98 0 0         $ml =~ m/^\d+-(\d+)_AIX_ML/ and $ml = "ML$1";
99 0           next;
100             }
101 0           $ml =~ s/\+*$/+/;
102             }
103 0           $os .= "/$ml";
104             }
105             }
106 0           $os =~ s/^/AIX - /;
107 0           $self->{__os} = $os;
108             } # prepare_os
109              
110             1;
111              
112             __END__