in reply to Parsing 'uptime' output
For example:
use Date::Calc qw/ Normalize_DHMS /; use IO::File; # get_uptime function - returns uptime from /proc/uptime # as 4-member array representing current system uptime in # days, hours, minutes and seconds sub get_uptime { my $uptime; my $fh = IO::File->new('/proc/uptime', 'r'); $uptime = (split /\s+/, <$fh>)[0] if defined $fh; return Normalize_DHMS(0, 0, 0, $uptime) if defined $uptime; }
A similar approach could be taken to obtain load average information from /proc/loadavg.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Parsing 'uptime' output
by sauoq (Abbot) on Aug 19, 2002 at 01:29 UTC | |
by blakem (Monsignor) on Aug 19, 2002 at 08:32 UTC | |
by sauoq (Abbot) on Aug 19, 2002 at 15:00 UTC | |
by blakem (Monsignor) on Aug 19, 2002 at 16:19 UTC | |
by sauoq (Abbot) on Aug 19, 2002 at 17:08 UTC |