
On 14 August 2013 10:45, Trent W. Buck <trentbuck@gmail.com> wrote:
Thanks, I already know free(1). By the word "logged" I meant a history or cumulative report of swapfile use, not a snapshot. For example does the kernel
while free -m | tail 1; do sleep 15m; done | logger -t swapstats
Thanks for that Trent, terse but instructive! Good to be reminded of 'logger'. However it does not address the point that I must not have expressed clearly enough in my prior comments about about vmstat. I want to avoid sampling because it introduces uncertainty and overhead when answering a question that does not require sampling. This kind of sampling method requires knowledge of what sampling resolution is small enough to ensure that a brief use of the swapfile would not occur in between "free -m" snapshots, and be missed in the logfile. Due to inexperience of active swapfiles, I lack that knowledge, and that knowledge gap introduces doubt that makes any sampling method feel unreliable for me. It seems to me that the most best answer to whether the swapfile has ever been used would be provided by some flag that indicates that the swapfile has been used, if any such thing exists anywhere on the system. I'd have thought something would be /proc Also, there might even be an "uncertainty principle" at play. If I have to sample so often that I have to log a huge amount of data, it might cause swapping :) I found this: http://www.linuxinsight.com/proc_vmstat.html from which I conclude that the answer to my question "has the swapfile ever been used" would be authoritatively given by: $ cat /proc/vmstat | grep pswpout pswpout 0 I was unable to find a more authoritative documentation of /proc/vmstat for kernel 3.2.0. I've had a look at the kernel source mm/vmstat.c but it is not obvious so I'll probably give up and leave it at that, unless anyone has anything helpful to add.