]> git.vpit.fr Git - perl/modules/Linux-SysInfo.git/blob - samples/sysinfo.pl
Importing Linux-SysInfo-0.08.tar.gz
[perl/modules/Linux-SysInfo.git] / samples / sysinfo.pl
1 #!/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use lib qw{blib/lib blib/arch};
7
8 use Linux::SysInfo qw/sysinfo LS_HAS_EXTENDED/;
9
10 my $si = sysinfo;
11 die 'sysinfo() failed ! (should be pretty rare but it did happen)' unless $si;
12
13 print 'Extended fields are ', (LS_HAS_EXTENDED ? '' : 'NOT '), "available on your system.\n\n";
14
15 print "Values :\n";
16 print "- $_: $si->{$_}\n" for sort keys %$si;
17
18 if (LS_HAS_EXTENDED) {
19  print "\n";
20  print 'You have the mem_unit field set to ', $si->{mem_unit}, ', hence ',
21  ($si->{mem_unit} == 1) ? "the memory values are the actual sizes in bytes :\n"
22                         : "the sizes in bytes are actually :\n";
23  print '- ', $_, ': ', $si->{$_} * $si->{mem_unit}, "\n" for sort
24  qw/totalram freeram sharedram bufferram totalswap freeswap totalhigh freehigh/;
25 }