From 865d9029c1113acde6b5c300c75f727fa68cdfea Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Wed, 25 Sep 2013 00:20:38 +0200 Subject: [PATCH] =?utf8?q?Ajout=20:=20local/swap=20:=20calcule=20pr=C3=A9?= =?utf8?q?=C3=A7is=C3=A9ment=20l'utilisation=20du=20swap=20de=20chaque=20p?= =?utf8?q?rocessus.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- local/swap | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 local/swap diff --git a/local/swap b/local/swap new file mode 100755 index 0000000..50f85cf --- /dev/null +++ b/local/swap @@ -0,0 +1,28 @@ +#!/bin/sh -eu +# SYNTAX: +# DESCRIPTION: print sorted swap usage of processes using it + +lastpid= +swap=0 +sudo grep -H '^Swap:' /proc/*/smaps 2>/dev/null | +while IFS=: read -r file x size x + do + pid=${file#/proc/} + pid=${pid%/smaps} + size=${size% kB} + size=${size##* } + if test "$pid" = "$lastpid" + then swap=$(( swap + size )) + else + if test "$swap" -gt 0 + then printf "%u pid=%u cmd=%s\n" "$swap" "$lastpid" "$(tr '\000' ' '