| 1 | package System::Info::BSD; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 3 | ▶ | use base "System::Info::Base"; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 3 | our $VERSION = "0.051"; | |||||||||||||
| 9 | |||||||||||||||
| 10 | =head1 NAME | ||||||||||||||
| 11 | |||||||||||||||
| 12 | System::Info::BSD - Object for specific BSD 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 | 0 | ▶ | sub prepare_sysinfo { | ||||||||||||
|
Subroutine
prepare_sysinfo: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||
| 23 | 0 | my $self = shift; | |||||||||||||
| 24 | 0 | $self->SUPER::prepare_sysinfo; | |||||||||||||
| 25 | |||||||||||||||
| 26 | 0 | my $sysctl = __get_sysctl (); | |||||||||||||
| 27 | 0 | $self->{__sysctl} = $sysctl; | |||||||||||||
| 28 | |||||||||||||||
| 29 | 0 | my $cpu = $sysctl->{model}; | |||||||||||||
| 30 | |||||||||||||||
| 31 | 0 | ▶ | if (exists $sysctl->{cpuspeed}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 32 | 0 | $cpu .= sprintf " (%.0f MHz)", $sysctl->{cpuspeed}; | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | elsif (exists $sysctl->{cpufrequency}) { | ||||||||||||||
| 35 | 0 | $cpu .= sprintf " (%.0f MHz)", $sysctl->{cpufrequency}/1_000_000; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 0 | ▶ | $self->{__cpu_type} = $sysctl->{machine} if $sysctl->{machine}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | 0 | ▶ | $self->{__cpu} = $cpu if $cpu; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | 0 | $self->{__cpu_count} = $sysctl->{ncpu}; | |||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | return $self; | |||||||||||||
| 43 | } # prepare_sysinfo | ||||||||||||||
| 44 | |||||||||||||||
| 45 | 0 | ▶ | sub __get_sysctl { | ||||||||||||
|
Subroutine
__get_sysctl: not called CC=3 SCAR=24.8
| |||||||||||||||
| 46 | 0 | ▶ | my $sysctl_cmd = -x "/sbin/sysctl" ? "/sbin/sysctl" : "sysctl"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 47 | |||||||||||||||
| 48 | 0 | chomp (my @sysctl = `$sysctl_cmd -a hw`); | |||||||||||||
| 49 | 0 | my %sysctl = map m/^hw\.([\w.]+)\s*[:=]\s*(.*)$/ => @sysctl; | |||||||||||||
| 50 | 0 | ▶ | $sysctl{machine} and $sysctl{machine} =~ s/Power Macintosh/macppc/; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 51 | |||||||||||||||
| 52 | 0 | return \%sysctl; | |||||||||||||
| 53 | } # __get_sysctl | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 3 | 1; | |||||||||||||
| 56 | |||||||||||||||
| 57 | __END__ | ||||||||||||||