summaryrefslogtreecommitdiffstats
path: root/lib/VServer.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VServer.pm')
-rw-r--r--lib/VServer.pm20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/VServer.pm b/lib/VServer.pm
index acbb8af..bd823b9 100644
--- a/lib/VServer.pm
+++ b/lib/VServer.pm
@@ -82,18 +82,22 @@ sub get_name($) {
sub get_loadavg($) {
my $id = shift;
my $dir = get_proc_dir($id) || return undef;
- my @load = undef;
+ my %load = ();
open(my $cvirt, "<", "$dir/cvirt") || return undef;
while (<$cvirt>) {
if ($_ =~ m/^loadavg:\s*([0-9.]+)\s*([0-9.]+)\s*([0-9.]+)$/) {
- @load = ($1, $2, $3);
+ %load = (
+ load1 => $1,
+ load5 => $2,
+ load15 => $3
+ );
last;
}
}
close($cvirt);
- return @load;
+ return \%load;
}
sub get_mem($) {
@@ -205,11 +209,11 @@ returned.
=item B<get_loadavg($context)>
-Returns the three (load1, load5, load15) load values for the vserver
-specified by the given context id. The functions reads the B<cvirt>
-file inside the I</proc> directory of the vserver and parses the
-loadavg values. The function returns the three values or B<undef>
-if any error occurs.
+Returns the three (load1, load5, load15) load values as hasref for
+the vserver specified by the given context id. The functions reads
+the B<cvirt> file inside the I</proc> directory of the vserver and
+parses the loadavg values. The function returns a hashref or
+B<undef> if any error occurs.
=item B<get_mem($context)>