Sys::uptime - tied OO interface to uptime

Published at: 2000.08.18 23:38:38

NAME

Sys::uptime - tied OO interface to uptime

SYNOPSIS

    use Sys::uptime;
    tie $uptime, 'Sys::uptime';

    printf "Load average over the last minute: %s\n",
        $uptime->load('one');

    print "Uptime was: '$uptime'\n";

OR

    # Update internal uptime cache after 2 seconds
    tie $uptime, 'Sys::uptime', 2;
    print "Load average now: %s\n",
        $uptime->load('one');

    sleep 3;
    print "Load average 3 seconds later: %s\n",
        $uptime->load('one');

DESCRIPTION

Sys::uptime is an interface to your system's uptime command. It parses the output of that command and lets you use simple object methods to access the data fields.

In addition, though, Sys::uptime also implements a tied interface that automatically updates its internal uptime cache after a certain number of seconds. For example, say that you wished to get the system load average now, then again in five seconds. Sys::uptime makes that very simple, because it automatically refreshes the information without you needing to do anything.

You can set the number of seconds after which the internal cache will be updated when you tie the variable:

    tie $foo, 'Sys::uptime', 20;

will tell Sys::uptime that it should update $foo's cache every 20 seconds.

METHODS

The following methods can be called on the variable that you tie to Sys::uptime. All values come directly from the uptime output.

AUTHOR

Benjamin Trott, ben@rhumba.pair.com



© 2000 Benjamin Trott, ben@rhumba.pair.com