line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package System::Info; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
211298
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
89
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.062"; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
15
|
use base "Exporter"; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
249
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw( &sysinfo &sysinfo_hash &si_uname ); |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
859
|
use System::Info::AIX; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
65
|
|
12
|
2
|
|
|
2
|
|
818
|
use System::Info::BSD; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
13
|
2
|
|
|
2
|
|
779
|
use System::Info::Cygwin; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
99
|
|
14
|
2
|
|
|
2
|
|
876
|
use System::Info::Darwin; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
66
|
|
15
|
2
|
|
|
2
|
|
773
|
use System::Info::Generic; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
16
|
2
|
|
|
2
|
|
778
|
use System::Info::Haiku; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
55
|
|
17
|
2
|
|
|
2
|
|
838
|
use System::Info::HPUX; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
18
|
2
|
|
|
2
|
|
1123
|
use System::Info::Irix; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
54
|
|
19
|
2
|
|
|
2
|
|
13
|
use System::Info::Linux; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
44
|
|
20
|
2
|
|
|
2
|
|
883
|
use System::Info::Solaris; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
55
|
|
21
|
2
|
|
|
2
|
|
797
|
use System::Info::VMS; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
22
|
2
|
|
|
2
|
|
842
|
use System::Info::Windows; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1242
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
System::Info - Factory for system specific information objects |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use System::Info; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $si = System::Info->new; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
printf "Hostname: %s\n", $si->host; |
35
|
|
|
|
|
|
|
printf "Number of CPU's: %s\n", $si->ncpu; |
36
|
|
|
|
|
|
|
printf "Processor type: %s\n", $si->cpu_type; # short |
37
|
|
|
|
|
|
|
printf "Processor description: %s\n", $si->cpu; # long |
38
|
|
|
|
|
|
|
printf "OS and version: %s\n", $si->os; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
or |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use System::Info qw( sysinfo ); |
43
|
|
|
|
|
|
|
printf "[%s]\n", sysinfo (); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
or |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$ perl -MSystem::Info=si_uname -le print+si_uname |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
System::Info tries to present system-related information, like number of CPU's, |
52
|
|
|
|
|
|
|
architecture, OS and release related information in a system-independent way. |
53
|
|
|
|
|
|
|
This releases the user of this module of the need to know if the information |
54
|
|
|
|
|
|
|
comes from Windows, Linux, HP-UX, AIX, Solaris, Irix, or VMS, and if the |
55
|
|
|
|
|
|
|
architecture is i386, x64, pa-risc2, or arm. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 System::Info->new |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Factory method, with fallback to the information in C<< POSIX::uname () >>. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new { |
66
|
97
|
|
|
97
|
1
|
5510
|
my $factory = shift; |
67
|
|
|
|
|
|
|
|
68
|
97
|
50
|
|
|
|
477
|
$^O =~ m/aix/i and return System::Info::AIX->new; |
69
|
97
|
50
|
|
|
|
405
|
$^O =~ m/bsd|dragonfly/i and return System::Info::BSD->new; |
70
|
97
|
50
|
|
|
|
207
|
$^O =~ m/cygwin/i and return System::Info::Cygwin->new; |
71
|
97
|
50
|
|
|
|
210
|
$^O =~ m/darwin/i and return System::Info::Darwin->new; |
72
|
97
|
50
|
|
|
|
234
|
$^O =~ m/haiku/ and return System::Info::Haiku->new; |
73
|
97
|
50
|
|
|
|
270
|
$^O =~ m/hp-?ux/i and return System::Info::HPUX->new; |
74
|
97
|
50
|
|
|
|
208
|
$^O =~ m/irix/i and return System::Info::Irix->new; |
75
|
97
|
100
|
|
|
|
656
|
$^O =~ m/linux/i and return System::Info::Linux->new; |
76
|
1
|
50
|
|
|
|
5
|
$^O =~ m/solaris|sunos|osf/i and return System::Info::Solaris->new; |
77
|
1
|
50
|
|
|
|
4
|
$^O =~ m/VMS/ and return System::Info::VMS->new; |
78
|
1
|
50
|
|
|
|
5
|
$^O =~ m/mswin32|windows/i and return System::Info::Windows->new; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
10
|
return System::Info::Generic->new; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 sysinfo |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
C returns a string with C, C and C. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub sysinfo { |
90
|
1
|
|
|
1
|
1
|
308
|
my $si = System::Info->new; |
91
|
1
|
50
|
|
|
|
31
|
my @fields = $_[0] |
92
|
|
|
|
|
|
|
? qw( host os cpu ncpu cpu_type ) |
93
|
|
|
|
|
|
|
: qw( host os cpu_type ); |
94
|
1
|
|
|
|
|
12
|
return join " ", @{ $si }{ map "_$_" => @fields }; |
|
1
|
|
|
|
|
68
|
|
95
|
|
|
|
|
|
|
} # sysinfo |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 sysinfo_hash |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
C returns a hash reference with basic system information, like: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
{ cpu => 'Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (GenuineIntel 2700MHz)', |
102
|
|
|
|
|
|
|
cpu_count => '1 [8 cores]', |
103
|
|
|
|
|
|
|
cpu_cores => 8, |
104
|
|
|
|
|
|
|
cpu_type => 'x86_64', |
105
|
|
|
|
|
|
|
distro => 'openSUSE Tumbleweed 20171030', |
106
|
|
|
|
|
|
|
hostname => 'foobar', |
107
|
|
|
|
|
|
|
os => 'linux - 4.13.10-1-default [openSUSE Tumbleweed 20171030]', |
108
|
|
|
|
|
|
|
osname => 'Linux', |
109
|
|
|
|
|
|
|
osvers => '4.13.10-1-default' |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub sysinfo_hash { |
115
|
1
|
|
|
1
|
1
|
9
|
my $si = System::Info->new; |
116
|
|
|
|
|
|
|
return { |
117
|
|
|
|
|
|
|
hostname => $si->{_host}, |
118
|
|
|
|
|
|
|
cpu => $si->{_cpu}, |
119
|
|
|
|
|
|
|
cpu_type => $si->{_cpu_type}, |
120
|
|
|
|
|
|
|
cpu_count => $si->{_ncpu}, |
121
|
|
|
|
|
|
|
cpu_cores => $si->{_ncore}, |
122
|
|
|
|
|
|
|
os => $si->{_os}, |
123
|
|
|
|
|
|
|
osname => $si->{__osname}, |
124
|
|
|
|
|
|
|
osvers => $si->{__osvers}, |
125
|
|
|
|
|
|
|
distro => $si->{__distro} |
126
|
|
|
|
|
|
|
|| join " " => $si->{__osname}, $si->{__osvers}, |
127
|
1
|
|
33
|
|
|
97
|
}; |
128
|
|
|
|
|
|
|
} # sysinfo |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 si_uname (@args) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This class gathers most of the C info, make a comparable |
133
|
|
|
|
|
|
|
version. Takes almost the same arguments: |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
a for all (can be omitted) |
136
|
|
|
|
|
|
|
n for nodename |
137
|
|
|
|
|
|
|
s for os name and version |
138
|
|
|
|
|
|
|
m for cpu name |
139
|
|
|
|
|
|
|
c for cpu count |
140
|
|
|
|
|
|
|
p for cpu_type |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub si_uname { |
145
|
0
|
|
|
0
|
1
|
|
my $si = System::Info->new; |
146
|
0
|
|
|
|
|
|
return $si->si_uname (@_); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |