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.
README
SysInfo.xs
lib/Linux/SysInfo.pm
+samples/sysinfo.pl
t/00-load.t
t/10-standard.t
t/20-extended.t
--- #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:
WriteMakefile(
NAME => 'Linux::SysInfo',
AUTHOR => 'Vincent Pit <perl@profvince.com>',
+ LICENSE => 'perl',
VERSION_FROM => 'lib/Linux/SysInfo.pm',
ABSTRACT_FROM => 'lib/Linux/SysInfo.pm',
PL_FILES => {},
Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call.
VERSION
- Version 0.03
+ Version 0.04
SYNOPSIS
use Linux::SysInfo qw/sysinfo/;
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);
PREINIT:
struct sysinfo si;
NV l;
- HV* h;
+ HV *h;
CODE:
if (sysinfo(&si) == -1) {
XSRETURN_UNDEF;
OUTPUT:
RETVAL
-SV *
-LS_HAS_EXTENDED()
-CODE:
- RETVAL = newSViv(SYSINFO_EXTENDED); /* mortalized in RETVAL */
-OUTPUT:
- RETVAL
=head1 VERSION
-Version 0.03
+Version 0.04
=cut
-our $VERSION = '0.03';
+our $VERSION = '0.04';
=head1 SYNOPSIS
--- /dev/null
+#!/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/;
+}
#!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);