X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Fsysinfo.pl;fp=samples%2Fsysinfo.pl;h=2ca2f90a374954c60f79599712c60fe629acd43a;hb=aeb4782b4d78bdce2873eef541f5759dd9dcae42;hp=0000000000000000000000000000000000000000;hpb=6459a6c2b2ebbcd7a8be8fce533739ad96b1347b;p=perl%2Fmodules%2FLinux-SysInfo.git diff --git a/samples/sysinfo.pl b/samples/sysinfo.pl new file mode 100755 index 0000000..2ca2f90 --- /dev/null +++ b/samples/sysinfo.pl @@ -0,0 +1,23 @@ +#!/bin/env perl + +use strict; +use warnings; + +use Linux::SysInfo qw/sysinfo LS_HAS_EXTENDED/; + +my $si = sysinfo; +die 'sysinfo() failed ! (should be pretty rare but it did happen)' unless $si; + +print 'Extended fields are ', (LS_HAS_EXTENDED ? '' : 'NOT '), "available on your system.\n\n"; + +print "Values :\n"; +print "- $_: $si->{$_}\n" for sort keys %$si; + +if (LS_HAS_EXTENDED) { + print "\n"; + print 'You have the mem_unit field set to ', $si->{mem_unit}, ', hence ', + ($si->{mem_unit} == 1) ? "the memory values are the actual sizes in bytes :\n" + : "the sizes in bytes are actually :\n"; + print '- ', $_, ': ', $si->{$_} * $si->{mem_unit}, "\n" for sort + qw/totalram freeram sharedram bufferram totalswap freeswap totalhigh freehigh/; +}