Sys::Load - Perl module for getting the current system load and uptime


Sys-Load documentation Contained in the Sys-Load distribution.

Index


Code Index:

NAME

Top

Sys::Load - Perl module for getting the current system load and uptime

SYNOPSIS

Top

  use Sys::Load qw/getload uptime/;
  print "System load: ", (getload())[0], "\n";
  print "System uptime: ", int uptime(), "\n";

DESCRIPTION

Top

getload() returns 3 elements: representing load averages over the last 1, 5 and 15 minutes. On failure empty list is returned.

uptime() returns the system uptime in seconds. Returns 0 on failure.

EXPORT

None by default.

AUTHOR

Top

Peter BARABAS, <z0d [@] artifact [.] hu>

SEE ALSO

Top

getloadavg(3), uptime(1)


Sys-Load documentation Contained in the Sys-Load distribution.

package Sys::Load;

use 5.006;
use strict;
use warnings;

require Exporter;
require DynaLoader;

our @ISA = qw(Exporter DynaLoader);

our @EXPORT_OK = qw( getload uptime );

our $VERSION = '0.2';

bootstrap Sys::Load $VERSION;

# Preloaded methods go here.

use constant UPTIME => "/proc/uptime";

sub uptime {
  open(FILE, UPTIME) || return 0;
  my $line = <FILE>;
  my($uptime, $idle) = split /\s+/, $line;
  close FILE;
  return $uptime;
}

1;

__END__