Hi,
On 2015-08-21 09:51, Nathan Scott wrote:
>>
>> I'm using this script to see which processes have (parts of) their memory
>> swapped:
>>
>> #!/bin/sh
>> #
>> # Total swap usage as shown by free(1) and /proc/swaps does not exactly match
>> # with the swap usage summed up for individual processes as done below due to
>> # pages in swap cache being included in free(1) and /proc/swaps usage amount.
>>
>> for p in /proc/[1-9]* ; do
>> awk '/^[0-9]+ \(/ {printf "%-8s%-18s", $1, $2; nextfile} \
>> /Swap:/ {swap+=$2} END {printf "%8.4f MB\n", swap/1024}' $p/stat $p/smaps
>> \
>> 2>/dev/null ;
>> done|sort -gk3|awk '{s=s+$3;print $0}END{printf "Total:%28.4f %s\n", s,
>> "MB"}'
>
> It looks like this script has a different definition of swapped to the value
> that proc.runq.swapped presents. The script is looking at smaps, and looking
> for any mappings within a process listed as swapped out. Reading through the
> pmdaproc code, proc.runq.swapped counts processes where the address space is
> entirely swapped out (not just parts thereof), and this is infered using only
> values from /proc/pid/stat.
thanks, code had a comment about that but I couldn't find any of such
processes during later testing so it wasn't clear.
>> So looks like proc.runq.swapped is currently meaningless?
>
> Just a different meaning to the value being presented by the script, I
> think, not meaningless.
Yup, the above is certainly useful metric to have.
> We have no code looking inside the smaps files at all currently in PCP -
> new metrics could certainly be added to export values from there though,
> its a SMOP.
>
> I did notice going through the atop code recently that it also looks at
> smaps, but only if a special option is used (-R) and it's using smaps to
> extract this (and nothing else - no swap metrics from there FWLIW) ...
>
> (we don't support this in pcp-atop yet, but we could if a PMDA was made
> to export this metric - it would need similar code to that which you're
> after to mimic your script above, looking at Pss: instead of Swap: tho).
Thanks,
--
Marko Myllynen
|