File Coverage

blib/lib/System/Info/HPUX.pm
Criterion Covered Total %
statement 9 63 14.2
branch 0 46 0.0
condition 0 9 0.0
subroutine 3 5 60.0
pod 1 1 100.0
total 13 124 10.4


line stmt bran cond sub pod time code
1             package System::Info::HPUX;
2              
3 2     2   15 use strict;
  2         4  
  2         60  
4 2     2   11 use warnings;
  2         4  
  2         53  
5              
6 2     2   11 use base "System::Info::Base";
  2         3  
  2         2215  
7              
8             our $VERSION = "0.051";
9              
10             =head1 NAME
11              
12             System::Info::HPUX - Object for specific HP-UX 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           $self->{__os} =~ s/hp-ux/HP-UX/;
27 0           chomp (my $k64 = `/usr/bin/getconf KERNEL_BITS 2>/dev/null`);
28 0 0         length $k64 and $self->{__os} .= "/$k64";
29              
30             # ioscan is always available
31 0           $self->{__cpu_count} = grep m/^processor/ => `/usr/sbin/ioscan -knfCprocessor`;
32              
33 0           $self->_prepare_cpu_type;
34 0           return $self;
35             } # prepare_sysinfo
36              
37             sub _prepare_cpu_type {
38 0     0     my $self = shift;
39              
40 0           my $parisc = 0;
41             # For now, unknown cpu_types are set as the Generic
42 0           chomp (my $cv = `/usr/bin/getconf CPU_VERSION 2>/dev/null`);
43              
44             # see /usr/include/sys/unistd.h for hex values
45 0 0 0       if ($cv < 0x20B) {
    0          
    0          
    0          
46             # $self->{__cpu_type} = sprintf("Unknown CPU_VERSION 0x%x", $cv);
47             }
48             elsif ($cv >= 0x20C && $cv <= 0x20E) {
49 0           $self->{__cpu_type} = "Motorola"; # You have an antique
50             }
51             elsif ($cv <= 0x2FF) {
52 0           $self->{__cpu_type} = "PA-RISC";
53 0 0         $self->{__cpu_type} = "PA-RISC1.0" if $cv == 0x20B;
54 0 0         $self->{__cpu_type} = "PA-RISC1.1" if $cv == 0x210;
55 0 0         $self->{__cpu_type} = "PA-RISC1.2" if $cv == 0x211;
56 0 0         $self->{__cpu_type} = "PA-RISC2.0" if $cv == 0x214;
57 0           $parisc++;
58             }
59             elsif ($cv == 0x300) {
60 0           $self->{__cpu_type} = "ia64";
61             }
62             else {
63             # $self->{__cpu_type} = sprintf("Unknown CPU_VERSION 0x%x", $cv);
64             }
65 0 0         if ($parisc) {
66 0           my (@cpu, $lst);
67 0           chomp (my $model = `model`);
68 0           (my $m = $model) =~ s{.*/}{};
69 0           foreach my $f (qw( /usr/sam/lib/mo/sched.models
70             /opt/langtools/lib/sched.models )) {
71 0 0         if (open my $fh, "<", $f) {
72 0           @cpu = grep m/$m/i => <$fh>;
73 0           close $fh;
74 0 0         @cpu and last;
75             }
76             }
77 0 0 0       if (@cpu == 0 && open my $lst,
78             "echo 'sc product cpu;il' | /usr/sbin/cstm |") {
79 0           while (<$lst>) {
80 0 0         s/^\s*(PA)\s*(\d+)\s+CPU Module.*/$m 1.1 $1$2/ or next;
81 0 0         $2 =~ m/^8/ and s/ 1.1 / 2.0 /;
82 0           push @cpu, $_;
83             }
84             }
85 0 0 0       if (@cpu and $cpu[0] =~ m/^\S+\s+(\d+\.\d+[a-z]?)\s+(\S+)/) {
86 0           my ($arch, $cpu) = ("PA-RISC$1", $2);
87 0           $self->{__cpu} = $cpu;
88 0           chomp (my $hw3264 =
89             `/usr/bin/getconf HW_32_64_CAPABLE 2>/dev/null`);
90 0           (my $osvers = $self->{__os}) =~ s/.*[AB]\.//;
91 0           $osvers =~ s{/.*}{};
92 0 0         $osvers <= 10.20 and $hw3264 = 0;
93 0 0         if ($hw3264 == 1) {
    0          
94 0           $self->{__cpu_type} = $arch . "/64";
95             }
96             elsif ($hw3264 == 0) {
97 0           $self->{__cpu_type} = $arch . "/32";
98             }
99             }
100             }
101             else {
102 0           my $machinfo = `/usr/contrib/bin/machinfo`;
103 0 0         if ($machinfo =~ m/processor model:\s+(\d+)\s+(.*)/) {
    0          
104 0           $self->{__cpu} = $2;
105             }
106             elsif ($machinfo =~ m{\s*[0-9]+\s+(intel.r.*processor)\s*\(([0-9.]+)\s*([GM])Hz.*}mi) {
107 0           my ($m, $s, $h) = ($1, $2, $3);
108 0           $m =~ s{ series processor}{};
109 0 0         $h eq "G" and $s = int ($s * 1024);
110 0           $self->{__cpu} = "$m/$s";
111             }
112             $machinfo =~ m/Clock\s+speed\s+=\s+(.*)/ and
113 0 0         $self->{__cpu} .= "/$1";
114             }
115              
116 0           (my $v = $self->{__osvers}) =~ s/^[A-Z]+\.//;
117 0           $self->{__distro} = "HP-UX $v";
118             } # _prepare_cpu_type
119              
120             1;
121              
122             __END__