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