]> git.vpit.fr Git - perl/modules/Linux-SysInfo.git/blobdiff - samples/sysinfo.pl
Importing Linux-SysInfo-0.04.tar.gz
[perl/modules/Linux-SysInfo.git] / samples / sysinfo.pl
diff --git a/samples/sysinfo.pl b/samples/sysinfo.pl
new file mode 100755 (executable)
index 0000000..2ca2f90
--- /dev/null
@@ -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/;
+}