From 0c18fb50467bcff9b7270427a5b9b5ee141fae0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Mon, 9 Nov 2015 21:40:16 -0300 Subject: [PATCH] memory_by_process: try to be smarted about labels and cleanup field names more deeply --- plugins/system/memory_by_process | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/system/memory_by_process b/plugins/system/memory_by_process index b06e3391..6af7dad4 100755 --- a/plugins/system/memory_by_process +++ b/plugins/system/memory_by_process @@ -30,18 +30,21 @@ if [ "$1" = "config" ]; then { @a = split; $proc = $a[10]; - $proc =~ s|.*/||; + $label = $proc; + $proc =~ s/ .*//; + if($proc =~ /^\[/) { $proc =~ s|/.*||; } else { $proc =~ s|.*/||; } $proc =~ s/:.*//; $proc =~ tr/[]//d; $proc =~ tr/A-Za-z0-9/_/c; $vsz = $a[4]; $total{$proc} += $vsz; + $labels{$proc} = $label; } my $stack = 0; sub draw() { return $stack++ ? "STACK" : "AREA" } print map { - "$_.label $_\n" . + "$_.label " . $labels{$_} . "\n" . "$_.min 0\n" . "$_.draw " . draw() . "\n" . "$_.cdef $_,1024,*\n" @@ -56,7 +59,7 @@ else { @a = split; $proc = $a[10]; - $proc =~ s|.*/||; + if($proc =~ /^\[/) { $proc =~ s|/.*||; } else { $proc =~ s|.*/||; } $proc =~ s/:.*//; $proc =~ tr/[]//d; $proc =~ tr/A-Za-z0-9/_/c;