Skip Menu |

This queue is for tickets about the Sys-Statistics-Linux CPAN distribution.

Report information
The Basics
Id: 24317
Status: resolved
Priority: 0/
Queue: Sys-Statistics-Linux

People
Owner: Nobody in particular
Requestors: RENEEB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.09_16



Subject: "find"-method to search in the stats
Hi Jonny, I would appreciate if you could add a "find" method to Sys::Statistics::Linux. This would made it easier to search for specific values. This is a short proposal: In Linux.pm: sub find{ my ($self,$part,%config) = @_; return unless $part and keys %config > 0; return unless STATISTICS->{$part}; my $return = {}; my $stats = $self->get->{$part}; for my $key(keys %config){ my $value = $config{$key}; if(ref($value) eq 'Regexp'){ for my $pid(keys %$stats){ if(exists $stats->{$pid}->{$key} and $stats->{$pid}->{$key} =~ $value){ $return->{$pid} = $stats->{$pid}; } } } elsif(not ref($value)){ for my $pid(keys %$stats){ if(exists $stats->{$pid}->{$key} and $stats->{$pid}->{$key} eq $value){ $return->{$pid} = $stats->{$pid}; } } } } return $return; } Then you can do thing like this: /usr/bin/perl use strict; use warnings; use Data::Dumper; use Sys::Statistics::Linux; my $lxs = Sys::Statistics::Linux->new(Processes => 1); sleep 1; my $stat = $lxs->find('Processes',cmd => qr/\(su\)/); print Dumper($stat); to find all Processes that have "(su)" as the value for "cmd"
From: BLOONIX [...] cpan.org
On Do. 11. Jan. 2007, 05:58:17, RENEEB wrote: Show quoted text
> to find all Processes that have "(su)" as the value for "cmd"
Hi Renee, there are now two ways for you: search() and fproc() I think that fproc() is that want you need. Cheers, Jonny