File Coverage

blib/lib/System/Info/Solaris.pm
Criterion Covered Total %
statement 9 43 20.9
branch 0 12 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 2 2 100.0
total 14 65 21.5


line stmt bran cond sub pod time code
1             package System::Info::Solaris;
2              
3 2     2   15 use strict;
  2         4  
  2         62  
4 2     2   10 use warnings;
  2         4  
  2         52  
5              
6 2     2   10 use base "System::Info::Base";
  2         5  
  2         1548  
7              
8             our $VERSION = "0.050";
9              
10             =head1 NAME
11              
12             System::Info::Solaris - Object for specific Solaris/Sun-os 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 0           $self->prepare_os;
26              
27 0           local $ENV{PATH} = "/usr/sbin:$ENV{PATH}";
28              
29 0           my @psrinfo = `psrinfo -v`;
30 0           my ($psrinfo) = grep m/the .* operates .* [gm]hz/ix => @psrinfo;
31 0           my ($type, $speed, $magnitude) =
32             $psrinfo =~ m/the (.+) processor.*at (.+?)\s*([GM]hz)/i;
33 0 0         $type =~ s/(v9)$/ $1 ? "64" : ""/e;
  0            
34              
35 0           my $cpu = $self->_cpu;
36              
37 0 0         if (-d "/usr/platform") { # Solaris but not OSF/1.
    0          
38 0           chomp (my $platform = `uname -i`);
39 0           my $pfpath = "/usr/platform/$platform/sbin/prtdiag";
40 0 0         if (-x "$pfpath") { # Not on Solaris-x86
41 0           my $prtdiag = `$pfpath`;
42 0           ($cpu) = $prtdiag =~ m/^System .+\(([^\s\)]+)/;
43 0 0         unless ($cpu) {
44 0           my ($cpu_line) = grep m/\s+on-?line\s+/i => split /\n/ => $prtdiag;
45 0           ($cpu = (split " " => $cpu_line)[4]) =~ s/.*,//;
46             }
47 0           $cpu .= " ($speed$magnitude)";
48             }
49             else {
50 0           $cpu .= " ($speed$magnitude)";
51             }
52             }
53             elsif (-x "/usr/sbin/sizer") { # OSF/1.
54 0           $cpu = $type;
55 0           chomp ($type = `sizer -implver`);
56             }
57              
58 0           my $ncpu = grep m/on-?line/ => `psrinfo`;
59              
60 0           $self->{__cpu_type} = $type;
61 0           $self->{__cpu} = $cpu;
62 0           $self->{__cpu_count} = $ncpu;
63 0           return $self;
64             } # prepare_sysinfo
65              
66             =head2 $si->prepare_os
67              
68             Use os-specific tools to find out more about the operating system.
69              
70             =cut
71              
72             sub prepare_os {
73 0     0 1   my $self = shift;
74              
75 0           my ($osn, $osv) = ($self->_osname, $self->_osvers);
76 0 0 0       if ($^O =~ /solaris|sunos/i && $osv > 5) {
77 0           $osn = "Solaris";
78 0           $osv = "2." . (split m/\./ => $osv, 2)[1];
79             }
80 0           $self->{__os} = join " - ", $osn, $osv;
81             } # prepare_os
82              
83             1;
84              
85             __END__