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; # Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
97        say "CPU count: ", $up->max_physical;          # 4
98        say "CPU cores: ", $up->max_online;            # 8
99        say "CPU speed: ", $up->max_clock;             # 2700
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;  # Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
124        say "CPU count: ", Sys::CPU::cpu_count; # 8
125        say "CPU speed: ", Sys::CPU::cpu_clock; # 2700
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        # { archname => 'x86_64',
150        #   codename => 'n/a',
151        #   is32bit  => 0,
152        #   is64bit  => 1,
153        #   kernel   => 'linux-5.17.4-1-default',
154        #   kname    => 'Linux',
155        #   kvers    => '5.17.4-1-default',
156        #   osflag   => 'linux',
157        #   oslabel  => 'openSUSE',
158        #   osname   => 'GNU/Linux',
159        #   osvers   => '20220426',
160        #   }
161
162        ->
163
164        use System::Info;
165        my $si = System::Info->new;
166        my $info = {
167           archname => $si->cpu_type,       # x86_64
168           codename => undef,
169           is32bit  => undef,
170           is64bit  => undef,
171           kernel   => "$^O-".$si->_osvers, # linux-5.17.4-1-default
172           kname    => $si->_osname,        # Linux
173           kvers    => $si->_osvers,        # 5.17.4-1-default
174           osflag   => $^O,                 # linux
175           oslabel  => $si->distro,         # openSUSE Tumbleweed 20220426
176           osname   => undef,
177           osvers   => $si->distro,         # openSUSE Tumbleweed 20220426
178           };
179
180   Devel::CheckOS
181       This one does not return the OS information as such, but features an
182       alternative to $^O.
183
184   Sys::OsRelease
185       Interface to FreeDesktop.Org's os-release standard.
186
187        use Sys::OsRealease;
188        Sys::OsRelease->init;
189        my $i = Sys::OsRelease->instance;
190        say $i->ansi_color;                 # 0;32
191        say $i->bug_report_url;             # https://bugs.opensuse.org
192        say $i->cpe_name;                   # cpe:/o:opensuse:tumbleweed:20220426
193        say $i->documentation_url;          # https://en.opensuse.org/Portal:Tumbleweed
194        say $i->home_url;                   # https://www.opensuse.org/
195        say $i->id;                         # opensuse-tumbleweed
196        say $i->id_like;                    # opensuse suse
197        say $i->logo;                       # distributor-logo-Tumbleweed
198        say $i->name;                       # openSUSE Tumbleweed
199        say $i->pretty_name;                # openSUSE Tumbleweed
200        say $i->version_id;                 # 20220426
201
203       (c) 2016-2023, Abe Timmerman & H.Merijn Brand, All rights reserved.
204
205       With contributions from Jarkko Hietaniemi, Campo Weijerman, Alan
206       Burlison, Allen Smith, Alain Barbet, Dominic Dunlop, Rich Rauenzahn,
207       David Cantrell.
208
209       This library is free software; you can redistribute it and/or modify it
210       under the same terms as Perl itself.
211
212       See:
213
214       •   <http://www.perl.com/perl/misc/Artistic.html>
215
216       •   <http://www.gnu.org/copyleft/gpl.html>
217
218       This program is distributed in the hope that it will be useful, but
219       WITHOUT ANY WARRANTY; without even the implied warranty of
220       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
221
222
223
224perl v5.38.0                      2023-08-01                   System::Info(3)
Impressum