Merge pull request #205 from iangregory/portability-improvements
Improve portability when fetching process memory
This commit is contained in:
commit
6d562f98b0
1 changed files with 5 additions and 5 deletions
|
@ -1088,15 +1088,15 @@ sub is_open_port {
|
||||||
|
|
||||||
sub get_process_memory {
|
sub get_process_memory {
|
||||||
my $pid = shift;
|
my $pid = shift;
|
||||||
return 0 unless -f "/proc/$pid/status";
|
my @mem = `ps -p $pid -o rss`;
|
||||||
my @pdata = grep { /RSS:/ } get_file_contents "/proc/$pid/status";
|
return 0 if scalar @mem != 2;
|
||||||
map { s/.*RSS:\s*(\d+)\s*kB\s*$/$1*1024/ge } @pdata;
|
return $mem[1]*1024;
|
||||||
return $pdata[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_other_process_memory {
|
sub get_other_process_memory {
|
||||||
my @procs = `ps -eo pid,cmd`;
|
my @procs = `ps -eaxo pid,command`;
|
||||||
map {
|
map {
|
||||||
|
s/.*PID.*//;
|
||||||
s/.*mysqld.*//;
|
s/.*mysqld.*//;
|
||||||
s/.*\[.*\].*//;
|
s/.*\[.*\].*//;
|
||||||
s/^\s+$//g;
|
s/^\s+$//g;
|
||||||
|
|
Loading…
Reference in a new issue