root / plugins / system / memory_by_process @ f9000cdc
Historique | Voir | Annoter | Télécharger (1,63 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# |
| 3 |
# Copyright (C) 2006 Holger Levsen |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or |
| 6 |
# modify it under the terms of the GNU General Public License |
| 7 |
# as published by the Free Software Foundation; version 2 dated June, |
| 8 |
# 1991. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; if not, write to the Free Software |
| 17 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 |
# |
| 19 |
|
| 20 |
if [ "$1" = "config" ]; then |
| 21 |
echo "graph_title VM by Process" |
| 22 |
echo 'graph_args --base 1024k' |
| 23 |
echo 'graph_vlabel VM size' |
| 24 |
echo 'graph_category system' |
| 25 |
echo "graph_info Shows contribution of each process to VM size" |
| 26 |
|
| 27 |
ps auxww | perl -e ' |
| 28 |
$junk = <>; |
| 29 |
while (<>) |
| 30 |
{
|
| 31 |
@a = split; |
| 32 |
$proc = $a[10]; |
| 33 |
$proc =~ s|.*/||; |
| 34 |
$proc =~ s/:.*//; |
| 35 |
$proc =~ tr/[]//d; |
| 36 |
$proc =~ tr/A-Za-z0-9/_/c; |
| 37 |
$vsz = $a[4]; |
| 38 |
$total{$proc} += $vsz;
|
| 39 |
} |
| 40 |
my $stack = 0; |
| 41 |
sub draw() { return $stack++ ? "STACK" : "AREA" }
|
| 42 |
print map |
| 43 |
{
|
| 44 |
"$_.label $_\n" . |
| 45 |
"$_.min 0\n" . |
| 46 |
"$_.draw " . draw() . "\n" . |
| 47 |
"$_.cdef $_,1024,*\n" |
| 48 |
} |
| 49 |
sort keys %total; |
| 50 |
' |
| 51 |
exit 0 |
| 52 |
else |
| 53 |
ps auxww | perl -e ' |
| 54 |
$junk = <>; |
| 55 |
while (<>) |
| 56 |
{
|
| 57 |
@a = split; |
| 58 |
$proc = $a[10]; |
| 59 |
$proc =~ s|.*/||; |
| 60 |
$proc =~ s/:.*//; |
| 61 |
$proc =~ tr/[]//d; |
| 62 |
$proc =~ tr/A-Za-z0-9/_/c; |
| 63 |
$vsz = $a[4]; |
| 64 |
$total{$proc} += $vsz;
|
| 65 |
} |
| 66 |
print map {"$_.value $total{$_}\n"} sort keys %total'
|
| 67 |
fi |
