From: Vincent Pit Date: Sun, 29 Jun 2008 16:41:24 +0000 (+0200) Subject: Importing Linux-SysInfo-0.04.tar.gz X-Git-Tag: v0.04^0 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=aeb4782b4d78bdce2873eef541f5759dd9dcae42;p=perl%2Fmodules%2FLinux-SysInfo.git Importing Linux-SysInfo-0.04.tar.gz --- diff --git a/Changes b/Changes index 65ca78c..5665e24 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Linux-SysInfo +0.04 2007-05-03 09:35 UTC + + Add : The samples/sysinfo.pl sample script. + + Chg : Declare LS_HAS_EXTENDED with newCONSTSUB. + + Fix : Missing LICENSE in Makefile.PL + + Fix : Skipping extended tests will now display the good reason. + 0.03 2007-04-18 10:25 UTC + Fix : Load average raw values have to be shifted on a platform dependant way. They are now correctly reported. diff --git a/MANIFEST b/MANIFEST index 03999d1..ad30d73 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5,6 +5,7 @@ Makefile.PL README SysInfo.xs lib/Linux/SysInfo.pm +samples/sysinfo.pl t/00-load.t t/10-standard.t t/20-extended.t diff --git a/META.yml b/META.yml index 8d262a3..6dd7092 100644 --- a/META.yml +++ b/META.yml @@ -1,8 +1,8 @@ --- #YAML:1.0 name: Linux-SysInfo -version: 0.03 +version: 0.04 abstract: Perl interface to the sysinfo(2) Linux system call. -license: ~ +license: perl generated_by: ExtUtils::MakeMaker version 6.32 distribution_type: module requires: diff --git a/Makefile.PL b/Makefile.PL index 708db53..979d78b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -5,6 +5,7 @@ use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Linux::SysInfo', AUTHOR => 'Vincent Pit ', + LICENSE => 'perl', VERSION_FROM => 'lib/Linux/SysInfo.pm', ABSTRACT_FROM => 'lib/Linux/SysInfo.pm', PL_FILES => {}, diff --git a/README b/README index 8bca0c2..c138c40 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call. VERSION - Version 0.03 + Version 0.04 SYNOPSIS use Linux::SysInfo qw/sysinfo/; diff --git a/SysInfo.xs b/SysInfo.xs index 7017009..f7509c4 100644 --- a/SysInfo.xs +++ b/SysInfo.xs @@ -43,6 +43,10 @@ PROTOTYPES: ENABLE BOOT: { + HV *stash; + stash = gv_stashpv("Linux::SysInfo", TRUE); + newCONSTSUB(stash, "LS_HAS_EXTENDED", newSViv(SYSINFO_EXTENDED)); + SYSINFO_KEY_SET_HASH(key_uptime); SYSINFO_KEY_SET_HASH(key_load1); SYSINFO_KEY_SET_HASH(key_load5); @@ -66,7 +70,7 @@ sysinfo() PREINIT: struct sysinfo si; NV l; - HV* h; + HV *h; CODE: if (sysinfo(&si) == -1) { XSRETURN_UNDEF; @@ -100,9 +104,3 @@ CODE: OUTPUT: RETVAL -SV * -LS_HAS_EXTENDED() -CODE: - RETVAL = newSViv(SYSINFO_EXTENDED); /* mortalized in RETVAL */ -OUTPUT: - RETVAL diff --git a/lib/Linux/SysInfo.pm b/lib/Linux/SysInfo.pm index c1e602d..9746646 100644 --- a/lib/Linux/SysInfo.pm +++ b/lib/Linux/SysInfo.pm @@ -9,11 +9,11 @@ Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call. =head1 VERSION -Version 0.03 +Version 0.04 =cut -our $VERSION = '0.03'; +our $VERSION = '0.04'; =head1 SYNOPSIS 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/; +} diff --git a/t/20-extended.t b/t/20-extended.t index c54751e..28806a4 100644 --- a/t/20-extended.t +++ b/t/20-extended.t @@ -1,12 +1,13 @@ #!perl -T -use Test::More tests => 4; +use Test::More; use Linux::SysInfo qw/sysinfo LS_HAS_EXTENDED/; -SKIP: -{ - skip 'Your kernel does not support extended sysinfo fields', 4 unless LS_HAS_EXTENDED; +unless (LS_HAS_EXTENDED) { + plan skip_all => 'your kernel does not support extended sysinfo fields'; +} else { + plan tests => 4; my $si = sysinfo; ok(defined $si);