AMF-Perl
view release on metacpan or search on metacpan
doc/code.html view on Meta::CPAN
import string
class cpuUsage:
def getCpuUsage(self, arg):
child = os.popen("uptime")
output = child.read()
tokens = output.split()
#Remove commas.
map(lambda x: x.replace(',', ''), tokens)
array = []
hash = {'Name' : 'L 1', 'Value' : tokens[9]}
array.append(hash)
hash = {'Name' : 'L 5', 'Value' : tokens[10]}
array.append(hash)
hash = {'Name' : 'L 15', 'Value' : tokens[11]}
array.append(hash)
return array
my ($proto)=@_;
my $self={};
bless $self, $proto;
return $self;
}
sub getCpuUsage
{
my $output = `uptime`;
my @tokens = split /\s+/, $output;
#Remove commas.
@tokens = map {s/,//g; $_} @tokens;
my @array;
my %hash = ("Name" => 'L 1', "Value" => $tokens[10]);
push @array, \%hash;
my %hash1 = ("Name" => 'L 5', "Value" => $tokens[11]);
push @array, \%hash1;
my %hash2 = ("Name" => 'L 15', "Value" => $tokens[12]);
push @array, \%hash2;
return \@array;
doc/examples/cpu/cpu.pl view on Meta::CPAN
my $self={};
bless $self, $proto;
return $self;
}
sub getCpuUsage
{
my ($self, $arg1, $arg2) = @_;
my $output = `uptime`;
my @tokens = split /\s+/, $output;
#Remove commas.
@tokens = map {s/,//g; $_} @tokens;
my @array;
my %hash = ("Name" => 'L 1', "Value" => $tokens[10]);
push @array, \%hash;
my %hash1 = ("Name" => 'L 5', "Value" => $tokens[11]);
push @array, \%hash1;
my %hash2 = ("Name" => 'L 15', "Value" => $tokens[12]);
push @array, \%hash2;
return \@array;
( run in 0.552 second using v1.01-cache-2.11-cpan-f56aa216473 )