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.
In reply to Re: Parsing 'uptime' output
by rob_au
in thread Parsing 'uptime' output
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |