1System::Info(3)       User Contributed Perl Documentation      System::Info(3)
2
3
4

NAME

6       System::Info - Factory for system specific information objects
7

SYNOPSIS

9           use System::Info;
10
11           my $si = System::Info->new;
12
13           printf "Hostname:              %s\n", $si->host;
14           printf "Number of CPU's:       %s\n", $si->ncpu;
15           printf "Processor type:        %s\n", $si->cpu_type; # short
16           printf "Processor description: %s\n", $si->cpu;      # long
17           printf "OS and version:        %s\n", $si->os;
18
19       or
20
21           use System::Info qw( sysinfo );
22           printf "[%s]\n", sysinfo ();
23
24       or
25
26           $ perl -MSystem::Info=si_uname -le print+si_uname
27

DESCRIPTION

29       System::Info tries to present system-related information, like number
30       of CPU's, architecture, OS and release related information in a system-
31       independent way.  This releases the user of this module of the need to
32       know if the information comes from Windows, Linux, HP-UX, AIX, Solaris,
33       Irix, or VMS, and if the architecture is i386, x64, pa-risc2, or arm.
34

METHODS

36   System::Info->new
37       Factory method, with fallback to the information in "POSIX::uname ()".
38
39   sysinfo
40       "sysinfo" returns a string with "host", "os" and "cpu_type".
41
42   sysinfo_hash
43       "sysinfo_hash" returns a hash reference with basic system information,
44       like:
45
46         { cpu       => 'Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (GenuineIntel 2700MHz)',
47           cpu_count => '1 [8 cores]',
48           cpu_cores => 8,
49           cpu_type  => 'x86_64',
50           distro    => 'openSUSE Tumbleweed 20171030',
51           hostname  => 'foobar',
52           os        => 'linux - 4.13.10-1-default [openSUSE Tumbleweed 20171030]',
53           osname    => 'Linux',
54           osvers    => '4.13.10-1-default'
55           }
56
57   si_uname (@args)
58       This class gathers most of the uname(1) info, make a comparable
59       version. Takes almost the same arguments:
60
61           a for all (can be omitted)
62           n for nodename
63           s for os name and version
64           m for cpu name
65           c for cpu count
66           p for cpu_type
67

SEE ALSO

69       There are more modules that provide system and/or architectural
70       information.
71
72       Where System::Info aims at returning the information that is useful for
73       bug reports, some other modules focus on a single aspect (possibly with
74       way more variables and methods than System::Info does supports), or are
75       limited to use on a specific architecture, like Windows or Linux.
76
77       Here are some of the alternatives and how to replace that code with
78       what System::Info offers. Not all returned values will be exactly the
79       same.
80
81   Sys::Hostname
82        use Sys::Hostname;
83        say "Hostname: ", hostname;
84
85        ->
86
87        use System::Info;
88        my $si = System::Info->new;
89        say "Hostname: ", $si->host;
90
91       Sys::Hostname is a CORE module, and will always be available.
92
93   Unix::Processors
94        use Unix::Processors;
95        my $up = Unix::Processors->new;
96        say "CPU type : ", $up->processors->[0]->type;
97        say "CPU count: ", $up->max_physical;
98        say "CPU cores: ", $up->max_online;
99        say "CPU speed: ", $up->max_clock;
100
101        ->
102
103        use System::Info;
104        my $si = System::Info->new;
105        say "CPU type : ", $si->cpu;
106        say "CPU count: ", $si->ncpu;
107        say "CPU cores: ", $si->ncore;
108        say "CPU speed: ", $si->cpu =~ s{^.*\b([0-9.]+)\s*[A-Z]Hz.*}{$1}r;
109
110       The number reported by max_physical is inaccurate for modern CPU's
111
112   Sys::Info
113       Sys::Info has a somewhat rigid configuration, which causes it to fail
114       installation on e.g. (modern versions of) CentOS and openSUSE
115       Tumbleweed.
116
117       It aims at returning a complete set of information, but as I cannot
118       install it on openSUSE Tumbleweed, I cannot test it and show the
119       analogies.
120
121   Sys::CPU
122        use Sys::CPU;
123        say "CPU type : ", Sys::CPU::cpu_type  ();
124        say "CPU count: ", Sys::CPU::cpu_count ();
125        say "CPU speed: ", Sys::CPU::cpu_clock ();
126
127        ->
128
129        use System::Info;
130        my $si = System::Info->new;
131        say "CPU type : ", $si->get_cpu;         # or ->cpu
132        say "CPU count: ", $si->get_core_count;  # or ->ncore
133        say "CPU speed: ", $si->get_cpu =~ s{^.*\b([0-9.]+)\s*[A-Z]Hz.*}{$1}r;
134
135       The speed reported by Sys::CPU is the current speed, and it will change
136       from call to call. YMMV.
137
138       Sys::CPU is not available on CPAN anymore, but you can still get is
139       from BackPAN.
140
141   Devel::Platform::Info
142       Devel::Platform::Info derives information from the files "/etc/issue",
143       "/etc/.issue" and the output of the commands "uname -a" (and "-m",
144       "-o", "-r", and "-s") and "lsb_release -a". It returns no information
145       on CPU type, CPU speed, or Memory.
146
147        use Devel::Platform::Info;
148        my $info = Devel::Platform::Info->new->get_info ();
149
150        ->
151
152        use System::Info;
153        my $si = System::Info->new;
154        my $info = {
155           archname => $si->cpu_type,
156           codename => undef,
157           is32bit  => undef,
158           is64bit  => undef,
159           kernel   => "$^O-".$si->_osvers,
160           kname    => $si->_osname,
161           kvers    => $si->_osvers,
162           osflag   => $^O,
163           oslabel  => $si->distro,
164           osname   => undef,
165           osvers   => $si->distro,
166           };
167
168   Devel::CheckOS
169       This one does not return the OS information as such, but features an
170       alternative to $^O.
171
173       (c) 2016-2022, Abe Timmerman & H.Merijn Brand, All rights reserved.
174
175       With contributions from Jarkko Hietaniemi, Campo Weijerman, Alan
176       Burlison, Allen Smith, Alain Barbet, Dominic Dunlop, Rich Rauenzahn,
177       David Cantrell.
178
179       This library is free software; you can redistribute it and/or modify it
180       under the same terms as Perl itself.
181
182       See:
183
184       •   <http://www.perl.com/perl/misc/Artistic.html>
185
186       •   <http://www.gnu.org/copyleft/gpl.html>
187
188       This program is distributed in the hope that it will be useful, but
189       WITHOUT ANY WARRANTY; without even the implied warranty of
190       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
191
192
193
194perl v5.34.0                      2022-01-21                   System::Info(3)
Impressum