The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Unix::Uptime - Determine the current uptime, in seconds, across different *NIX architectures

SYNOPSIS

  # Standard Usage
  use Unix::Uptime;

  my $uptime = Unix::Uptime->uptime(); # 2345

  # "HiRes" mode
  use Unix::Uptime qw(:hires);

  my $uptime = Unix::Uptime->uptime_hires(); # 2345.123593

DESCRIPTION

This is a rather simple module that abstracts the task of figuring out the current system uptime, in seconds. It was born out of a desire to do this on non-Linux systems, without SNMP. If you want to use SNMP, there are pleanty of modules on CPAN already.

Currently, this module just supports getting the uptime on Linux, FreeBSD, Darwin (Mac OS X), OpenBSD, and NetBSD. It should be easy enough to add support for other operating systems, though.

OPTIONS

While this module doesn't provide any functions for exporting, if the tag :hires is given, then uptime_hires static method will be available. It returns decimal numbers when possible, but on some systems it is simply an alias for uptime(). This will likely require the Time::HiRes module to be available. Otherwise, they will simply be whole seconds.

METHODS

The following static (class) methods are available:

uptime()

This takes no arguments, and simply returns the number of seconds this system has been running. This will always be an integer.

uptime_hires()

This is only available if the :hires import tag is used. It returns the system uptime with a greater resolution than one second on supported platforms. On some platforms, its results may not be any more precise than uptime(), though. On different platforms, this requires different additional modules:

Linux

No additional requirements.

FreeBSD

Requires Time::HiRes

Darwin, OpenBSD, NetBSD

No more precise than uptime()

SEE ALSO

Sys::Load(3) and Sys::Uptime(3) for Linux-specific implementations.

Win32::Uptime for Win32.

BUGS

This currently doesn't support more than Linux, FreeBSD, Darwin (Mac OS X), OpenBSD, and NetBSD. Contributions for other operating systems would be welcome.

CAVEATS

NOTE: This module is still a work in progress, under fairly heavy development. While I think the final API should be mostly finalized at this point, I won't commit to an API freeze until version 1.0.

CONTRIBUTING

This project is developed using git. The repository may be browsed at: http://git.pioto.org/gitweb/Unix-Uptime.git

Patches in git-format-patch style are preferred. Either send them to me by email, or open an RT ticket http://rt.cpan.org/Public/Bug/Report.html?Queue=Unix-Uptime.

AUTHOR

Mike Kelly <pioto@pioto.org>

COPYRIGHT AND LICENSE

Copyright 2008, 2009 Mike Kelly

Distributed under the same terms as Perl itself. See http://dev.perl.org/licenses/ for more information.