3

I am trying to monitor the swapping activity in a Linux Server in the last, say, 1, 5 or 15 minutes.

One way is to run vmstat and keep watching si and so counters during these intervals.

However how can I check as a "one-shot" action (e.g. through a Nagios plugin) for a value showing the swapping activity during the aforementioned intervals?

In other words I need a way to instantly check whether my Server is actively swapping.

1

Believe you could use /proc/vmstat output, say with

cat /proc/vmstat | grep pswp

command.

This will show you swap in and swap out counters.

Or:

only si:

vmstat 1 1 | awk 'NR == 1 {next} NR == 2 {for (i = 1; i <= NF; i++) fields[$i] = i; next} {split($0, data); item = data[fields["si"]]; print item; totals[fields["si"]] += item} NR >= 6 + 2 {exit}'

only so:

vmstat 1 1 | awk 'NR == 1 {next} NR == 2 {for (i = 1; i <= NF; i++) fields[$i] = i; next} {split($0, data); item = data[fields["si"]]; print item; totals[fields["so"]] += item} NR >= 6 + 2 {exit}'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.